Skip to content

Commit

Permalink
GitHub Actions workflow fixes (#422)
Browse files Browse the repository at this point in the history
This PR proposes fixes for some of the workflow issues introduced with #418, and to update the GitHub Actions workflows where appropriate to use recent versions of Xcode, macOS and the Actions plugins.

This ended up being a wonderful confluence of problems to solve, resulting in the following changes:
- macOS 11 runners have been removed (GHA doesn't support them anymore).
- Swift versions prior to 5.7 on platforms other than macOS had to be removed, as the images were conflicting with the actions/checkout action (in reality, all node-based actions would fail on these older images).
- Where possible, base tasks like SwiftLint and CocoaPods verification happen on a macOS 14 Sonoma image running Xcode 15.4 (the latest at the time of authoring).
- CocoaPods needed to be upgraded for visionOS support.
- A few minor SwiftLint violations introduced in recent versions needed to be fixed or disabled.
- I disabled running SwiftLint from within the Xcode project when it detects that it is being built on CI. It seemed unnecessary given it's running in a dedicated workflow.
- Existing workflow jobs will now auto-cancel if a new set of jobs is started on the same branch.
  • Loading branch information
tonyarnold authored Jul 10, 2024
1 parent 60be6ad commit 98650c6
Show file tree
Hide file tree
Showing 15 changed files with 213 additions and 148 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@ on:
- '.bazelrc'
- '.bazelversion'

concurrency:
group: bazel-${{ github.ref }}
cancel-in-progress: true

jobs:
MacOS:
runs-on: macos-13
macOS:
runs-on: macos-14
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Apple tests
run: bazelisk test //Tests/...
Linux:
Expand All @@ -42,7 +46,7 @@ jobs:
container:
image: swift:${{ matrix.tag }}-focal
steps:
- uses: actions/checkout@v3
- uses: bazelbuild/setup-bazelisk@v2
- uses: actions/checkout@v4
- uses: bazelbuild/setup-bazelisk@v3
- name: Yams tests
run: bazel test --test_output=all //Tests:UnitTests
23 changes: 15 additions & 8 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: CMake
on:
push:
branches: [main]
paths:
paths:
- '.github/workflows/cmake.yml'
- '**/CMakeLists.txt'
- '**/*.cmake'
Expand All @@ -12,7 +12,7 @@ on:
- 'Sources/**/*.swift'
- 'Sources/**/module.modulemap'
pull_request:
paths:
paths:
- '.github/workflows/cmake.yml'
- '**/CMakeLists.txt'
- '**/*.cmake'
Expand All @@ -21,33 +21,40 @@ on:
- 'Sources/**/*.swift'
- 'Sources/**/module.modulemap'

concurrency:
group: cmake-${{ github.ref }}
cancel-in-progress: true

jobs:
CMake:
name: macOS with Xcode ${{ matrix.xcode_version }}
strategy:
matrix:
xcode_version: ['14.2', '14.3', '15.0']
runs-on: macos-13
xcode_version: ['15.0', '15.1', '15.2', '15.3', '15.4']
runs-on: macos-14
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode_version }}.app
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: sudo chown runner:admin /usr/local
- run: brew install cmake ninja
- run: swift -version
- run: rm -rf build
- run: cmake -B build -G Ninja -S . -DCMAKE_BUILD_TYPE=Release
- run: cmake --build build
- run: cmake --build build --target install
- run: file /usr/local/lib/swift/macosx/libYams.dylib | grep "Mach-O 64-bit dynamically linked shared library x86_64"
- run: file /usr/local/lib/swift/macosx/libYams.dylib | grep "Mach-O 64-bit dynamically linked shared library arm64"

