Skip to content

Commit 8665c58

Browse files
authored
Merge pull request #232 from arnested/job-summary
Add GitHub Actions Job Summary
2 parents a77b85c + 84d22a7 commit 8665c58

File tree

6 files changed

+36
-9
lines changed

6 files changed

+36
-9
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ jobs:
3939
- run: |
4040
test '${{ steps.go-version.outputs.latest }}' == '1.18'
4141
- run: |
42-
test '${{ steps.go-version.outputs.matrix }}' == '["1.18","1.17","1.16","1.15","1.14","1.13"]'
42+
test '${{ steps.go-version.outputs.matrix }}' == '["1.13","1.14","1.15","1.16","1.17","1.18"]'

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,14 @@ jobs:
7373
my-go-workflow:
7474
runs-on: ubuntu-latest
7575
steps:
76-
- uses: actions/checkout@v2
76+
- uses: actions/checkout@v3
7777
- uses: arnested/go-version-action@v1
7878
id: go-version
7979
- name: Install Go ${{ steps.go-version.outputs.minimal }}
80-
uses: actions/setup-go@v2
80+
uses: actions/setup-go@v3
8181
with:
8282
go-version: ${{ steps.go-version.outputs.minimal }}
83+
check-latest: true
8384
```
8485

8586
![Log of running action](docs/action-run.png)
@@ -102,7 +103,7 @@ jobs:
102103
outputs:
103104
matrix: ${{ steps.versions.outputs.matrix }}
104105
steps:
105-
- uses: actions/checkout@v2
106+
- uses: actions/checkout@v3
106107
- uses: arnested/go-version-action@v1
107108
id: versions
108109
test:
@@ -113,13 +114,22 @@ jobs:
113114
matrix:
114115
version: ${{ fromJSON(needs.go-versions.outputs.matrix) }}
115116
steps:
116-
- uses: actions/checkout@v2
117+
- uses: actions/checkout@v3
117118
- name: Install Go
118-
uses: actions/setup-go@v2
119+
uses: actions/setup-go@v3
119120
with:
120121
go-version: ${{ matrix.version }}
122+
check-latest: true
121123
- name: go test
122124
run: go test -v -race -cover -covermode=atomic -coverprofile=coverage.txt ./...
123125
```
124126

125127
![The workflow summary](docs/action-matrix-summary.png)
128+
129+
## Summary
130+
131+
The action writes a [GitHub Actions Job
132+
Summary](https://github.blog/2022-05-09-supercharging-github-actions-with-job-summaries/)
133+
with values it identified:
134+
135+
![Job summary](docs/job-summary.png)

__tests__/main.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ test('test minimal version', () => {
1212
})
1313

1414
test('test latest version', () => {
15-
expect(latest(['1.18', '1.17', '1.16', '1.15', '1.14', '1.13'])).toEqual(
15+
expect(latest(['1.13', '1.14', '1.15', '1.16', '1.17', '1.18'])).toEqual(
1616
'1.18'
1717
)
1818
})
1919

2020
test('test version matrix', () => {
2121
const t = JSON.parse(fs.readFileSync('__tests__/testdata/dl.json', 'utf8'))
2222
const m = matrix('1.13', t)
23-
expect(m).toEqual(['1.18', '1.17', '1.16', '1.15', '1.14', '1.13'])
23+
expect(m).toEqual(['1.13', '1.14', '1.15', '1.16', '1.17', '1.18'])
2424
})

docs/job-summary.png

33.4 KB
Loading

src/go-versions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const matrix = (min: string, tags: Version[]): string[] => {
6666
return v2 !== null && semverGte(v2, minClean)
6767
})
6868

69-
return versions
69+
return versions.reverse()
7070
}
7171

7272
const latest = (versions: string[]): string => {

src/main.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,23 @@ async function run(): Promise<void> {
3232
core.info(`minimal go version: ${min} - from go.mod`)
3333
core.info(`latest go version: ${lat} - from https://go.dev/dl/`)
3434
core.info(`go version matrix: ${mat} - from https://go.dev/dl/`)
35+
36+
const htmlMat = mat
37+
.map(v => `<a href="https://go.dev/doc/go${v}">Go ${v}</a>`)
38+
.join('<br>')
39+
40+
await core.summary
41+
.addTable([
42+
[
43+
{data: 'Output', header: true},
44+
{data: 'Value', header: true}
45+
],
46+
['Module', `<a href="https://pkg.go.dev/${name}">${name}</a>`],
47+
['Minimal', `<a href="https://go.dev/doc/go${min}">Go ${min}</a>`],
48+
['Latest', `<a href="https://go.dev/doc/go${lat}">Go ${lat}</a>`],
49+
['Matrix', `${htmlMat}`]
50+
])
51+
.write()
3552
} catch (error) {
3653
core.setFailed((error as Error).message)
3754
}

0 commit comments

Comments
 (0)