Skip to content

Commit

Permalink
Migrate to Swift 5️⃣.9️⃣
Browse files Browse the repository at this point in the history
Migrate CI to macOS 14 image and Xcode 15.2 which contains Swift 5.9,
and migrate Danger CI to run on ubuntu 22.04.

https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#xcode

## Changes

- Update Xcode references to 15.2 and Swift references to 5.9.
  reasons.
- Update destination device to iPhone 15 Pro.
- Improve SwiftLint setup and fix warnings.
- Update `README.md`.
- Apply Xcode's recommended project settings.
- Improve SwiftLint setup:
  + Move SwiftLint run script to Alicerce target
  + Add SwiftLint as SPM plugin on Alicerce Package (via Package.swift)
- Improve CI:
  + Update GH Actions' versions
  + Specify SwiftLint version for Danger CI
  + Place DerivedData outside checkout folder
  + Enable SPM caching and artifact upload in CI
  + Always upload artifacts
  + Disable Package and Macro validation for CI
  + Add Homebrew bundle install and caching
  + Add multiple workarounds for Carthage validation
  + Cancel in progress PR builds on push
  • Loading branch information
p4checo committed Apr 24, 2024
1 parent 59bc699 commit bdc2b3c
Show file tree
Hide file tree
Showing 16 changed files with 431 additions and 102 deletions.
210 changes: 183 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@ on:
- master

env:
# https://github.com/actions/virtual-environments/blob/main/images/macos/macos-12-Readme.md#xcode
DEVELOPER_DIR: /Applications/Xcode_14.0.app/Contents/Developer
IOS_DESTINATION: "platform=iOS Simulator,name=iPhone 14 Pro,OS=latest"
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-Readme.md#xcode
DEVELOPER_DIR: "/Applications/Xcode_15.2.app/Contents/Developer"
IOS_DESTINATION: "platform=iOS Simulator,name=iPhone 15 Pro,OS=latest"

concurrency:
# cancel in progress jobs only from PRs, as run_id is unique
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true

jobs:
env-details:
name: Environment details
runs-on: macos-12
runs-on: macos-14
steps:
- name: xcode version
run: xcodebuild -version -sdk
Expand All @@ -28,22 +33,59 @@ jobs:
xcrun simctl delete unavailable
xcrun simctl list
- name: brew version
run: brew --version

build-test:
name: Build and Test
runs-on: macos-12
runs-on: macos-14
env:
WORKSPACE: Alicerce.xcworkspace
SCHEME: Alicerce
DERIVED_DATA_PATH: build
DERIVED_DATA_PATH: /tmp/DerivedData
SPM_CLONED_DEPENDENCIES_PATH: /tmp/spm-dependencies
RESULT_BUNDLE_PATH: build-test.xcresult
LOG_PATH: xcodebuild.log
steps:
- name: git checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: install xcbeautify
run: brew install xcbeautify
- name: set Homebrew cache path
run: |
HOMEBREW_CACHE_DIR="$(brew --cache)"
echo "Homebrew cache directory: $HOMEBREW_CACHE_DIR"
echo "HOMEBREW_CACHE_PATH=$HOMEBREW_CACHE_DIR" >> "$GITHUB_ENV"
- name: cache Homebrew
uses: actions/cache@v4
with:
save-always: true
path: ${{ env.HOMEBREW_CACHE_PATH }}
key: ${{ runner.os }}-brew-${{ hashFiles('**/Brewfile.lock.json') }}
restore-keys: ${{ runner.os }}-brew-

- name: install Homebrew formulas
run: |
brew update
brew bundle install
- name: cache SPM
uses: actions/cache@v4
with:
save-always: true
path: ${{ env.SPM_CLONED_DEPENDENCIES_PATH }}
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
restore-keys: ${{ runner.os }}-spm-

