Skip to content

Commit 79fcd26

Browse files
authored
ci: improve reliability (#232)
Background: as the default `ubuntu-latest` runner [has upgraded](actions/runner-images@976232d) to `ubuntu-24.04`, we need to ensure compatibility with older OS versions if we release the binary on a new runner as the dotnet building process depends on OS libraries (for example, `GLIBC`). CI: - Unit test pipeline - added unit test on Linux arm64 and windows x64. - E2E pipeline - built `linux-x64` binary on `ubuntu-24.04` and tested on `ubuntu-22.04`, `ubuntu-24.04` and `mcr.microsoft.com/cbl-mariner/base/core:2.0` container. - built `linux-arm64` binary on `ubuntu-24.04-arm` and tested on `ubuntu-24.04-arm`, `ubuntu-22.04-arm`. - built `windows-x64` binary on `windows-2022` and tested on `windows-2022` and `windows-2025` (GA). - release pipeline - updated release pipeline to use `ubuntu 24.04` for Linux and macOS binaries and `windows-2022` for Windows binary. - removed ARM emulator from release pipeline and replaced with `ubuntu-24.04-arm` runner. Test: - fixed unit test on windows to avoid line ending symbol issue - tested new release pipeline in forked repo Note: win-x64 build generates a warning which is discussed here: dotnet/runtime#109958. It should be fixed in the future dotnet release. --------- Signed-off-by: Junjie Gao <[email protected]>
1 parent b57e76f commit 79fcd26

File tree

3 files changed

+91
-40
lines changed

3 files changed

+91
-40
lines changed

.github/workflows/release.yml

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ jobs:
1717
config:
1818
- runtime: osx-x64
1919
build_args: ""
20-
os: ubuntu-latest
20+
os: ubuntu-24.04
2121
- runtime: osx-arm64
2222
build_args: ""
23-
os: ubuntu-latest
23+
os: ubuntu-24.04
2424
- runtime: linux-x64
2525
build_args: --enable-aot
26-
os: ubuntu-latest
26+
os: ubuntu-24.04
2727
- runtime: linux-arm64
2828
build_args: --enable-aot
29-
os: ubuntu-22.04
29+
os: ubuntu-24.04-arm
3030
- runtime: win-x64
3131
build_args: --enable-aot
32-
os: windows-latest
32+
os: windows-2022
3333
name: Build
3434
runs-on: ${{ matrix.config.os }}
3535
steps:
@@ -41,19 +41,6 @@ jobs:
4141
uses: actions/setup-dotnet@v4
4242
with:
4343
dotnet-version: '8.0.x'
44-
- name: Setup ARM64 Emulator
45-
if: matrix.config.runtime == 'linux-arm64'
46-
run: |
47-
sudo dpkg --add-architecture arm64
48-
sudo bash -c 'cat > /etc/apt/sources.list.d/arm64.list <<EOF
49-
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted
50-
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted
51-
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted universe multiverse
52-
EOF'
53-
sudo sed -i -e 's/deb http/deb [arch=amd64] http/g' /etc/apt/sources.list
54-
sudo sed -i -e 's/deb mirror/deb [arch=amd64] mirror/g' /etc/apt/sources.list
55-
sudo apt update
56-
sudo apt install -y clang llvm binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu zlib1g-dev:arm64
5744
- name: Build .NET project
5845
shell: bash
5946
run: python3 ./scripts/build.py "${GITHUB_REF_NAME}" ${{ matrix.config.runtime }} ${{ matrix.config.build_args }}
@@ -91,7 +78,7 @@ jobs:
9178
retention-days: 1
9279
release:
9380
name: Release
94-
runs-on: ubuntu-latest
81+
runs-on: ubuntu-24.04
9582
needs: macos_codesign
9683
steps:
9784
- name: Checkout

.github/workflows/test.yml

Lines changed: 80 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ jobs:
4141
VALIDATE_MARKDOWN: false
4242
VALIDATE_JSCPD: false
4343
VALIDATE_SHELL_SHFMT: false
44-
test:
45-
name: Unit Testing and Build
46-
runs-on: ubuntu-latest
44+
test-linux:
45+
name: Unit Testing and Build on Linux x64
46+
runs-on: ubuntu-24.04
4747
timeout-minutes: 5
4848
permissions:
4949
contents: read
@@ -82,11 +82,63 @@ jobs:
8282
name: darwin-amd64-binary
8383
path: ./bin/artifacts/notation-azure-kv_0.0.1_darwin_amd64.tar.gz
8484
retention-days: 1
85+
test-linux-arm:
86+
name: Unit Testing and Build on Linux arm64
87+
runs-on: ubuntu-24.04-arm
88+
timeout-minutes: 5
89+
permissions:
90+
contents: read
91+
steps:
92+
- name: Setup .NET
93+
uses: actions/setup-dotnet@v4
94+
with:
95+
dotnet-version: '8.0.x'
96+
- name: Check out code into the project directory
97+
uses: actions/checkout@v4
98+
with:
99+
fetch-depth: 0
100+
- name: Run unit tests
101+
run: make test
102+
- name: Build Linux Binary
103+
run: |
104+
# the binary will be used in E2E test
105+
python3 ./scripts/build.py v0.0.1 linux-arm64 --enable-aot
106+
- name: Upload Linux artifact
107+
uses: actions/upload-artifact@v4
108+
with:
109+
name: linux-arm64-binary
110+
path: ./bin/artifacts/notation-azure-kv_0.0.1_linux_arm64.tar.gz
111+
retention-days: 1
112+
test-windows:
113+
name: Unit Testing and Build on windows x64
114+
runs-on: windows-2022
115+
timeout-minutes: 5
116+
permissions:
117+
contents: read
118+
steps:
119+
- name: Setup .NET
120+
uses: actions/setup-dotnet@v4
121+
with:
122+
dotnet-version: '8.0.x'
123+
- name: Check out code into the project directory
124+
uses: actions/checkout@v4
125+
with:
126+
fetch-depth: 0
127+
- name: Run unit tests
128+
run: make test
129+
- name: Build Windows Binary
130+
run: python3 ./scripts/build.py v0.0.1 win-x64 --enable-aot
131+
- name: Upload Linux artifact
132+
uses: actions/upload-artifact@v4
133+
with:
134+
name: windows-amd64-binary
135+
path: ./bin/artifacts/notation-azure-kv_0.0.1_windows_amd64.zip
136+
retention-days: 1
85137
e2e-mariner-container:
86138
name: E2E testing for Mariner container
87139
runs-on: ubuntu-latest
88140
environment: E2E
89-
needs: test
141+
needs: test-linux
90142
steps:
91143
- name: Check out code into the project directory
92144
uses: actions/checkout@v4
@@ -128,24 +180,35 @@ jobs:
128180
AZURE_FEDERATED_TOKEN_FILE: ./federated_token
129181
e2e-linux:
130182
name: E2E testing on Linux
131-
runs-on: ubuntu-latest
183+
runs-on: ${{ matrix.config.os }}
184+
strategy:
185+
matrix:
186+
config:
187+
- os: ubuntu-24.04
188+
arch: amd64
189+
- os: ubuntu-22.04
190+
arch: amd64
191+
- os: ubuntu-24.04-arm
192+
arch: arm64
193+
- os: ubuntu-22.04-arm
194+
arch: arm64
132195
environment: E2E
133-
needs: test
196+
needs: [test-linux, test-linux-arm]
134197
steps:
135198
- name: Check out code into the project directory
136199
uses: actions/checkout@v4
137200
with:
138201
fetch-depth: 0
139202
- uses: actions/download-artifact@v4
140203
with:
141-
name: linux-amd64-binary
204+
name: linux-${{ matrix.config.arch }}-binary
142205
path: ./bin/artifacts
143206
- name: Run download server locally
144207
run: |
145208
nohup python3 -m http.server --directory ./bin/artifacts/ &
146209
147210
# prepare the environment variables for E2E
148-
artifactName=notation-azure-kv_0.0.1_linux_amd64.tar.gz
211+
artifactName=notation-azure-kv_0.0.1_linux_${{ matrix.config.arch }}.tar.gz
149212
checksum=$(shasum -a 256 "./bin/artifacts/$artifactName" | awk '{print $1}')
150213
echo "pluginChecksum=$checksum" >> "$GITHUB_ENV"
151214
echo "pluginDownloadURL=http://localhost:8000/$artifactName" >> "$GITHUB_ENV"
@@ -168,20 +231,21 @@ jobs:
168231
pluginChecksum: ${{ env.pluginChecksum }}
169232
e2e-windows:
170233
name: E2E testing on Windows
171-
runs-on: windows-latest
234+
runs-on: ${{ matrix.os }}
235+
strategy:
236+
matrix:
237+
os: [windows-2022, windows-2025]
172238
environment: E2E
173-
needs: test
239+
needs: test-windows
174240
steps:
175241
- name: Check out code into the project directory
176242
uses: actions/checkout@v4
177243
with:
178244
fetch-depth: 0
179-
- name: Setup .NET
180-
uses: actions/setup-dotnet@v4
245+
- uses: actions/download-artifact@v4
181246
with:
182-
dotnet-version: '8.0.x'
183-
- name: Build Windows Binary
184-
run: python3 ./scripts/build.py v0.0.1 win-x64 --enable-aot
247+
name: windows-amd64-binary
248+
path: ./bin/artifacts
185249
- name: Run download server locally
186250
run: |
187251
# wsl bash
@@ -215,7 +279,7 @@ jobs:
215279
name: E2E testing on macOS
216280
runs-on: macos-13
217281
environment: E2E
218-
needs: test
282+
needs: test-linux
219283
steps:
220284
- name: Check out code into the project directory
221285
uses: actions/checkout@v4

Notation.Plugin.AzureKeyVault.Tests/ProgramTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ internal interface IResponseMock
9797

9898
[Theory]
9999
[InlineData(200, "{\"error\":{\"message\":\"TestErrorMessage\"}}", "TestErrorMessage")]
100-
[InlineData(500, "{\"error\":{\"message\":\"TestErrorMessage\"}", "Service request failed.\nStatus: 500\n")]
101-
[InlineData(500, "{\"error2\":{\"message\":\"TestErrorMessage\"}}", "Service request failed.\nStatus: 500\n")]
102-
[InlineData(500, "{\"error\":{\"message2\":\"TestErrorMessage\"}}", "Service request failed.\nStatus: 500\n")]
103-
[InlineData(500, "{\"error\":{\"message\":\"\"}}", "\nStatus: 500\n")]
100+
[InlineData(500, "{\"error\":{\"message\":\"TestErrorMessage\"}", "Status: 500")]
101+
[InlineData(500, "{\"error2\":{\"message\":\"TestErrorMessage\"}}", "Status: 500")]
102+
[InlineData(500, "{\"error\":{\"message2\":\"TestErrorMessage\"}}", "Status: 500")]
103+
[InlineData(500, "{\"error\":{\"message\":\"\"}}", "Status: 500")]
104104
public void HandleAzureException(int code, string content, string expectedErrorMessage)
105105
{
106106
// Arrange
@@ -124,7 +124,7 @@ public void HandleAzureException(int code, string content, string expectedErrorM
124124
var errorResponse = Program.HandleAzureException(exception);
125125

126126
// Assert exit code 1
127-
Assert.StartsWith(expectedErrorMessage, errorResponse.ErrorMessage);
127+
Assert.Contains(expectedErrorMessage, errorResponse.ErrorMessage);
128128
Assert.Equal("ERROR", errorResponse.ErrorCode);
129129
}
130130
}

0 commit comments

Comments
 (0)