-
Notifications
You must be signed in to change notification settings - Fork 644
57 lines (56 loc) · 1.69 KB
/
tests-template.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
---
name: Reusable unit test Workflow
on:
workflow_call:
inputs:
runs-on:
required: false
type: string
default: ubuntu-latest
targets:
required: false
type: string
default: "['linux-unit-test-1-cpu','linux-unit-test-2-cpu','linux-unit-test-4-cpu']"
permissions: read-all
jobs:
test-linux:
# this is to prevent arm64 jobs from running at forked projects
if: ${{ github.repository == 'etcd-io/bbolt' || inputs.runs-on == 'ubuntu-latest' }}
strategy:
fail-fast: false
matrix:
target: ${{ fromJSON(inputs.targets) }}
runs-on: ${{ inputs.runs-on }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- id: goversion
run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT"
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: ${{ steps.goversion.outputs.goversion }}
- run: make fmt
- env:
TARGET: ${{ matrix.target }}
run: |
case "${TARGET}" in
linux-unit-test-1-cpu)
CPU=1 make test
;;
linux-unit-test-2-cpu)
CPU=2 make test
;;
linux-unit-test-4-cpu)
CPU=4 make test
;;
linux-unit-test-4-cpu-race)
CPU=4 ENABLE_RACE=true make test
;;
*)
echo "Failed to find target"
exit 1
;;
esac
- name: golangci-lint
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
with:
version: v1.61.0