-
-
Notifications
You must be signed in to change notification settings - Fork 511
140 lines (126 loc) · 4.79 KB
/
ci.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
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
136
137
138
139
140
name: Main pipeline
on:
push:
branches:
- main
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.sha }}
cancel-in-progress: true
jobs:
detect-modules:
runs-on: ubuntu-latest
outputs:
modules: ${{ steps.set-modified-modules.outputs.modules }}
modules_count: ${{ steps.set-modified-modules-count.outputs.modules_count }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- id: changed-files
name: Get changed files
uses: tj-actions/changed-files@4edd678ac3f81e2dc578756871e4d00c19191daf # v45.0.4
- id: set-modified-modules
name: Set all modified modules
env:
ALL_CHANGED_FILES: "${{ steps.changed-files.outputs.all_changed_files }}"
run: echo "modules=$(./scripts/changed-modules.sh)" >> $GITHUB_OUTPUT
- id: set-modified-modules-count
name: Set all modified modules count
run: echo "modules_count=$(echo ${{ toJSON(steps.set-modified-modules.outputs.modules) }} | jq '. | length')" >> $GITHUB_OUTPUT
- name: Print out the modules to be used
run: |
echo "${{ steps.set-modified-modules-count.outputs.modules_count }} modules in the build"
echo "${{ steps.set-modified-modules.outputs.modules }}"
lint:
# only run if there are modules to lint
if: ${{ needs.detect-modules.outputs.modules_count > 0 }}
needs:
- detect-modules
strategy:
matrix:
module: ${{ fromJSON(needs.detect-modules.outputs.modules) }}
uses: ./.github/workflows/ci-lint-go.yml
with:
project-directory: "${{ matrix.module }}"
test:
# only run if there are modules to test
if: ${{ needs.detect-modules.outputs.modules_count > 0 }}
needs:
- detect-modules
- lint
strategy:
matrix:
go-version: [1.22.x, 1.x]
module: ${{ fromJSON(needs.detect-modules.outputs.modules) }}
uses: ./.github/workflows/ci-test-go.yml
with:
go-version: ${{ matrix.go-version }}
fail-fast: true
platforms: ${{ matrix.module == 'modulegen' && '["ubuntu-latest", "macos-latest", "windows-latest"]' || '["ubuntu-latest"]' }}
project-directory: "${{ matrix.module }}"
rootless-docker: false
ryuk-disabled: false
# The job below is a copy of the job above, but with ryuk disabled.
# It's executed in the first stage to avoid concurrency issues.
test-reaper-off:
# the core module is identified by the empty string (the root path)
if: ${{ contains(fromJSON(needs.detect-modules.outputs.modules), '') }}
needs:
- detect-modules
- lint
name: "Test with reaper off"
strategy:
matrix:
go-version: [1.22.x, 1.x]
uses: ./.github/workflows/ci-test-go.yml
with:
go-version: ${{ matrix.go-version }}
fail-fast: false
platforms: '["ubuntu-latest"]'
project-directory: "."
rootless-docker: false
ryuk-disabled: true
# The job below is a copy of the job above, but with Docker rootless.
# It's executed in the first stage to avoid concurrency issues.
test-rootless-docker:
# the core module is identified by the empty string (the root path)
if: ${{ contains(fromJSON(needs.detect-modules.outputs.modules), '') }}
needs:
- detect-modules
- lint
name: "Test with Rootless Docker"
strategy:
matrix:
go-version: [1.22.x, 1.x]
uses: ./.github/workflows/ci-test-go.yml
with:
go-version: ${{ matrix.go-version }}
fail-fast: false
platforms: '["ubuntu-latest"]'
project-directory: "."
rootless-docker: true
ryuk-disabled: false
sonarcloud:
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: read # for sonarsource/sonarcloud-github-action to determine which PR to decorate
if: ${{ github.ref_name == 'main' && github.repository_owner == 'testcontainers' && needs.detect-modules.outputs.modules_count > 0 }}
needs:
- detect-modules
- test
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
pattern: sonarcloud-*
merge-multiple: true
- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@49e6cd3b187936a73b8280d59ffd9da69df63ec9 # v2.1.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}