- name: cache DerivedData
uses: actions/cache@v4
with:
save-always: true
path: ${{ env.DERIVED_DATA_PATH }}
key: ${{ runner.os }}-DerivedData-${{ hashFiles('**/Package.resolved') }}
restore-keys: ${{ runner.os }}-DerivedData-

- name: unit tests
run: |
Expand All @@ -55,26 +97,76 @@ jobs:
-derivedDataPath "$DERIVED_DATA_PATH" \
-enableCodeCoverage YES \
-resultBundlePath "$RESULT_BUNDLE_PATH" \
-onlyUsePackageVersionsFromResolvedFile \
-skipPackagePluginValidation \
-skipMacroValidation \
-clonedSourcePackagesDirPath $SPM_CLONED_DEPENDENCIES_PATH \
| tee $LOG_PATH \
| xcbeautify
- name: codecov upload
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
plugin: xcode
file: ${{ env.RESULT_BUNDLE_PATH }}
token: ${{ secrets.CODECOV_TOKEN }}

- name: Archive artifacts
if: always()
uses: actions/upload-artifact@v4
with:
xcode: true
xcode_archive_path: ${{ env.RESULT_BUNDLE_PATH }}
name: artifacts
path: |
${{ env.RESULT_BUNDLE_PATH }}
${{ env.LOG_PATH }}
swiftpm:
name: SwiftPM Build
runs-on: macos-12
runs-on: macos-14
env:
WORKSPACE: Alicerce.xcworkspace
SCHEME: "Alicerce (SPM)"
DERIVED_DATA_PATH: /tmp/DerivedData
SPM_CLONED_DEPENDENCIES_PATH: /tmp/spm-dependencies
LOG_PATH: spm-xcodebuild.log
steps:
- name: git checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: set Homebrew cache path
run: |
HOMEBREW_CACHE_DIR="$(brew --cache)"
echo "Homebrew cache directory: $HOMEBREW_CACHE_DIR"
echo "HOMEBREW_CACHE_PATH=$HOMEBREW_CACHE_DIR" >> "$GITHUB_ENV"
- name: cache Homebrew
uses: actions/cache@v4
with:
save-always: true
path: ${{ env.HOMEBREW_CACHE_PATH }}
key: ${{ runner.os }}-brew-${{ hashFiles('**/Brewfile.lock.json') }}
restore-keys: ${{ runner.os }}-brew-

- name: install Homebrew formulas
run: |
brew update
brew bundle install
- name: install xcbeautify
run: brew install xcbeautify
- name: cache SPM
uses: actions/cache@v4
with:
save-always: true
path: ${{ env.SPM_CLONED_DEPENDENCIES_PATH }}
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
restore-keys: ${{ runner.os }}-spm-

- name: cache DerivedData
uses: actions/cache@v4
with:
save-always: true
path: ${{ env.DERIVED_DATA_PATH }}
key: ${{ runner.os }}-DerivedData-${{ hashFiles('**/Package.resolved') }}
restore-keys: ${{ runner.os }}-DerivedData-

- name: build
run: |
Expand All @@ -83,14 +175,27 @@ jobs:
-workspace "$WORKSPACE" \
-scheme "$SCHEME" \
-destination "$IOS_DESTINATION" \
-derivedDataPath $DERIVED_DATA_PATH \
-onlyUsePackageVersionsFromResolvedFile \
-skipPackagePluginValidation \
-skipMacroValidation \
-clonedSourcePackagesDirPath $SPM_CLONED_DEPENDENCIES_PATH \
| tee $LOG_PATH \
| xcbeautify
- name: Archive logs
if: always()
uses: actions/upload-artifact@v4
with:
name: spm-xcodebuild.log
path: ${{ env.LOG_PATH }}

cocoapods:
name: CocoaPods Verification
runs-on: macos-12
runs-on: macos-14
steps:
- name: git checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: ruby versions
run: |
Expand All @@ -99,7 +204,7 @@ jobs:
bundler --version
- name: cache gems
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: vendor/bundle
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
Expand All @@ -116,22 +221,73 @@ jobs:

