Fix Rust/Swift caching and parallelize swift build (#1793)

- Renames remnants of `cloud` ref to `main`
- Uses matrix for macOS, iphoneos builds
This commit is contained in:
Jamil
2023-07-14 23:09:15 -07:00
committed by GitHub
parent 5af2b45034
commit b782436f98
8 changed files with 43 additions and 25 deletions

View File

@@ -2,8 +2,7 @@ name: Continuous Delivery
on:
push:
branches:
- master
- cloud
- main
# Cancel old workflow runs if new code is pushed
concurrency:

View File

@@ -184,7 +184,7 @@ jobs:
MIX_ENV: dev
POSTGRES_HOST: localhost
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MASTER_BRANCH: cloud
MASTER_BRANCH: main
services:
postgres:
image: postgres:15

View File

@@ -23,7 +23,7 @@ jobs:
steps:
- uses: release-drafter/release-drafter@v5
with:
commitish: cloud
commitish: main
id: release_drafter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -33,10 +33,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- run: 'echo "No build required"'
rust_build-apple:
runs-on: ubuntu-latest
steps:
- run: 'echo "No build required"'
rust_cross-compile-relay: # cross is separate from test because cross-compiling yields different artifacts and we cannot reuse the cache.
runs-on: ubuntu-latest
steps:

View File

@@ -26,7 +26,7 @@ jobs:
steps:
- uses: release-drafter/release-drafter@v5
with:
commitish: cloud
commitish: main
id: release_drafter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -55,7 +55,7 @@ jobs:
workspaces: ./rust
key: v2
prefix-key: rust-${{ matrix.runs-on }}
save-if: ${{ github.ref == 'refs/heads/cloud' }}
save-if: ${{ github.ref == 'refs/heads/main' }}
# TODO: Building *ring* from git requires us to install additional tools;
# once we're not using a forked *ring* these 2 steps can be removed.

View File

@@ -18,6 +18,13 @@ jobs:
steps:
- run: 'echo "No build required"'
swift_build:
strategy:
matrix:
target:
- sdk: macosx
platform: macOS
- sdk: iphoneos
platform: iOS
runs-on: ubuntu-latest
steps:
- run: 'echo "No build required"'

View File

@@ -23,12 +23,21 @@ jobs:
steps:
- uses: release-drafter/release-drafter@v5
with:
commitish: cloud
commitish: main
id: release_drafter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
swift_build:
strategy:
matrix:
target:
- sdk: macosx
platform: macOS
destination: platform=macOS
- sdk: iphoneos
platform: iOS
destination: generic/platform=iOS
runs-on: macos-latest
permissions:
contents: read
@@ -43,27 +52,24 @@ jobs:
- uses: Swatinem/rust-cache@v2
with:
workspaces: ./rust
prefix-key: rust-${{ matrix.runs-on }}
save-if: ${{ github.ref == 'refs/heads/cloud' }}
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Update toolchain
run: rustup show
- uses: actions/cache@v3
with:
path: apple/.build
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
path: ~/Library/Developer/Xcode/DerivedData/**/SourcePackages/checkouts
key: ${{ matrix.target.platform }}-spm-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-
${{ matrix.target.platform }}-spm-
- name: Select Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Build app for macOS
- name: Build app
env:
ONLY_ACTIVE_ARCH: no
working-directory: ./swift/apple
run: |
cp Firezone/xcconfig/Developer.xcconfig.ci-macOS Firezone/xcconfig/Developer.xcconfig
xcodebuild archive -scheme Firezone -sdk macosx -destination 'platform=macOS' CODE_SIGNING_ALLOWED=NO
- name: Build app for iOS
working-directory: ./swift/apple
run: |
cp Firezone/xcconfig/Developer.xcconfig.ci-iOS Firezone/xcconfig/Developer.xcconfig
xcodebuild archive -scheme Firezone -sdk iphoneos -destination 'generic/platform=iOS' CODE_SIGNING_ALLOWED=NO
cp Firezone/xcconfig/Developer.xcconfig.ci-${{ matrix.target.platform }} Firezone/xcconfig/Developer.xcconfig
xcodebuild archive -configuration Release -scheme Firezone -sdk ${{ matrix.target.sdk }} -destination '${{ matrix.target.destination }}' CODE_SIGNING_ALLOWED=NO

View File

@@ -26,6 +26,16 @@ export INCLUDE_PATH="${base_dir}/usr/include"
export CFLAGS="-L ${LIBRARY_PATH} -I ${INCLUDE_PATH} -Qunused-arguments"
export RUSTFLAGS="-C link-arg=-F$base_dir/System/Library/Frameworks"
# Borrowed from https://github.com/signalapp/libsignal/commit/02899cac643a14b2ced7c058cc15a836a2165b6d
# Thanks to @francesca64 for the fix
if [[ -n "${DEVELOPER_SDK_DIR:-}" ]]; then
# Assume we're in Xcode, which means we're probably cross-compiling.
# In this case, we need to add an extra library search path for build scripts and proc-macros,
# which run on the host instead of the target.
# (macOS Big Sur does not have linkable libraries in /usr/lib/.)
export LIBRARY_PATH="${DEVELOPER_SDK_DIR}/MacOSX.sdk/usr/lib:${LIBRARY_PATH:-}"
fi
TARGETS=()
if [[ "$PLATFORM_NAME" = "macosx" ]]; then
if [[ $CONFIGURATION == "Release" ]] || [[ -z "$NATIVE_ARCH" ]]; then
@@ -89,6 +99,6 @@ fi
for target in "${TARGETS[@]}"
do
set -x
cargo build --target $target $FEATURE_ARGS $CONFIGURATION_ARGS
cargo build --target=$target $FEATURE_ARGS $CONFIGURATION_ARGS
set +x
done