Skip to content

Add macOS job to pull request workflow #364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ env:
SWIFTLY_BOOTSTRAP_VERSION: 1.0.0

jobs:
buildrelease:
name: Build Release
buildrelease-linux:
name: Build Release / Linux x86_64
runs-on: ubuntu-latest
container:
image: "redhat/ubi9"
Expand All @@ -44,3 +44,20 @@ jobs:
name: swiftly-docs
path: .build/docs/**
if-no-files-found: error

buildrelease-macos:
name: Build Release / macOS
runs-on: [self-hosted, macos, sequoia, ARM64]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Prepare the action
run: ./scripts/prep-gh-action.sh --install-swiftly
- name: Build Release Artifact
run: swift run build-swiftly-release ${{ inputs.skip }} ${{ inputs.version }}
- name: Upload Release Artifact
uses: actions/upload-artifact@v4
with:
name: swiftly-release-x86_64
path: .build/release/swiftly-*.tar.gz
if-no-files-found: error
13 changes: 12 additions & 1 deletion .github/workflows/nightly_snapshot_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ env:
SWIFTLY_BOOTSTRAP_VERSION: 1.0.0

jobs:
tests-selfhosted:
tests-selfhosted-linux:
name: Test (Smoke Test - Nightly Swift Toolchain) / ${{ matrix.container }}
runs-on: ubuntu-latest
strategy:
Expand All @@ -26,3 +26,14 @@ jobs:
# UBI 9 and Ubuntu 20.04 - See https://github.com/swiftlang/swift/issues/80908
# UBI 9 - See https://github.com/swiftlang/swift/issues/80909
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'

tests-selfhosted-macos:
name: Test (Smoke Test - Nightly Swift Toolchain) / macOS Sequoia ARM64
runs-on: [self-hosted, macos, sequoia, ARM64]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Prepare the action
run: ./scripts/prep-gh-action.sh --install-swiftly --swift-main-snapshot
- name: Build and Test
run: swift test
49 changes: 44 additions & 5 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [main]

env:
SWIFTLY_BOOTSTRAP_VERSION: 1.0.0
SWIFTLY_BOOTSTRAP_VERSION: 1.0.1-dev

jobs:
soundness:
Expand All @@ -22,6 +22,20 @@ jobs:
shell_check_enabled: false
unacceptable_language_check_enabled: true

macos-tests-selfhosted:
name: Test (Self Hosted) / macOS Sequoia ARM64
runs-on: [self-hosted, macos, sequoia, ARM64]
strategy:
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Prepare the action
run: ./scripts/prep-gh-action.sh --install-swiftly
- name: Build and Test
run: swift test
timeout-minutes: 60

Comment on lines +25 to +38
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there reason for not using the github-workflow yml file here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's mainly so that we can use the .swift-version file to control what toolchain to install and use. For that we need swiftly to be installed so that it can fetch and install the toolchain for us.

For other jobs that verify swiftly installs on a fresh system there needs to be no trace of swift or swiftly in those containers.

tests-selfhosted:
name: Test (Self Hosted) / ${{ matrix.container }}
runs-on: ubuntu-latest
Expand All @@ -42,7 +56,7 @@ jobs:
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'

releasebuildcheck:
name: Release Build Check
name: Release Build Check / Linux
runs-on: ubuntu-latest
container:
image: "redhat/ubi9"
Expand All @@ -63,11 +77,36 @@ jobs:
- name: Upload Tests
uses: actions/upload-artifact@v4
with:
name: swiftly-tests-x86_64
name: test-swiftly-linux-x86_64
path: .build/debug/test-swiftly-linux-x86_64.tar.gz
if-no-files-found: error
retention-days: 1

releasebuildcheckmacos:
name: Release Build Check / macOS
runs-on: [self-hosted, macos, sequoia, ARM64]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Prepare the action
run: ./scripts/prep-gh-action.sh --install-swiftly
- name: Build Artifact
run: swift run build-swiftly-release --test --skip "999.0.0"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: swiftly-release-darwin
path: .build/release/swiftly-*.pkg
if-no-files-found: error
retention-days: 1
- name: Upload Tests
uses: actions/upload-artifact@v4
with:
name: test-swiftly-macos
path: .build/release/test-swiftly-macos.tar.gz
if-no-files-found: error
retention-days: 1

releasetest:
name: Test Release / ${{matrix.shell.pkg}}
needs: releasebuildcheck
Expand All @@ -92,7 +131,7 @@ jobs:
- name: Download Tests
uses: actions/download-artifact@v4
with:
name: swiftly-tests-x86_64
name: test-swiftly-linux-x86_64
- name: Extract and Run Workflow Tests
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

Expand All @@ -112,7 +151,7 @@ jobs:
- name: Download Tests
uses: actions/download-artifact@v4
with:
name: swiftly-tests-x86_64
name: test-swiftly-linux-x86_64
- name: Extract and Run Workflow Tests
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

Expand Down
35 changes: 26 additions & 9 deletions scripts/prep-gh-action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

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

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

set -e

Expand All @@ -27,14 +29,25 @@ done

if [ "$installSwiftly" == true ]; then
echo "Installing swiftly"
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

. "/root/.local/share/swiftly/env.sh"
if [[ "$(uname -s)" == "Linux" ]]; then
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
. "/root/.local/share/swiftly/env.sh"
else
export SWIFTLY_HOME_DIR="$(pwd)/swiftly-bootstrap"
export SWIFTLY_BIN_DIR="$SWIFTLY_HOME_DIR/bin"
export SWIFTLY_TOOLCHAINS_DIR="$SWIFTLY_HOME_DIR/toolchains"

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

. "$SWIFTLY_HOME_DIR/env.sh"
fi

hash -r

if [ -n "$GITHUB_ENV" ]; then
echo "Updating GitHub environment"
echo "PATH=$PATH" >> "$GITHUB_ENV" && echo "SWIFTLY_HOME_DIR=$SWIFTLY_HOME_DIR" >> "$GITHUB_ENV" && echo "SWIFTLY_BIN_DIR=$SWIFTLY_BIN_DIR" >> "$GITHUB_ENV"
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"
fi

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

CC=clang swiftly run "${runSelector[@]}" "$(dirname "$0")/install-libarchive.sh"
if [[ "$(uname -s)" == "Linux" ]]; then
CC=clang swiftly run "${runSelector[@]}" "$(dirname "$0")/install-libarchive.sh"
fi
else
"$(dirname "$0")/install-libarchive.sh"
if [[ "$(uname -s)" == "Linux" ]]; then
"$(dirname "$0")/install-libarchive.sh"
fi
fi