carthage:
name: Carthage Verification
runs-on: macos-12
runs-on: macos-14
env:
# Use Xcode 15.3 (latest) for Carthage to avoid iOS device/simulator version mismatches
DEVELOPER_DIR: "/Applications/Xcode_15.3.app/Contents/Developer"
DERIVED_DATA_PATH: /tmp/DerivedData
LOG_PATH: carthage.log
steps:
- name: git checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: set Homebrew cache path
run: |
HOMEBREW_CACHE_DIR="$(brew --cache)"
echo "Homebrew cache directory: $HOMEBREW_CACHE_DIR"
echo "HOMEBREW_CACHE_PATH=$HOMEBREW_CACHE_DIR" >> "$GITHUB_ENV"
- name: cache Homebrew
uses: actions/cache@v4
with:
save-always: true
path: ${{ env.HOMEBREW_CACHE_PATH }}
key: ${{ runner.os }}-brew-${{ hashFiles('**/Brewfile.lock.json') }}
restore-keys: ${{ runner.os }}-brew-

- name: install Homebrew formulas
run: |
brew update
brew bundle install
- name: cache DerivedData
uses: actions/cache@v4
with:
save-always: true
path: ${{ env.DERIVED_DATA_PATH }}
key: ${{ runner.os }}-DerivedData-${{ hashFiles('**/Package.resolved') }}
restore-keys: ${{ runner.os }}-DerivedData-

- name: carthage build
run: ./script/carthage.sh build --cache-builds --no-skip-current
run: |
defaults write com.apple.dt.Xcode IDESkipPackagePluginFingerprintValidatation -bool YES
defaults write com.apple.dt.Xcode IDESkipMacroFingerprintValidation -bool YES
# remove SPM scheme because Carthage builds all shared schemes...
rm ".swiftpm/xcode/xcshareddata/xcschemes/Alicerce (SPM).xcscheme"
./script/carthage.sh build \
--cache-builds \
--no-skip-current \
--use-xcframeworks \
--derived-data $DERIVED_DATA_PATH \
--log-path $LOG_PATH
- name: Archive logs
if: always()
uses: actions/upload-artifact@v4
with:
name: carthage.log
path: ${{ env.LOG_PATH }}

release-github:
name: GitHub Release
runs-on: macos-12
runs-on: macos-14
needs: [build-test, swiftpm, cocoapods, carthage]
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: git checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: create release
uses: softprops/action-gh-release@v1
Expand All @@ -145,12 +301,12 @@ jobs:
release-cocoapods:
name: CocoaPods Release
runs-on: macos-12
runs-on: macos-14
needs: [build-test, swiftpm, cocoapods, carthage]
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: git checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: ruby versions
run: |
Expand All @@ -159,7 +315,7 @@ jobs:
bundler --version
- name: cache gems
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: vendor/bundle
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/danger-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:

Danger:
name: Danger Swift
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Danger
uses: 417-72KI/danger-swiftlint@v3
uses: 417-72KI/danger-swiftlint@v5.9
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
excluded:
- Carthage
- Carthage/
- Pods/
- Tests/
- Alicerce.playground/
reporter: "xcode"
disabled_rules:
- closure_parameter_position
- blanket_disable_command
- todo
- unused_optional_binding
- nesting
Expand Down Expand Up @@ -43,7 +44,6 @@ function_body_length:
error: 150
number_separator:
minimum_length: 5
empty_count: warning
superfluous_disable_command: warning
implicit_return:
included:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1240"
LastUpgradeVersion = "1520"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Alicerce.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
s.source = { :git => 'https://github.com/Mindera/Alicerce.git', :tag => "#{s.version}" }

s.module_name = 'Alicerce'
s.swift_version = '5.7'
s.swift_version = '5.9'

s.ios.deployment_target = '13.0'

Expand Down
Loading

0 comments on commit bdc2b3c

Please sign in to comment.