Repository navigation
75 lines (64 loc) · 1.77 KB
/
Copy pathtest.yml
File metadata and controls
75 lines (64 loc) · 1.77 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
name: Test and Lint
on:
push:
branches:
- master
pull_request:
workflow_dispatch:
concurrency:
group: '${{ github.workflow }}-${{ github.ref }}'
cancel-in-progress: true
permissions:
contents: read
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Run Lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.13.0
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Run Tests
run: go test -v -race -cover -coverprofile=coverage.out -coverpkg=./... ./...
- name: Upload coverage report
uses: actions/upload-artifact@v6
with:
name: coverage-report
path: coverage.out
if-no-files-found: error
# The master ruleset requires a status check named exactly "Test and Lint"
# (the workflow name). Report it from one job that passes only when both
# Lint and Test succeeded, so the required context reflects both jobs.
test-and-lint:
name: Test and Lint
needs: [lint, test]
if: always()
runs-on: ubuntu-latest
steps:
- name: Require Lint and Test to succeed
env:
LINT_RESULT: ${{ needs.lint.result }}
TEST_RESULT: ${{ needs.test.result }}
run: |
echo "Lint: $LINT_RESULT, Test: $TEST_RESULT"
test "$LINT_RESULT" = success
test "$TEST_RESULT" = success