-
Notifications
You must be signed in to change notification settings - Fork 9
229 lines (197 loc) Β· 7.76 KB
/
ci-cd.yml
File metadata and controls
229 lines (197 loc) Β· 7.76 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
name: "CI/CD Pipeline"
on:
push:
paths-ignore:
- "**.md"
- LICENSE
branches:
- "master"
pull_request:
paths-ignore:
- "**.md"
- LICENSE
branches:
- master
- "feature/*"
env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_NOLOGO: true
jobs:
build-and-test:
name: "Build & Test (${{ matrix.name }})"
runs-on: ${{ matrix.os }}
env:
NUGET_PACKAGES: ${{ contains(matrix.os, 'windows') && format('{0}\.nuget\packages', github.workspace) || format('{0}/.nuget/packages', github.workspace) }}
BADGE_GIST_ID: "472c59b7c2a1898c48a29f3c88897c5a"
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
name: "Windows"
script: "./build.ps1"
filename: "test-results-windows.json"
- os: ubuntu-22.04
name: "Linux"
script: "./build.sh"
filename: "test-results-linux.json"
- os: macos-latest
name: "macOS"
script: "./build.sh"
filename: "test-results-macos.json"
steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for better caching
- name: "Setup .NET SDK"
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
- name: "Make build script executable"
if: runner.os != 'Windows'
run: chmod +x ./build.sh
- name: "Cache NuGet packages"
uses: actions/cache@v4
with:
path: ${{ runner.os == 'Windows' && format('{0}\.nuget\packages', github.workspace) || format('{0}/.nuget/packages', github.workspace) }}
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json', '**/*.csproj', '**/Directory.Packages.props') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: "Build"
run: ${{ matrix.script }} --target build
- name: "Run Tests"
run: ${{ matrix.script }} --target tests --skipFunctionalTest ${{ runner.os == 'Linux' && 'false' || 'true' }} --exclusive
- name: "Publish Test Results"
id: test-results
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: "Test Results (${{ matrix.name }})"
path: "**/TestResults/*.trx"
reporter: "dotnet-trx"
fail-on-error: true
max-annotations: 50
- name: "Update Test Results Badge"
if: always() # Run even if tests failed or were skipped
continue-on-error: true # Don't fail workflow if badge update fails
uses: ./.github/actions/update-test-badge
with:
platform: ${{ matrix.name }}
gist_id: ${{ env.BADGE_GIST_ID }}
filename: ${{ matrix.filename }}
gist_token: ${{ secrets.GIST_SECRET }}
test_passed: ${{ steps.test-results.outputs.passed || 0 }}
test_failed: ${{ steps.test-results.outputs.failed || 0 }}
test_skipped: ${{ steps.test-results.outputs.skipped || 0 }}
test_url_html: ${{ steps.test-results.outputs.url_html || '' }}
commit_sha: ${{ github.sha }}
run_id: ${{ github.run_id }}
repository: ${{ github.repository }}
server_url: ${{ github.server_url }}
- name: "Upload Test Artifacts"
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-results-${{ matrix.name }}
path: |
**/*.trx
**/TestResults/**/*
retention-days: 7
continuous-deployment:
name: "Continuous Deployment"
runs-on: ubuntu-22.04
needs: build-and-test
if: |
github.repository == 'localstack-dotnet/localstack-dotnet-client' &&
((github.event_name == 'push' && github.ref == 'refs/heads/master') ||
(github.event_name == 'pull_request' && startsWith(github.head_ref, 'feature/')))
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
permissions:
contents: read
packages: write
steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Setup .NET SDK"
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
- name: "Cache NuGet packages"
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json', '**/*.csproj', '**/Directory.Packages.props') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: "Make build script executable"
run: chmod +x ./build.sh
- name: "Setup GitHub Packages Configuration"
run: |
echo "π Adding GitHub Packages authentication..."
dotnet nuget add source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json \
--name github-packages \
--username ${{ github.actor }} \
--password ${{ secrets.GITHUB_TOKEN }} \
--store-password-in-clear-text
echo "π§ Original nuget.config..."
cat nuget.config
echo "π Backing up original nuget.config..."
cp nuget.config nuget.config.backup
echo "π§ Using GitHub-optimized nuget.config..."
cp .github/nuget.config nuget.config
echo "π§ Replaced nuget.config..."
cat nuget.config
- name: "Pack & Publish LocalStack.Client"
id: pack-client
run: |
echo "π¨ Building and publishing LocalStack.Client package..."
./build.sh --target nuget-pack-and-publish \
--package-source github \
--package-id LocalStack.Client \
--use-directory-props-version true \
--branch-name ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }} \
--package-secret ${{ secrets.GITHUB_TOKEN }}
- name: "Prepare Extensions Project"
run: |
echo "π§ Preparing Extensions project to use LocalStack.Client package..."
./build.sh --target nuget-prepare-extensions \
--package-source github \
--package-id LocalStack.Client.Extensions \
--client-version ${{ steps.pack-client.outputs.client-version }}
- name: "Pack & Publish LocalStack.Client.Extensions"
run: |
echo "π¨ Building and publishing LocalStack.Client.Extensions package..."
./build.sh --target nuget-pack-and-publish \
--package-source github \
--package-id LocalStack.Client.Extensions \
--use-directory-props-version true \
--branch-name ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }} \
--package-secret ${{ secrets.GITHUB_TOKEN }}
- name: "Upload Package Artifacts"
uses: actions/upload-artifact@v4
with:
name: "packages-${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }}-${{ github.run_number }}"
path: |
artifacts/*.nupkg
artifacts/*.snupkg
retention-days: 7
- name: "Generate Build Summary"
run: |
echo "π¦ Generating build summary..."
./build.sh --target workflow-summary \
--use-directory-props-version true \
--branch-name ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }}
- name: "Cleanup Configuration"
if: always()
run: |
echo "π§Ή Restoring original nuget.config..."
mv nuget.config.backup nuget.config || echo "β οΈ Original config not found, skipping restore"