-
-
Notifications
You must be signed in to change notification settings - Fork 343
183 lines (145 loc) · 5.16 KB
/
cicd.yml
File metadata and controls
183 lines (145 loc) · 5.16 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
name: Continuous Integration & Delivery
on:
push:
branches: [ develop, main, bugfix/*, feature/* ]
pull_request:
branches: [ develop, main ]
workflow_dispatch:
inputs:
publish_nuget_package:
description: Publish a new NuGet package?
required: false
type: boolean
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.sha }}
cancel-in-progress: true
env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_USE_POLLING_FILE_WATCHER: true
NUGET_XMLDOC_MODE: skip
# https://stackoverflow.com/q/53510011.
TZ: CET
jobs:
collect-test-projects:
runs-on: ubuntu-24.04
outputs:
test-projects: ${{ steps.set-test-projects.outputs.test-projects }}
steps:
- name: Checkout Repository
uses: actions/checkout@v5
with:
lfs: true
- id: get-all-changed-files
name: Collect Changed Files
uses: tj-actions/changed-files@v47
- id: set-test-projects
name: Collect Test Projects
shell: pwsh
run: echo "test-projects=$(.github/scripts/Collect-TestProjects.ps1)" >> $env:GITHUB_OUTPUT
env:
ALL_CHANGED_FILES: ${{ steps.get-all-changed-files.outputs.all_changed_files }}
ci:
if: ${{ needs.collect-test-projects.outputs.test-projects != '[]' }}
needs: collect-test-projects
strategy:
max-parallel: 6
matrix:
test-projects: ${{ fromJSON(needs.collect-test-projects.outputs.test-projects) }}
runs-on: ${{ matrix.test-projects.runs-on }}
env:
# Lowest API version that GitHub runners support.
DOCKER_API_VERSION: 1.47
steps:
- name: Checkout Repository
uses: actions/checkout@v5
with:
lfs: true
- name: Cache NuGet Packages
uses: actions/cache@v4
with:
key: ${{ matrix.test-projects.runs-on }}-nuget-${{ hashFiles('Directory.Packages.props') }}
path: ~/.nuget/packages
- name: Setup .NET
uses: actions/setup-dotnet@v5
- name: Restore NuGet Packages
run: ./build.sh --target=Restore-NuGet-Packages
shell: bash
- name: Run Build
run: ./build.sh --target=Build --test-project=${{ matrix.test-projects.name }}
shell: bash
- name: Run Tests
run: ./build.sh --target=Test --test-project=${{ matrix.test-projects.name }}
shell: bash
- name: Upload Test And Coverage Results
uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ matrix.test-projects.name }}
path: test-results
cd:
if: ${{ github.repository == 'testcontainers/testcontainers-dotnet' && contains(fromJson('["develop", "main"]'), github.ref_name) }}
needs: ci
environment: production
permissions:
contents: write
pull-requests: read
runs-on: ubuntu-24.04
env:
CODE_SIGNING_CERTIFICATE_BASE64: ${{ secrets.CODE_SIGNING_CERTIFICATE_BASE64 }}
CODE_SIGNING_CERTIFICATE_PASSWORD: ${{ secrets.CODE_SIGNING_CERTIFICATE_PASSWORD }}
FEED_SOURCE: https://api.nuget.org/v3/index.json
FEED_API_KEY: ${{ secrets.FEED_API_KEY }}
SONARCLOUD_URL: https://sonarcloud.io
SONARCLOUD_ORGANIZATION: testcontainers
SONARCLOUD_KEY: testcontainers_testcontainers-dotnet
SONARCLOUD_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
PUBLISH_NUGET_PACKAGE: ${{ inputs.publish_nuget_package }}
steps:
- name: Checkout Repository
uses: actions/checkout@v5
with:
lfs: true
fetch-depth: 0
- name: Download Test And Coverage Results
uses: actions/download-artifact@v5
with:
pattern: Testcontainers*
path: test-results
- name: Fix Absolute Code Coverage Paths
run: Get-ChildItem -Path 'test-results' -Filter '*.xml' -Recurse | Select-Object -ExpandProperty FullName | % { (Get-Content -LiteralPath $_) -Replace 'fullPath="[A-Za-z0-9:\-\/\\]+(src|tests)', 'fullPath="${{ github.workspace }}/$1' | Set-Content -LiteralPath $_ }
shell: pwsh
- name: Cache NuGet Packages
uses: actions/cache@v4
with:
key: ubuntu-24.04-nuget-${{ hashFiles('Directory.Packages.props') }}
path: ~/.nuget/packages
- name: Setup Java
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 21
- name: Setup .NET
uses: actions/setup-dotnet@v5
- name: Restore NuGet Packages
run: ./build.sh --target=Restore-NuGet-Packages
shell: bash
- name: Run Sonar Analysis
run: ./build.sh --target=Sonar-Begin
shell: bash
- name: Run Build
run: ./build.sh --target=Build
shell: bash
- name: Upload Sonar Results
run: ./build.sh --target=Sonar-End
shell: bash
- name: Publish NuGet Package
run: ./build.sh --target=Publish
shell: bash
# Cake sets the semVer environment variable.
- uses: release-drafter/release-drafter@v6
with:
version: ${{ env.semVer }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}