-
Notifications
You must be signed in to change notification settings - Fork 21
113 lines (103 loc) · 3.64 KB
/
ci.yml
File metadata and controls
113 lines (103 loc) · 3.64 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
name: Main pipeline
on:
push:
branches:
- main
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.sha }}
cancel-in-progress: true
jobs:
detect-packages:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
packages: ${{ steps.filter.outputs.changes || '[]' }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Generate filters
id: filter-setup
run: |
filters=$(go work edit -json | jq -r '.Use[] | "\(.DiskPath | ltrimstr("./")): \"\(.DiskPath | ltrimstr("./"))/**\""')
echo "filters<<EOF" >> $GITHUB_OUTPUT
echo "$filters" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
shell: bash
- name: Filter changes
id: filter
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 #v3
with:
filters: ${{ steps.filter-setup.outputs.filters }}
lint:
needs:
- detect-packages
if: needs.detect-packages.outputs.packages != '[]' # Ensure job runs only if there are changes
strategy:
# We don't want to fail the build the soonest but identify which modules passed and failed.
fail-fast: false
matrix:
package: ${{ fromJSON(needs.detect-packages.outputs.packages || '[]') }}
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: write # for golangci-lint action to determine which PR to decorate
uses: ./.github/workflows/ci-lint-go.yml
with:
project-directory: "${{ matrix.package }}"
test:
needs:
- detect-packages
- lint
if: needs.detect-packages.outputs.packages != '[]' # Ensure job runs only if there are changes
strategy:
# We don't want to fail the build the soonest but identify which modules passed and failed.
fail-fast: false
matrix:
go-version: [1.24.x, 1.25.x]
package: ${{ fromJSON(needs.detect-packages.outputs.packages || '[]') }}
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: read # for sonarsource/sonarcloud-github-action to determine which PR to decorate
uses: ./.github/workflows/ci-test-go.yml
with:
go-version: ${{ matrix.go-version }}
project-directory: "${{ matrix.package }}"
secrets: inherit
benchmarks:
needs:
- detect-packages
- lint
- test
if: needs.detect-packages.outputs.packages != '[]' # Ensure job runs only if there are changes
strategy:
# We don't want to fail the build the soonest but identify which modules passed and failed.
fail-fast: false
matrix:
package: ${{ fromJSON(needs.detect-packages.outputs.packages || '[]') }}
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: write # for sonarsource/sonarcloud-github-action to determine which PR to decorate
uses: ./.github/workflows/ci-benchmarks.yml
with:
project-directory: "${{ matrix.package }}"
secrets: inherit
# This job serves as confirmation that all test jobs finished
end:
if: needs.detect-packages.outputs.packages != '[]' # Ensure job runs only if there are changes
needs:
- detect-packages
- test
- benchmarks
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
steps:
- name: Check if any jobs failed
if: ${{ failure() || cancelled() }}
run: exit 1
- run: echo "All tests completed successfully!"