Skip to content

Commit 7bb2382

Browse files
authored
ci: Use a shared definition of integration tests in pull request and main jobs (#71)
Motivation ---------- The definition of the integration test job was duplicated in `main.yml` and `pull_request.yml`. When changes were made in one but not the other, the pull request CI job passed but the main CI job later failed after the pull request had been merged. Modifications ------------- * The integration test job has been moved to a shared file which `main.yml` and `pull_request.yml` can both include. Result ------ If the pull request job succeeds, the main job should also succeed. Test Plan --------- Tests on main branch pass again.
1 parent 4590771 commit 7bb2382

File tree

3 files changed

+39
-53
lines changed

3 files changed

+39
-53
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Integration tests
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
integration-tests:
8+
name: Integration tests
9+
runs-on: ubuntu-latest
10+
services:
11+
registry:
12+
image: registry:2
13+
ports:
14+
- 5000:5000
15+
container:
16+
image: swift:6.0-noble
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
with:
21+
persist-credentials: false
22+
23+
- name: Mark the workspace as safe
24+
# https://github.com/actions/checkout/issues/766
25+
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
26+
27+
- name: Install bsdtar
28+
run: |
29+
which bsdtar || (apt-get -q update && apt-get -yq install libarchive-tools)
30+
31+
- name: Run test job
32+
env:
33+
REGISTRY_HOST: registry
34+
REGISTRY_PORT: 5000
35+
run: |
36+
swift test

.github/workflows/main.yml

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,7 @@ jobs:
2020

2121
integration-tests:
2222
name: Integration tests
23-
runs-on: ubuntu-latest
24-
services:
25-
registry:
26-
image: registry:2
27-
ports:
28-
- 5000:5000
29-
container:
30-
image: swift:6.0-noble
31-
steps:
32-
- name: Checkout repository
33-
uses: actions/checkout@v4
34-
with:
35-
persist-credentials: false
36-
37-
- name: Mark the workspace as safe
38-
# https://github.com/actions/checkout/issues/766
39-
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
40-
41-
- name: Run test job
42-
env:
43-
REGISTRY_HOST: registry
44-
REGISTRY_PORT: 5000
45-
run: |
46-
swift test
23+
uses: ./.github/workflows/integration_tests.yml
4724

4825
endtoend-tests:
4926
name: End to end tests

.github/workflows/pull_request.yml

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,37 +25,10 @@ jobs:
2525
linux_nightly_6_1_arguments_override: "--skip SmokeTests --skip TarInteropTests"
2626
linux_nightly_main_arguments_override: "--skip SmokeTests --skip TarInteropTests"
2727

28-
# Test functions and modules against an separate registry
28+
# Test functions and modules against a separate registry
2929
integration-tests:
3030
name: Integration tests
31-
runs-on: ubuntu-latest
32-
services:
33-
registry:
34-
image: registry:2
35-
ports:
36-
- 5000:5000
37-
container:
38-
image: swift:6.0-noble
39-
steps:
40-
- name: Checkout repository
41-
uses: actions/checkout@v4
42-
with:
43-
persist-credentials: false
44-
45-
- name: Mark the workspace as safe
46-
# https://github.com/actions/checkout/issues/766
47-
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
48-
49-
- name: Install bsdtar
50-
run: |
51-
which bsdtar || (apt-get -q update && apt-get -yq install libarchive-tools)
52-
53-
- name: Run test job
54-
env:
55-
REGISTRY_HOST: registry
56-
REGISTRY_PORT: 5000
57-
run: |
58-
swift test
31+
uses: ./.github/workflows/integration_tests.yml
5932

6033
# Test that outputs can be handled properly by other systems
6134
interop-tests:

0 commit comments

Comments
 (0)