-
Notifications
You must be signed in to change notification settings - Fork 6
218 lines (196 loc) · 6.42 KB
/
ci.yml
File metadata and controls
218 lines (196 loc) · 6.42 KB
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
name: CI
on:
push:
branches:
- master
paths-ignore:
- '**.md'
- 'LICENSE'
- '**/.gitignore'
- 'Dockerfile'
- '.dockerignore'
- '**.sample'
pull_request:
paths-ignore:
- '**.md'
- 'LICENSE'
- '**/.gitignore'
- 'Dockerfile'
- '.dockerignore'
- '**.sample'
workflow_dispatch:
# env:
# BENCHMARK_DIR: .test
# BENCHMARK_FILE: bench.new
jobs:
test:
name: Test with Go version ${{ matrix.go }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ 'ubuntu-latest' ]
go: [ '1.19' ]
steps:
- id: setup-go
name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- id: checkout
name: Check out code into the Go module directory
uses: actions/checkout@v3
- id: cache
name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- id: mod-tidy
name: Tidy dependency go modules
run: make tidy
- id: add-gobin-path
name: Add GITHUB_WORKSPACE/bin into PATH
# DEPRECATED: run: echo "::add-path::${GITHUB_WORKSPACE}/bin"
run: echo "${GITHUB_WORKSPACE}/bin" >> $GITHUB_PATH
- id: ci
name: Run tests and linters
run: make ci
- id: codecov
name: Send a coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.txt
flags: unittests
name: codecov
fail_ci_if_error: false
- id: dump-contexts-after
name: Dump contexts After
if: ${{ always() }}
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
JOB_CONTEXT: ${{ toJson(job) }}
STEPS_CONTEXT: ${{ toJson(steps) }}
RUNNER_CONTEXT: ${{ toJson(runner) }}
STRATEGY_CONTEXT: ${{ toJson(strategy) }}
MATRIX_CONTEXT: ${{ toJson(matrix) }}
run: |
echo ">>>>>>>>>> show GITHUB_CONTEXT"
echo "$GITHUB_CONTEXT"
echo ">>>>>>>>>> show JOB_CONTEXT"
echo "$JOB_CONTEXT"
echo ">>>>>>>>>> show STEPS_CONTEXT"
echo "$STEPS_CONTEXT"
echo ">>>>>>>>>> show RUNNER_CONTEXT"
echo "$RUNNER_CONTEXT"
echo ">>>>>>>>>> show STRATEGY_CONTEXT"
echo "$STRATEGY_CONTEXT"
echo ">>>>>>>>>> show MATRIX_CONTEXT"
echo "$MATRIX_CONTEXT"
gitleaks:
name: Run gitleaks
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ 'ubuntu-latest' ]
steps:
- id: checkout
name: Check out code into the Go module directory with checkout@v3
# See: https://github.com/marketplace/actions/gitleaks
uses: actions/checkout@v3
with:
fetch-depth: 0
- id: run-gitleaks
name: Run gitleaks
uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- id: dump-contexts-after
name: Dump contexts After
if: ${{ always() }}
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
JOB_CONTEXT: ${{ toJson(job) }}
STEPS_CONTEXT: ${{ toJson(steps) }}
RUNNER_CONTEXT: ${{ toJson(runner) }}
STRATEGY_CONTEXT: ${{ toJson(strategy) }}
MATRIX_CONTEXT: ${{ toJson(matrix) }}
run: |
echo ">>>>>>>>>> show GITHUB_CONTEXT"
echo "$GITHUB_CONTEXT"
echo ">>>>>>>>>> show JOB_CONTEXT"
echo "$JOB_CONTEXT"
echo ">>>>>>>>>> show STEPS_CONTEXT"
echo "$STEPS_CONTEXT"
echo ">>>>>>>>>> show RUNNER_CONTEXT"
echo "$RUNNER_CONTEXT"
echo ">>>>>>>>>> show STRATEGY_CONTEXT"
echo "$STRATEGY_CONTEXT"
echo ">>>>>>>>>> show MATRIX_CONTEXT"
echo "$MATRIX_CONTEXT"
###
# only on push to master
###
draft-release:
name: Create draft release
# if: github.event_name == 'push' && github.ref == 'refs/heads/master'
if: github.event_name == 'push'
needs: [ test ]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ 'ubuntu-latest' ]
# env:
# BENCHMARK_LATEST: BENCHMARK_LATEST.txt
steps:
- id: checkout
name: Check out code into the Go module directory
uses: actions/checkout@v3
- id: confirm-version
name: Confirm version from version.go
run: |
v=$(make version)
echo "::set-output name=master-version::${v}"
# FIXME: move to benchmark.yml
# - id: download-benchmark
# name: Download a current benchmark result
# continue-on-error: true
# uses: actions/download-artifact@v2
# with:
# name: benchmark-${{ matrix.go }}
# path: ${{ env.BENCHMARK_DIR }}
# - id: create-benchmark-latest-txt-on-bench-latest-branch
# name: Create BENCHMARK_LATEST.txt from current benchmark result with switching branch to bench-latest branch
# continue-on-error: true
# run: |
# ls -lrt ${{ env.BENCHMARK_DIR }}
# git fetch --all
# git branch -a
# git checkout -t origin/bench-latest
# cp -f ${{ env.BENCHMARK_DIR }}/${{ env.BENCHMARK_FILE }} ${{ env.BENCHMARK_LATEST }}
# git status -s
# # See: https://stackoverflow.com/questions/57921401/push-to-origin-from-github-action
# - id: commit-push-benchmark-latest
# name: Commit and push BENCHMARK_LATEST.txt to bench-latest branch (only on push)
# continue-on-error: true
# run: |
# pwd
# ls -l
# git config --global user.name 'goldeneggg'
# git config --global user.email 'jpshadowapps@gmail.com'
# git add ${{ env.BENCHMARK_LATEST }}
# git commit -m "Automated update latest benchmark report"
# git push origin bench-latest
- id: create-draft-release
name: Create draft release (only on push)
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.confirm-version.outputs.master-version }}
release_name: Release v${{ steps.confirm-version.outputs.master-version }} (${{ github.ref }})
body: |
TODO
draft: true
prerelease: false