-
-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (117 loc) · 4.29 KB
/
Copy pathgo.yml
File metadata and controls
135 lines (117 loc) · 4.29 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
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
# ! ┌───────────────────────────────────────────────────────────────────┐
# ! │ │
# ! │ IMPORTANT NOTE │
# ! │ │
# ! │ This file is synced with https://github.com/atomicgo/template │
# ! │ │
# ! │ Please apply all changes to the template repository │
# ! │ │
# ! └───────────────────────────────────────────────────────────────────┘
name: Go
on:
pull_request:
push:
branches:
- main
concurrency:
group: go-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
id-token: write
env:
CGO_ENABLED: "1"
jobs:
test:
name: Test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
if: "${{ github.event_name != 'push' || !contains(github.event.head_commit.message, 'docs: autoupdate') }}"
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Download dependencies
shell: bash
run: |
go mod download
go mod verify
- name: Build
run: go build -v ./...
- name: Test
run: go test -race -coverprofile="coverage.txt" -covermode=atomic -v -p 1 ./...
- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v6
with:
files: ./coverage.txt
fail_ci_if_error: true
use_oidc: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
- name: Test summary
if: always()
shell: bash
run: |
{
echo "### Go test: ${{ matrix.os }}"
echo ""
echo "| Check | Result |"
echo "| --- | --- |"
echo "| Build and tests | ${{ job.status }} |"
echo "| Coverage upload | ${{ matrix.os == 'ubuntu-latest' && 'enabled' || 'skipped' }} |"
} >> "$GITHUB_STEP_SUMMARY"
lint:
name: Lint
runs-on: ubuntu-latest
if: "${{ github.event_name != 'push' || !contains(github.event.head_commit.message, 'docs: autoupdate') }}"
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.11.4
args: --timeout=3m
- name: Lint summary
if: always()
shell: bash
run: |
{
echo "### Lint"
echo ""
echo "| Tool | Result |"
echo "| --- | --- |"
echo "| golangci-lint | ${{ job.status }} |"
} >> "$GITHUB_STEP_SUMMARY"
summary:
name: CI summary
runs-on: ubuntu-latest
needs: [test, lint]
if: "${{ always() && (github.event_name != 'push' || !contains(github.event.head_commit.message, 'docs: autoupdate')) }}"
steps:
- name: Write workflow summary
shell: bash
run: |
{
echo "## AtomicGo CI"
echo ""
echo "| Job | Result |"
echo "| --- | --- |"
echo "| Tests | ${{ needs.test.result }} |"
echo "| Lint | ${{ needs.lint.result }} |"
} >> "$GITHUB_STEP_SUMMARY"
if [[ "${{ needs.test.result }}" != "success" || "${{ needs.lint.result }}" != "success" ]]; then
echo "::error::One or more CI checks failed."
exit 1
fi