Skip to content

Commit

Permalink
allow empty outputs (#2)
Browse files Browse the repository at this point in the history
* allow empty outputs and inputs

* added tests

* fix no inputs test

* fixed no outputs test

* fixed overall tests

* added ci build

* added automerge
  • Loading branch information
mhristof committed Mar 24, 2021
1 parent 68293d5 commit 81414cf
Show file tree
Hide file tree
Showing 5 changed files with 259 additions and 11 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: ci

on:
- push

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: make test
- name: automerge
uses: mhristof/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


7 changes: 5 additions & 2 deletions action/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,24 @@ var md = `# {{ .Name }}
{{ .Description }}
{{ if .Inputs -}}
## Inputs
| Name | Description | Default | Required |
| ---- | ----------- | ------- | -------- |
{{ range $key, $value := .Inputs -}}
| {{ $key }} | {{$value.Description}} | {{$value.Default }} | {{ $value.Required }}|
{{ end }}
{{ end -}}
{{ if .Outputs -}}
## Outputs
| Name | Description |
| ---- | ----------- |
{{ range $key, $value := .Outputs -}}
| {{ $key }} | {{$value.Description}} |
{{ end }}`
{{ end }}
{{ end -}}`

func (c *Config) Markdown() string {
tmpl, err := template.New("markdown").Parse(md)
Expand Down
47 changes: 47 additions & 0 deletions action/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,59 @@ func TestMarkdown(t *testing.T) {
| ---- | ----------- | ------- | -------- |
| who-to-greet | Who to greet | World | true|
## Outputs
| Name | Description |
| ---- | ----------- |
| random-number | Random number |
`),
},
{
name: "no outputs",
yaml: heredoc.Doc(`
name: 'Hello World'
description: 'Greet someone'
inputs:
who-to-greet: # id of input
description: 'Who to greet'
required: true
default: 'World'
`),
expected: heredoc.Doc(`
# Hello World
Greet someone
## Inputs
| Name | Description | Default | Required |
| ---- | ----------- | ------- | -------- |
| who-to-greet | Who to greet | World | true|
`),
},
{
name: "no inputs",
yaml: heredoc.Doc(`
name: 'Hello World'
description: 'Greet someone'
outputs:
random-number:
description: "Random number"
value: ${{ steps.random-number-generator.outputs.random-id }}
`),
expected: heredoc.Doc(`
# Hello World
Greet someone
## Outputs
| Name | Description |
| ---- | ----------- |
| random-number | Random number |
`),
},
}
Expand Down
11 changes: 5 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
module github.com/mhristof/githubactions-docs

go 1.14
go 1.16

require (
github.com/MakeNowJust/heredoc v1.0.0
github.com/atsushinee/go-markdown-generator v0.0.0-20191121114853-83f9e1f68504
github.com/mhristof/go-update v0.1.0
github.com/riywo/loginshell v0.0.0-20200815045211-7d26008be1ab
github.com/sirupsen/logrus v1.5.0
github.com/spf13/cobra v1.0.0
github.com/stretchr/testify v1.5.1
gopkg.in/yaml.v2 v2.2.8
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.1.3
github.com/stretchr/testify v1.7.0
gopkg.in/yaml.v2 v2.4.0
)

0 comments on commit 81414cf

Please sign in to comment.