generated from dkoshkin/golang-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
164 lines (136 loc) · 4.28 KB
/
checks.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# Copyright 2023 Dimitri Koshkin. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
name: checks
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
branches:
- main
jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install tools via asdf
uses: asdf-vm/actions/install@v3.0.2
with:
asdf_branch: v0.11.2
- name: Run unit tests
run: make test
- name: Annotate tests
if: always()
uses: guyarb/golang-test-annotations@v0.8.0
with:
test-results: test.json
lint:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Gather tool versions
uses: endorama/asdf-parse-tool-versions@v1
id: versions
- name: github-actions-lint
uses: reviewdog/action-actionlint@v1
with:
fail_on_error: true
reporter: github-pr-review
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2
with:
fail_on_error: true
reporter: github-pr-review
go_version: v${{ fromJson(steps.versions.outputs.tools).golang }}
golangci_lint_version: v${{ fromJson(steps.versions.outputs.tools).golangci-lint }}
pre-commit:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Gather tool versions
uses: endorama/asdf-parse-tool-versions@v1
id: versions
- uses: actions/setup-go@v5
with:
go-version: ${{ fromJson(steps.versions.outputs.tools).golang }}
check-latest: false
cache: true
- uses: mfinelli/setup-shfmt@v3
with:
shfmt-version: ${{ fromJson(steps.versions.outputs.tools).shfmt }}
- uses: pre-commit/action@v3.0.1
with:
extra_args: --all-files --show-diff-on-failure
env:
SKIP: no-commit-to-branch,golangci-lint
build-and-run:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install tools via asdf
uses: asdf-vm/actions/install@v3.0.2
with:
asdf_branch: v0.11.2
- name: Build
run: make build-snapshot
- name: Run binary
run: |
./dist/status-writer-action_linux_amd64_v1/status-writer-action --version
run-with-influxdb:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install tools via asdf
uses: asdf-vm/actions/install@v3.0.2
with:
asdf_branch: v0.11.2
- name: Build
run: make build-snapshot
- name: Run status-writer-action with InfluxDB
uses: ./.github/composite-actions/status-writer
# always run this step, even if previous steps fail
if: always()
with:
# select the backend to use
backend: "influxdb"
# set InfluxDB details
influxdb_token: "${{ secrets.INFLUXDB_TOKEN }}"
influxdb_url: "${{ secrets.INFLUXDB_URL }}"
influxdb_org: "${{ secrets.INFLUXDB_ORG }}"
influxdb_bucket: "${{ secrets.INFLUXDB_BUCKET }}"
run-with-googlesheets:
runs-on: ubuntu-latest
env:
GOOGLE_APPLICATION_CREDENTIALS: client_secret.json
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install tools via asdf
uses: asdf-vm/actions/install@v3.0.2
with:
asdf_branch: v0.11.2
- name: Build
run: make build-snapshot
- name: Write Google Cloud credentials to file
uses: jsdaniell/create-json@v1.2.3
with:
name: "${{ env.GOOGLE_APPLICATION_CREDENTIALS }}"
json: "${{ secrets.GOOGLE_CREDENTIALS }}"
- name: Run status-writer-action with Google Sheets
uses: ./.github/composite-actions/status-writer
# always run this step, even if previous steps fail
if: always()
with:
# select the backend to use
backend: "googlesheets"
# set Google Sheets details
googlesheets_spreadsheet_id: "${{ secrets.GOOGLESHEETS_SPREADSHEET_ID }}"