CMake_Linux:
name: Linux with Swift ${{ matrix.tag }}
strategy:
matrix:
tag: ['5.6', '5.7', '5.8', '5.9', '5.10']
tag: ['5.7', '5.8', '5.9', '5.10']
runs-on: ubuntu-latest
container:
image: swift:${{ matrix.tag }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: apt-get update && apt-get install -y ninja-build curl
- run: curl -L https://github.com/Kitware/CMake/releases/download/v3.23.1/cmake-3.23.1-linux-x86_64.tar.gz | tar xz --strip-components=1 -C /usr
- run: swift -version
Expand Down
18 changes: 11 additions & 7 deletions .github/workflows/jazzy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Jazzy
on:
push:
branches: [main]
paths:
paths:
- '.github/workflows/jazzy.yml'
- '.jazzy.yaml'
- '**/*.md'
Expand All @@ -12,7 +12,7 @@ on:
- 'Package*'
- 'Sources/**/*.swift'
pull_request:
paths:
paths:
- '.github/workflows/jazzy.yml'
- '.jazzy.yaml'
- '**/*.md'
Expand All @@ -21,21 +21,25 @@ on:
- 'Package*'
- 'Sources/**/*.swift'

concurrency:
group: jazzy-${{ github.ref }}
cancel-in-progress: true

jobs:
Jazzy:
runs-on: macos-13
runs-on: macos-14
env:
DEVELOPER_DIR: /Applications/Xcode_15.0.app
DEVELOPER_DIR: /Applications/Xcode_15.4.app
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install SourceKitten
run: brew install sourcekitten
- run: swift build
- name: Generate documentation json
run: sourcekitten doc --spm --module-name Yams > yams.json
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.5
ruby-version: 3.3.3
bundler-cache: true
- name: Run jazzy
run: bundle exec jazzy --clean --sourcekitten-sourcefile yams.json
Expand All @@ -47,7 +51,7 @@ jobs:
exit 1
fi
- name: Upload Artifact
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: API Docs
path: docs
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Nightly
on:
push:
branches: [main]
paths:
paths:
- '.github/workflows/nightly.yml'
- 'Package*'
- 'Sources/**/*.[ch]'
Expand All @@ -12,7 +12,7 @@ on:
- 'Tests/**/*.swift'
- 'Tests/**/*.ya?ml'
pull_request:
paths:
paths:
- '.github/workflows/nightly.yml'
- 'Package*'
- 'Sources/**/*.[ch]'
Expand All @@ -23,13 +23,17 @@ on:
schedule:
- cron: '0 4 * * *'

concurrency:
group: nightly-${{ github.ref }}
cancel-in-progress: true

jobs:
Nightly:
runs-on: ubuntu-latest
container:
image: swiftlang/swift:nightly
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: swift --version
- run: YAMS_DEFAULT_ENCODING=UTF16 swift test --parallel
- run: YAMS_DEFAULT_ENCODING=UTF8 swift test --parallel
14 changes: 9 additions & 5 deletions .github/workflows/pod_lib_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,31 @@ name: pod lib lint
on:
push:
branches: [main]
paths:
paths:
- '.github/workflows/pod_lib_lint.yml'
- '*.podspec'
- 'Gemfile*'
- 'Sources/**/*.[ch]'
- 'Sources/**/*.swift'
pull_request:
paths:
paths:
- '.github/workflows/pod_lib_lint.yml'
- '*.podspec'
- 'Gemfile*'
- 'Sources/**/*.[ch]'
- 'Sources/**/*.swift'

concurrency:
group: pod-lib-lint-${{ github.ref }}
cancel-in-progress: true

jobs:
pod_lib_lint:
name: pod lib lint
runs-on: macos-13
runs-on: macos-14
env:
DEVELOPER_DIR: /Applications/Xcode_14.3.app
DEVELOPER_DIR: /Applications/Xcode_15.4.app
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: bundle install --path vendor/bundle
- run: bundle exec pod lib lint --verbose
6 changes: 5 additions & 1 deletion .github/workflows/swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ on:
- '.swiftlint.yml'
- '**/*.swift'

concurrency:
group: swiftlint-${{ github.ref }}
cancel-in-progress: true

jobs:
SwiftLint:
runs-on: ubuntu-latest
container:
image: ghcr.io/realm/swiftlint:0.54.0
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: SwiftLint
run: swiftlint lint --strict
12 changes: 8 additions & 4 deletions .github/workflows/swiftlint_analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: SwiftLint Analyze
on:
push:
branches: [main]
paths:
paths:
- '.github/workflows/swiftlint_analyze.yml'
- 'Yams.xcodeproj/**'
- 'Sources/**/*.[ch]'
Expand All @@ -19,13 +19,17 @@ on:
- 'Tests/**/*.swift'
- '!Tests/LinuxMain.swift'

concurrency:
group: swiftlint-analyze-${{ github.ref }}
cancel-in-progress: true

jobs:
Analyze:
runs-on: macos-13
runs-on: macos-14
env:
DEVELOPER_DIR: /Applications/Xcode_15.0.app
DEVELOPER_DIR: /Applications/Xcode_15.4.app
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Generate xcodebuild.log
run: xcodebuild -sdk macosx -scheme Yams -project Yams.xcodeproj clean build-for-testing > xcodebuild.log
shell: bash
Expand Down
55 changes: 28 additions & 27 deletions .github/workflows/swiftpm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,47 +23,54 @@ on:
- 'Tests/**/*.swift'
- 'Tests/**/*.ya?ml'

concurrency:
group: swiftpm-${{ github.ref }}
cancel-in-progress: true

jobs:
Xcode:
Xcode_Monterey:
name: macOS 12 with Xcode ${{ matrix.xcode_version }}
strategy:
matrix:
xcode_version: ['12.5.1', '13.0', '13.1', '13.2.1']
runs-on: macos-11
xcode_version: ['13.3.1', '13.4', '14.0.1', '14.1', '14.2']
runs-on: macos-12
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode_version }}.app
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: swift -version
- run: YAMS_DEFAULT_ENCODING=UTF16 swift test --parallel
- run: YAMS_DEFAULT_ENCODING=UTF8 swift test --parallel

