-
Notifications
You must be signed in to change notification settings - Fork 33
153 lines (136 loc) · 4.43 KB
/
tests.yaml
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
name: Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: "0 1 * * *"
# Restrict tests to the most recent commit.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build Docker Images
runs-on: ubuntu-22.04
outputs:
testcases: ${{ steps.enum-tests.outputs.testcases }}
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Build images
shell: bash
run: make generate build
- name: Save images
shell: bash
run: |
mkdir -p docker-cache
docker save -o docker-cache/autograph-images.tar autograph-app autograph-app-hsm
- name: Enumerate tests
id: enum-tests
shell: bash
run: |
echo -n "testcases=" >> $GITHUB_OUTPUT
yq -o=json '.services | keys' tools/autograph-client/integration-tests.yml | jq -c >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v4
with:
name: autograph-images-${{ github.sha }}
path: docker-cache/
lint:
name: Linting
runs-on: ubuntu-22.04
permissions:
# Required: allow read access to the content for analysis.
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
pull-requests: read
# Optional: allow write access to checks to allow the action to annotate code in the PR.
checks: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "./go.mod"
- name: golangci-lint
# If you bump this version, double check that we shouldn't also bump
# GOLANGCI_LINT_VERSION in the Makefile. (The version here is for the
# GitHub Action and the one in the Makefile is for the actual version of
# golangci-lint.)
uses: golangci/[email protected]
with:
args: --timeout 5m
unit-tests:
name: Run Unit Tests
runs-on: ubuntu-22.04
needs:
- build
steps:
- name: Clone repository
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: autograph-images-${{ github.sha }}
path: docker-cache/
- name: Load images
shell: bash
run: docker load -i docker-cache/autograph-images.tar
- name: Run Tests
shell: bash
run: |
docker compose run unit-test
integration-tests:
name: Run Integration Tests
runs-on: ubuntu-22.04
needs:
- build
strategy:
fail-fast: false # Don't cancel other jobs if a test fails
matrix:
testcase: ${{ fromJSON(needs.build.outputs.testcases) }}
steps:
- name: Clone repository
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: autograph-images-${{ github.sha }}
path: docker-cache/
- name: Load images
shell: bash
run: docker load -i docker-cache/autograph-images.tar
- name: Running ${{ matrix.testcase }}
shell: bash
run: docker compose -f tools/autograph-client/integration-tests.yml run ${{ matrix.testcase }}
- name: Fetching autograph logs
shell: bash
if: ${{ always() }}
run: |
if echo "${{ matrix.testcase }}" | grep -q hsm; then
docker compose -f tools/autograph-client/integration-tests.yml logs app-hsm
else
docker compose -f tools/autograph-client/integration-tests.yml logs app
fi
# A hack around matrix jobs not reporting their status up through the job that
# created them. See
# https://github.com/orgs/community/discussions/26822#discussioncomment-8285141
# and
# https://github.com/orgs/community/discussions/26822#discussioncomment-3305794
integration-tests-results:
if: ${{ always() }}
name: Check Integration Test Results (See the individual Run Integration Tests jobs for details)
runs-on: ubuntu-22.04
needs:
- integration-tests
steps:
- name: See the individual Run Integration Tests jobs for details
run:
exit 1
# see https://stackoverflow.com/a/67532120/4907315
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
|| contains(needs.*.result, 'skipped')
}}