-
Notifications
You must be signed in to change notification settings - Fork 37
79 lines (67 loc) · 2.48 KB
/
__unit_tests.yaml
File metadata and controls
79 lines (67 loc) · 2.48 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
name: unit tests
on:
workflow_call: {}
permissions:
contents: read
env:
MISE_VERBOSE: 1
MISE_DEBUG: 1
jobs:
unit-tests:
timeout-minutes: ${{ fromJSON(vars.GHA_EXTENDED_TIMEOUT_MINUTES || 60) }}
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: go.mod
cache: false
- run: echo "GO_MOD_CACHE=$(go env GOMODCACHE)" >> $GITHUB_ENV
- run: echo "GO_BUILD_CACHE=$(go env GOCACHE)" >> $GITHUB_ENV
- uses: jdx/mise-action@c1ecc8f748cd28cdeabf76dab3cccde4ce692fe4 # v4.0.0
with:
install: false
- run: echo "GO_CACHE_KEY=go-unittests-${{ runner.os }}-${{ runner.arch }}-go-${{ hashFiles('**/go.mod') }}" >> $GITHUB_ENV
- run: echo "GO_CACHE_KEY_2=go-unittests-${{ runner.os }}-${{ runner.arch }}-go-" >> $GITHUB_ENV
- name: Go cache main branch
if: ${{ github.ref == 'refs/heads/main' }}
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7
with:
path: |
${{ env.GO_MOD_CACHE }}
${{ env.GO_BUILD_CACHE }}
key: ${{ env.GO_CACHE_KEY }}
restore-keys: |
${{ env.GO_CACHE_KEY }}
${{ env.GO_CACHE_KEY_2 }}
- name: Go cache (restore only for non-main branches)
if: ${{ github.ref != 'refs/heads/main' }}
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7
with:
path: |
${{ env.GO_MOD_CACHE }}
${{ env.GO_BUILD_CACHE }}
key: ${{ env.GO_CACHE_KEY }}
restore-keys: |
${{ env.GO_CACHE_KEY }}
${{ env.GO_CACHE_KEY_2 }}
- name: run unit tests
run: make test.unit
env:
KONG_PLUGIN_IMAGE_REGISTRY_CREDENTIALS: ${{ secrets.KONG_PLUGIN_IMAGE_REGISTRY_CREDENTIALS }}
GOTESTSUM_JUNITFILE: "unit-tests.xml"
- name: collect test coverage
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: coverage-unit-tests
path: coverage.unit.out
- name: collect test report
if: ${{ always() }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: tests-report-unit-tests
path: unit-tests.xml