Xcode_Monterey:
Xcode_Ventura:
name: macOS 13 with Xcode ${{ matrix.xcode_version }}
strategy:
matrix:
xcode_version: ['13.3.1', '13.4', '14.0.1', '14.1', '14.2']
runs-on: macos-12
xcode_version: ['14.3', '15.0']
runs-on: macos-13
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode_version }}.app
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: swift -version
- run: YAMS_DEFAULT_ENCODING=UTF16 swift test --parallel
- run: YAMS_DEFAULT_ENCODING=UTF8 swift test --parallel

Xcode_Ventura:
Xcode_Sonoma:
name: macOS 14 with Xcode ${{ matrix.xcode_version }}
strategy:
matrix:
xcode_version: ['14.3', '15.0']
runs-on: macos-13
xcode_version: ['15.4']
runs-on: macos-14
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode_version }}.app
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: swift -version
- run: YAMS_DEFAULT_ENCODING=UTF16 swift test --parallel
- run: YAMS_DEFAULT_ENCODING=UTF8 swift test --parallel
- name: Code Coverage
if: matrix.xcode_version == '15.0'
if: matrix.xcode_version == '15.4'
run: |
swift test --enable-code-coverage
xcrun llvm-cov export -format="lcov" .build/debug/YamsPackageTests.xctest/Contents/MacOS/YamsPackageTests -instr-profile .build/debug/codecov/default.profdata > coverage.lcov
Expand All @@ -73,36 +80,30 @@ jobs:
env: { 'CODECOV_TOKEN': '${{ secrets.CODECOV_TOKEN }}' }

Linux:
name: Linux with Swift ${{ matrix.tag }}
strategy:
matrix:
tag: ['5.4', '5.5', '5.6', '5.7', '5.8', '5.9', '5.10']
tag: ['5.7', '5.8', '5.9', '5.10']
runs-on: ubuntu-latest
container:
image: swift:${{ matrix.tag }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: YAMS_DEFAULT_ENCODING=UTF16 swift test --parallel
- run: YAMS_DEFAULT_ENCODING=UTF8 swift test --parallel

Windows:
name: Windows with Swift ${{ matrix.swift_version }}
runs-on: windows-latest

strategy:
matrix:
include:
- branch: swift-5.6.3-release
tag: 5.6.3-RELEASE
- branch: swift-5.7.2-release
tag: 5.7.2-RELEASE
- branch: development
tag: DEVELOPMENT-SNAPSHOT-2021-11-20-a

swift_version: ['5.7.3', '5.8.1', '5.9.1', '5.10.1']
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: compnerd/gha-setup-swift@main
with:
branch: ${{ matrix.branch }}
tag: ${{ matrix.tag }}
branch: swift-${{ matrix.swift_version }}-release
tag: ${{ matrix.swift_version }}-RELEASE
# Commands to run once connected via SSH:
#
# >d:
Expand Down
Loading

0 comments on commit 98650c6

Please sign in to comment.