Skip to content

Commit ba36907

Browse files
committed
first test to get a matrix setup
1 parent b30dfe4 commit ba36907

File tree

3 files changed

+116
-13
lines changed

3 files changed

+116
-13
lines changed

.github/workflows/examples_matrix.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: ExamplesMatrix
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
name:
7+
type: string
8+
description: "The name of the workflow used for the concurrency group."
9+
required: true
10+
matrix_linux_command:
11+
type: string
12+
description: "The command of the current Swift version linux matrix job to execute."
13+
required: true
14+
matrix_linux_nightly_6_0_enabled:
15+
type: boolean
16+
description: "Boolean to enable the nightly 6.0 Swift version matrix job. Defaults to true."
17+
default: true
18+
matrix_linux_nightly_6_0_container_image:
19+
type: string
20+
description: "Container image for the nightly 6.0 Swift version matrix job. Defaults to matching Swift Ubuntu image."
21+
default: "swiftlang/swift:nightly-6.0-jammy"
22+
matrix_linux_nightly_6_0_command_override:
23+
type: string
24+
description: "The command of the nightly 6.0 Swift version linux matrix job to execute."
25+
matrix_linux_nightly_main_enabled:
26+
type: boolean
27+
description: "Boolean to enable the nightly main Swift version matrix job. Defaults to true."
28+
default: true
29+
matrix_linux_nightly_main_container_image:
30+
type: string
31+
description: "Container image for the nightly main Swift version matrix job. Defaults to matching Swift Ubuntu image."
32+
default: "swiftlang/swift:nightly-main-jammy"
33+
matrix_linux_nightly_main_command_override:
34+
type: string
35+
description: "The command of the nightly main Swift version linux matrix job to execute."
36+
37+
## We are cancelling previously triggered workflow runs
38+
concurrency:
39+
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.name }}
40+
cancel-in-progress: true
41+
42+
jobs:
43+
linux:
44+
name: Linux (${{ matrix.swift.swift_version }})
45+
runs-on: ubuntu-latest
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
examples : [ "HelloWorld", "APIGateway" ]
50+
# We are specifying only the major and minor of the docker images to automatically pick up the latest patch release
51+
swift:
52+
- image: ${{ inputs.matrix_linux_nightly_6_0_container_image }}
53+
swift_version: "nightly-6.0"
54+
enabled: ${{ inputs.matrix_linux_nightly_6_0_enabled }}
55+
- image: ${{ inputs.matrix_linux_nightly_main_container_image }}
56+
swift_version: "nightly-main"
57+
enabled: ${{ inputs.matrix_linux_nightly_main_enabled }}
58+
container:
59+
image: ${{ matrix.swift.image }}
60+
steps:
61+
- name: Checkout repository
62+
if: ${{ matrix.swift.enabled }}
63+
uses: actions/checkout@v4
64+
with:
65+
persist-credentials: false
66+
- name: Mark the workspace as safe
67+
if: ${{ matrix.swift.enabled }}
68+
# https://github.com/actions/checkout/issues/766
69+
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
70+
- name: Run matrix job
71+
if: ${{ matrix.swift.enabled }}
72+
env:
73+
SWIFT_VERSION: ${{ matrix.swift.swift_version }}
74+
COMMAND: ${{ inputs.matrix_linux_command }}
75+
COMMAND_OVERRIDE_NIGHTLY_6_0: ${{ inputs.matrix_linux_nightly_6_0_command_override }}
76+
COMMAND_OVERRIDE_NIGHTLY_MAIN: ${{ inputs.matrix_linux_nightly_main_command_override }}
77+
EXAMPLE: ${{ matrix.examples }}
78+
run: |
79+
apt-get -qq update && apt-get -qq -y install curl
80+
./scripts/integration_tests.sh

.github/workflows/pull_request.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,10 @@ jobs:
2626

2727
integration-tests:
2828
name: Integration Tests
29-
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
29+
uses: examples_matrix.yml
3030
with:
3131
name: "Integration tests"
32-
matrix_linux_command: "./scripts/integration_tests.sh"
33-
matrix_linux_5_8_enabled: false
34-
matrix_linux_5_9_enabled: false
35-
matrix_linux_5_10_enabled: false
32+
matrix_linux_command: "pushd Examples/$EXAMPLE && LAMBDA_USE_LOCAL_DEPS=../.. swift build && popd"
3633

3734
swift-6-language-mode:
3835
name: Swift 6 Language Mode

scripts/integration_tests.sh

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,38 @@
1313
##
1414
##===----------------------------------------------------------------------===##
1515

16-
set +x -e
16+
# set +x -e
1717

18-
for EXAMPLE in $(find Examples -type d -d 1);
19-
do
20-
echo "Building $EXAMPLE"
21-
pushd $EXAMPLE
22-
LAMBDA_USE_LOCAL_DEPS=../.. swift build
23-
popd
24-
done
18+
# for EXAMPLE in $(find Examples -type d -d 1);
19+
# do
20+
# echo "Building $EXAMPLE"
21+
# pushd $EXAMPLE
22+
# LAMBDA_USE_LOCAL_DEPS=../.. swift build
23+
# popd
24+
# done
25+
26+
set -euo pipefail
27+
28+
log() { printf -- "** %s\n" "$*" >&2; }
29+
error() { printf -- "** ERROR: %s\n" "$*" >&2; }
30+
fatal() { error "$@"; exit 1; }
31+
32+
test -n "${SWIFT_VERSION:-}" || fatal "SWIFT_VERSION unset"
33+
test -n "${COMMAND:-}" || fatal "COMMAND unset"
34+
test -n "${EXAMPLE:-}" || fatal "EXAMPLE unset"
35+
swift_version="$SWIFT_VERSION"
36+
command="$COMMAND"
37+
command_nightly_6_0="$COMMAND_OVERRIDE_NIGHTLY_6_0"
38+
command_nightly_main="$COMMAND_OVERRIDE_NIGHTLY_MAIN"
39+
example="$EXAMPLE"
40+
41+
if [[ "$swift_version" == "nightly-6.0" ]] && [[ -n "$command_nightly_6_0" ]]; then
42+
log "Running nightly 6.0 command override"
43+
eval "$command_nightly_6_0"
44+
elif [[ "$swift_version" == "nightly-main" ]] && [[ -n "$command_nightly_main" ]]; then
45+
log "Running nightly main command override"
46+
eval "$command_nightly_main"
47+
else
48+
log "Running default command"
49+
eval "$command"
50+
fi

0 commit comments

Comments
 (0)