Skip to content

Commit 81414cf

Browse files
authored
allow empty outputs (#2)
* allow empty outputs and inputs * added tests * fix no inputs test * fixed no outputs test * fixed overall tests * added ci build * added automerge
1 parent 68293d5 commit 81414cf

File tree

5 files changed

+259
-11
lines changed

5 files changed

+259
-11
lines changed

.github/workflows/ci.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: ci
2+
3+
on:
4+
- push
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- run: make test
12+
- name: automerge
13+
uses: mhristof/github-action-automerge@v1.0.1
14+
with:
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
17+

action/main.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,24 @@ var md = `# {{ .Name }}
4848
4949
{{ .Description }}
5050
51+
{{ if .Inputs -}}
5152
## Inputs
5253
5354
| Name | Description | Default | Required |
5455
| ---- | ----------- | ------- | -------- |
5556
{{ range $key, $value := .Inputs -}}
5657
| {{ $key }} | {{$value.Description}} | {{$value.Default }} | {{ $value.Required }}|
5758
{{ end }}
58-
59+
{{ end -}}
60+
{{ if .Outputs -}}
5961
## Outputs
6062
6163
| Name | Description |
6264
| ---- | ----------- |
6365
{{ range $key, $value := .Outputs -}}
6466
| {{ $key }} | {{$value.Description}} |
65-
{{ end }}`
67+
{{ end }}
68+
{{ end -}}`
6669

6770
func (c *Config) Markdown() string {
6871
tmpl, err := template.New("markdown").Parse(md)

action/main_test.go

+47
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,59 @@ func TestMarkdown(t *testing.T) {
6969
| ---- | ----------- | ------- | -------- |
7070
| who-to-greet | Who to greet | World | true|
7171
72+
## Outputs
73+
74+
| Name | Description |
75+
| ---- | ----------- |
76+
| random-number | Random number |
77+
78+
`),
79+
},
80+
{
81+
name: "no outputs",
82+
yaml: heredoc.Doc(`
83+
name: 'Hello World'
84+
description: 'Greet someone'
85+
inputs:
86+
who-to-greet: # id of input
87+
description: 'Who to greet'
88+
required: true
89+
default: 'World'
90+
`),
91+
expected: heredoc.Doc(`
92+
# Hello World
93+
94+
Greet someone
95+
96+
## Inputs
7297
98+
| Name | Description | Default | Required |
99+
| ---- | ----------- | ------- | -------- |
100+
| who-to-greet | Who to greet | World | true|
101+
102+
`),
103+
},
104+
{
105+
name: "no inputs",
106+
yaml: heredoc.Doc(`
107+
name: 'Hello World'
108+
description: 'Greet someone'
109+
outputs:
110+
random-number:
111+
description: "Random number"
112+
value: ${{ steps.random-number-generator.outputs.random-id }}
113+
`),
114+
expected: heredoc.Doc(`
115+
# Hello World
116+
117+
Greet someone
118+
73119
## Outputs
74120
75121
| Name | Description |
76122
| ---- | ----------- |
77123
| random-number | Random number |
124+
78125
`),
79126
},
80127
}

go.mod

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
module github.com/mhristof/githubactions-docs
22

3-
go 1.14
3+
go 1.16
44

55
require (
66
github.com/MakeNowJust/heredoc v1.0.0
7-
github.com/atsushinee/go-markdown-generator v0.0.0-20191121114853-83f9e1f68504
87
github.com/mhristof/go-update v0.1.0
98
github.com/riywo/#shell v0.0.0-20200815045211-7d26008be1ab
10-
github.com/sirupsen/logrus v1.5.0
11-
github.com/spf13/cobra v1.0.0
12-
github.com/stretchr/testify v1.5.1
13-
gopkg.in/yaml.v2 v2.2.8
9+
github.com/sirupsen/logrus v1.8.1
10+
github.com/spf13/cobra v1.1.3
11+
github.com/stretchr/testify v1.7.0
12+
gopkg.in/yaml.v2 v2.4.0
1413
)

0 commit comments

Comments
 (0)