[WIP] full rewrite #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
jobs: | |
tests: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
swift: ["6.0", "6.1", "main-snapshot"] | |
exclude: | |
- os: macos-latest | |
swift: "6.0" # Swift 6.0 on mac runs into a compiler error on CI when building MetaCodable, but somehow runs fine on the Swift Package Index build process? | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Install Swift toolchain | |
shell: bash | |
run: | | |
set -e | |
export SWIFTLY_BIN_DIR=${{ github.workspace }}/.swiftly/bin | |
export SWIFTLY_HOME_DIR=${{ github.workspace }}/.swiftly/share | |
echo "TOOLCHAINS=swift" >> $GITHUB_ENV | |
echo "$SWIFTLY_BIN_DIR" >> $GITHUB_PATH | |
echo "SWIFTLY_BIN_DIR=$SWIFTLY_BIN_DIR" >> $GITHUB_ENV | |
echo "SWIFTLY_HOME_DIR=$SWIFTLY_HOME_DIR" >> $GITHUB_ENV | |
export PATH=$SWIFTLY_BIN_DIR:$PATH | |
mkdir -p $SWIFTLY_BIN_DIR | |
mkdir -p $SWIFTLY_HOME_DIR | |
if ${{ runner.os == 'Linux' }} ; then | |
curl -O https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz | |
tar -xzf swiftly-$(uname -m).tar.gz -C $SWIFTLY_BIN_DIR | |
rm swiftly-$(uname -m).tar.gz | |
sudo apt-get update | |
else | |
curl -O https://download.swift.org/swiftly/darwin/swiftly.pkg | |
installer -pkg swiftly.pkg -target CurrentUserHomeDirectory | |
cp ~/.swiftly/bin/swiftly $SWIFTLY_BIN_DIR | |
rm swiftly.pkg | |
fi | |
swiftly init --no-modify-profile --quiet-shell-followup --assume-yes --skip-install --verbose | |
echo "swiftly version: $(swiftly --version)" >&2 | |
swiftly install --assume-yes --post-install-file "${HOME}/.swiftly-postinstall-cmds.sh" --use ${{ matrix.swift }} | |
if [[ -f "${HOME}/.swiftly-postinstall-cmds.sh" ]]; then | |
export DEBIAN_FRONTEND=noninteractive # prevent Debian/Ubuntu installs from hanging on tzdata | |
if [[ "$(id -un)" == 'root' ]]; then | |
. "${HOME}/.swiftly-postinstall-cmds.sh" | |
else | |
sudo bash -c ". '${HOME}/.swiftly-postinstall-cmds.sh'" | |
fi | |
rm "${HOME}/.swiftly-postinstall-cmds.sh" | |
fi | |
- uses: actions/checkout@v4 | |
- name: Restore .build | |
id: restore-build | |
uses: actions/cache/restore@v4 | |
with: | |
path: .build | |
restore-keys: "swiftpm-tests-build-${{ runner.os }}-${{ matrix.swift }}-" | |
key: "swiftpm-tests-build-${{ runner.os }}-${{ matrix.swift }}-${{ github.event.pull_request.base.sha || github.event.after }}" | |
- name: Build | |
run: swift build | |
- name: Cache .build | |
if: steps.restore-build.outputs.cache-hit != 'true' | |
uses: actions/cache/save@v4 | |
with: | |
path: .build | |
key: "swiftpm-tests-build-${{ runner.os }}-${{ matrix.swift }}-${{ github.event.pull_request.base.sha || github.event.after }}" |