-
Notifications
You must be signed in to change notification settings - Fork 85
134 lines (129 loc) · 4.24 KB
/
main.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
---
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- "**"
jobs:
config:
runs-on: ubuntu-latest
outputs:
go_versions: ${{ steps.config.outputs.go_versions }}
steps:
- id: config
run: |
echo 'go_versions=["1.21","1.20","1.19"]' >> $GITHUB_OUTPUT
gating-lints:
needs: ['config']
name: Gating Lints
runs-on: ubuntu-latest
steps:
- name: Commit Check
uses: gsactions/commit-message-checker@v2
with:
pattern: |
^(.*):\s*(.*)\n.*$
error: 'Commit must begin with <scope>: <subject>'
flags: 'gm'
excludeTitle: true
excludeDescription: true
checkAllCommitMessages: true
accessToken: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v3
- name: Check Filenames
if: success() || failure()
run: | # Check for all the characters Windows hates.
git ls-files -- ':/:*[<>:"|?*]*' | while read -r file; do
printf '::error file=%s,title=Bad Filename::Disallowed character in file name\n' "$file"
done
exit $(git ls-files -- ':/:*[<>:"|?*]*' | wc -l)
- name: Setup Go
if: success() || failure()
uses: actions/setup-go@v4
with:
go-version: ${{ fromJSON(needs.config.outputs.go_versions)[0] }}
- name: Go Tidy
if: success() || failure()
run: |
trap 'echo "::error file=go.mod,title=Tidy Check::Commit would leave go.mod untidy"' ERR
go mod tidy
git diff --exit-code
build-documentation:
name: Build Docs
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup mdBook
uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: '0.3.5'
- name: mdBook Build
run: mdbook build
tests:
needs: ['config']
name: Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go: ${{ fromJSON(needs.config.outputs.go_versions) }}
steps:
- name: Check for Previous Run
id: previous
uses: actions/cache@v3
with:
path: ~/ok-by-run
key: commit-ok-${{ matrix.go }}-${{ github.sha }}
- name: Checkout
if: steps.previous.outputs.cache-hit != 'true'
uses: actions/checkout@v3
- uses: actions/setup-go@v4
if: steps.previous.outputs.cache-hit != 'true'
with:
go-version: ${{ matrix.go }}
- name: Cache Integration Assets
if: steps.previous.outputs.cache-hit != 'true'
uses: actions/cache@v3
with:
key: integration-assets-${{ hashFiles('**/*_test.go') }}
restore-keys: |
integration-assets-
path: |
~/.cache/clair-testing
- name: Tests
run: |
if test -f ~/ok-by-run; then
echo "::notice title=Commit Previously Passed::See $(cat ~/ok-by-run) (cache key 'commit-ok-${{ matrix.go }}-${{ github.sha }}')"
exit 0
fi
printf '%s/%s/actions/runs/%s/attempts/%s\n'\
"${GITHUB_SERVER_URL}" "${GITHUB_REPOSITORY}" "${GITHUB_RUN_ID}" "${GITHUB_RUN_ATTEMPT}"\
> ~/ok-by-run
find . -name .git -prune -o -name testdata -prune -o -name go.mod -printf '%h\n' |
while read -r dir; do (
cd "$dir"
go list -m
go mod download
go test -race ${RUNNER_DEBUG:+-v} "-coverprofile=${{ runner.temp }}/$(go list -m | tr / _).codecov.out" -covermode=atomic ./...
); done
- name: Codecov
if: >-
steps.previous.outputs.cache-hit != 'true' &&
success() &&
fromJSON(needs.config.outputs.go_versions)[0] == matrix.go
uses: codecov/codecov-action@v3
with:
directory: ${{ runner.temp }}
override_branch: ${{ github.ref_name }}
- name: Database Logs
if: failure() || env.RUNNER_DEBUG == 1
run: |
sudo -u postgres psql -c 'SELECT version();'
sudo journalctl --unit postgresql.service --boot -0
ls /var/log/postgresql/postgresql-*.log
sudo cat /var/log/postgresql/postgresql-*.log