Skip to content

Commit 49f9006

Browse files
authored
Add macOS job to pull request workflow (#364)
* Add macOS job to pull request workflow * Use swiftly to install swift for macOS * Customize swiftly home and toolchain locations for macOS * Build release check for macOS * Add macOS nightly smoke test and release workflow
1 parent fcb074e commit 49f9006

File tree

4 files changed

+101
-17
lines changed

4 files changed

+101
-17
lines changed

.github/workflows/build_release.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ env:
1818
SWIFTLY_BOOTSTRAP_VERSION: 1.0.0
1919

2020
jobs:
21-
buildrelease:
22-
name: Build Release
21+
buildrelease-linux:
22+
name: Build Release / Linux x86_64
2323
runs-on: ubuntu-latest
2424
container:
2525
image: "redhat/ubi9"
@@ -44,3 +44,20 @@ jobs:
4444
name: swiftly-docs
4545
path: .build/docs/**
4646
if-no-files-found: error
47+
48+
buildrelease-macos:
49+
name: Build Release / macOS
50+
runs-on: [self-hosted, macos, sequoia, ARM64]
51+
steps:
52+
- name: Checkout repository
53+
uses: actions/checkout@v4
54+
- name: Prepare the action
55+
run: ./scripts/prep-gh-action.sh --install-swiftly
56+
- name: Build Release Artifact
57+
run: swift run build-swiftly-release ${{ inputs.skip }} ${{ inputs.version }}
58+
- name: Upload Release Artifact
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: swiftly-release-x86_64
62+
path: .build/release/swiftly-*.tar.gz
63+
if-no-files-found: error

.github/workflows/nightly_snapshot_check.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ env:
88
SWIFTLY_BOOTSTRAP_VERSION: 1.0.0
99

1010
jobs:
11-
tests-selfhosted:
11+
tests-selfhosted-linux:
1212
name: Test (Smoke Test - Nightly Swift Toolchain) / ${{ matrix.container }}
1313
runs-on: ubuntu-latest
1414
strategy:
@@ -26,3 +26,14 @@ jobs:
2626
# UBI 9 and Ubuntu 20.04 - See https://github.com/swiftlang/swift/issues/80908
2727
# UBI 9 - See https://github.com/swiftlang/swift/issues/80909
2828
run: bash -c 'if [[ "${{ matrix.container }}" == "redhat/ubi9" ]]; then swiftly run +main-snapshot swift build --build-tests; elif [[ "${{ matrix.container }}" == "ubuntu:20.04" ]]; then swiftly run +main-snapshot swift build --build-tests; else swiftly run +main-snapshot swift test; fi'
29+
30+
tests-selfhosted-macos:
31+
name: Test (Smoke Test - Nightly Swift Toolchain) / macOS Sequoia ARM64
32+
runs-on: [self-hosted, macos, sequoia, ARM64]
33+
steps:
34+
- name: Checkout repository
35+
uses: actions/checkout@v4
36+
- name: Prepare the action
37+
run: ./scripts/prep-gh-action.sh --install-swiftly --swift-main-snapshot
38+
- name: Build and Test
39+
run: swift test

.github/workflows/pull_request.yml

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [main]
88

99
env:
10-
SWIFTLY_BOOTSTRAP_VERSION: 1.0.0
10+
SWIFTLY_BOOTSTRAP_VERSION: 1.0.1-dev
1111

1212
jobs:
1313
soundness:
@@ -22,6 +22,20 @@ jobs:
2222
shell_check_enabled: false
2323
unacceptable_language_check_enabled: true
2424

25+
macos-tests-selfhosted:
26+
name: Test (Self Hosted) / macOS Sequoia ARM64
27+
runs-on: [self-hosted, macos, sequoia, ARM64]
28+
strategy:
29+
fail-fast: false
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
- name: Prepare the action
34+
run: ./scripts/prep-gh-action.sh --install-swiftly
35+
- name: Build and Test
36+
run: swift test
37+
timeout-minutes: 60
38+
2539
tests-selfhosted:
2640
name: Test (Self Hosted) / ${{ matrix.container }}
2741
runs-on: ubuntu-latest
@@ -42,7 +56,7 @@ jobs:
4256
run: bash -c 'if [[ "${{ matrix.container }}" == "redhat/ubi9" ]]; then swift build --build-tests; elif [[ "${{ matrix.container }}" == "ubuntu:20.04" ]]; then swift build --build-tests; else swift test; fi'
4357

4458
releasebuildcheck:
45-
name: Release Build Check
59+
name: Release Build Check / Linux
4660
runs-on: ubuntu-latest
4761
container:
4862
image: "redhat/ubi9"
@@ -63,11 +77,36 @@ jobs:
6377
- name: Upload Tests
6478
uses: actions/upload-artifact@v4
6579
with:
66-
name: swiftly-tests-x86_64
80+
name: test-swiftly-linux-x86_64
6781
path: .build/debug/test-swiftly-linux-x86_64.tar.gz
6882
if-no-files-found: error
6983
retention-days: 1
7084

85+
releasebuildcheckmacos:
86+
name: Release Build Check / macOS
87+
runs-on: [self-hosted, macos, sequoia, ARM64]
88+
steps:
89+
- name: Checkout repository
90+
uses: actions/checkout@v4
91+
- name: Prepare the action
92+
run: ./scripts/prep-gh-action.sh --install-swiftly
93+
- name: Build Artifact
94+
run: swift run build-swiftly-release --test --skip "999.0.0"
95+
- name: Upload Artifact
96+
uses: actions/upload-artifact@v4
97+
with:
98+
name: swiftly-release-darwin
99+
path: .build/release/swiftly-*.pkg
100+
if-no-files-found: error
101+
retention-days: 1
102+
- name: Upload Tests
103+
uses: actions/upload-artifact@v4
104+
with:
105+
name: test-swiftly-macos
106+
path: .build/release/test-swiftly-macos.tar.gz
107+
if-no-files-found: error
108+
retention-days: 1
109+
71110
releasetest:
72111
name: Test Release / ${{matrix.shell.pkg}}
73112
needs: releasebuildcheck
@@ -92,7 +131,7 @@ jobs:
92131
- name: Download Tests
93132
uses: actions/download-artifact@v4
94133
with:
95-
name: swiftly-tests-x86_64
134+
name: test-swiftly-linux-x86_64
96135
- name: Extract and Run Workflow Tests
97136
run: cp swiftly-*.tar.gz /root/swiftly.tar.gz && cp test-swiftly-*.tar.gz /root && cd /root && tar zxf test-swiftly-*.tar.gz && ./test-swiftly -y ./swiftly.tar.gz
98137

@@ -112,7 +151,7 @@ jobs:
112151
- name: Download Tests
113152
uses: actions/download-artifact@v4
114153
with:
115-
name: swiftly-tests-x86_64
154+
name: test-swiftly-linux-x86_64
116155
- name: Extract and Run Workflow Tests
117156
run: cp swiftly-*.tar.gz /root/swiftly.tar.gz && cp test-swiftly-*.tar.gz /root && cd /root && tar zxf test-swiftly-*.tar.gz && ./test-swiftly -y --custom-location ./swiftly.tar.gz
118157

scripts/prep-gh-action.sh

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
# This script does a bit of extra preparation of the docker containers used to run the GitHub workflows
44
# that are specific to this project's needs when building/testing. Note that this script runs on
5-
# every supported Linux distribution so it must adapt to the distribution that it is running.
5+
# every supported Linux distribution and macOS so it must adapt to the distribution that it is running.
66

7-
# Install the basic utilities depending on the type of Linux distribution
8-
apt-get --help && apt-get update && TZ=Etc/UTC apt-get -y install curl make gpg tzdata
9-
yum --help && (curl --help && yum -y install curl) && yum install make gpg
7+
if [[ "$(uname -s)" == "Linux" ]]; then
8+
# Install the basic utilities depending on the type of Linux distribution
9+
apt-get --help && apt-get update && TZ=Etc/UTC apt-get -y install curl make gpg tzdata
10+
yum --help && (curl --help && yum -y install curl) && yum install make gpg
11+
fi
1012

1113
set -e
1214

@@ -27,14 +29,25 @@ done
2729

2830
if [ "$installSwiftly" == true ]; then
2931
echo "Installing swiftly"
30-
curl -O https://download.swift.org/swiftly/linux/swiftly-${SWIFTLY_BOOTSTRAP_VERSION}-$(uname -m).tar.gz && tar zxf swiftly-*.tar.gz && ./swiftly init -y --skip-install
3132

32-
. "/root/.local/share/swiftly/env.sh"
33+
if [[ "$(uname -s)" == "Linux" ]]; then
34+
curl -O https://download.swift.org/swiftly/linux/swiftly-${SWIFTLY_BOOTSTRAP_VERSION}-$(uname -m).tar.gz && tar zxf swiftly-*.tar.gz && ./swiftly init -y --skip-install
35+
. "/root/.local/share/swiftly/env.sh"
36+
else
37+
export SWIFTLY_HOME_DIR="$(pwd)/swiftly-bootstrap"
38+
export SWIFTLY_BIN_DIR="$SWIFTLY_HOME_DIR/bin"
39+
export SWIFTLY_TOOLCHAINS_DIR="$SWIFTLY_HOME_DIR/toolchains"
40+
41+
curl -O https://download.swift.org/swiftly/darwin/swiftly-${SWIFTLY_BOOTSTRAP_VERSION}.pkg && pkgutil --check-signature swiftly-*.pkg && pkgutil --verbose --expand swiftly-*.pkg "${SWIFTLY_HOME_DIR}" && tar -C "${SWIFTLY_HOME_DIR}" -xvf "${SWIFTLY_HOME_DIR}"/swiftly-*/Payload && "$SWIFTLY_HOME_DIR/bin/swiftly" init -y --skip-install
42+
43+
. "$SWIFTLY_HOME_DIR/env.sh"
44+
fi
45+
3346
hash -r
3447

3548
if [ -n "$GITHUB_ENV" ]; then
3649
echo "Updating GitHub environment"
37-
echo "PATH=$PATH" >> "$GITHUB_ENV" && echo "SWIFTLY_HOME_DIR=$SWIFTLY_HOME_DIR" >> "$GITHUB_ENV" && echo "SWIFTLY_BIN_DIR=$SWIFTLY_BIN_DIR" >> "$GITHUB_ENV"
50+
echo "PATH=$PATH" >> "$GITHUB_ENV" && echo "SWIFTLY_HOME_DIR=$SWIFTLY_HOME_DIR" >> "$GITHUB_ENV" && echo "SWIFTLY_BIN_DIR=$SWIFTLY_BIN_DIR" >> "$GITHUB_ENV" && echo "SWIFTLY_TOOLCHAINS_DIR=$SWIFTLY_TOOLCHAINS_DIR" >> "$GITHUB_ENV"
3851
fi
3952

4053
selector=()
@@ -64,7 +77,11 @@ if [ "$installSwiftly" == true ]; then
6477
echo "Displaying swift version"
6578
swiftly run "${runSelector[@]}" swift --version
6679

67-
CC=clang swiftly run "${runSelector[@]}" "$(dirname "$0")/install-libarchive.sh"
80+
if [[ "$(uname -s)" == "Linux" ]]; then
81+
CC=clang swiftly run "${runSelector[@]}" "$(dirname "$0")/install-libarchive.sh"
82+
fi
6883
else
69-
"$(dirname "$0")/install-libarchive.sh"
84+
if [[ "$(uname -s)" == "Linux" ]]; then
85+
"$(dirname "$0")/install-libarchive.sh"
86+
fi
7087
fi

0 commit comments

Comments
 (0)