Skip to content

Commit

Permalink
Add iOS Testing Step (#31)
Browse files Browse the repository at this point in the history
* Add step to run tests on iOS

* Allow xcodebuild command to be overwritten

* Rename action and actually use it

* Use macOS 15 runners
  • Loading branch information
0xTim authored Oct 12, 2024
1 parent 1b12943 commit 89ea871
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/run-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ on:
required: false
default: false
description: "Set to 'true' to build with the Static Linux SDK to test MUSL compatibility. Defaults to 'false'."
ios_scheme_name:
type: string
required: false
default: ''
description: "Set to the scheme name in Xcode to run tests on iOS. Defaults to '' which won't run any tests."
extra_flags:
type: string
required: false
Expand All @@ -67,6 +72,11 @@ on:
required: false
default: ''
description: "Additional 'swift build' flags to be applied on when compiling with MUSL."
ios_xcodebuild_action:
type: string
required: false
default: 'test'
description: "Action to pass to xcodebuild when running iOS tests. Defaults to 'test'. Set to '' to just compile and not run tests."
secrets:
CODECOV_TOKEN:
required: false
Expand All @@ -78,6 +88,8 @@ env:
WARNINGS_AS_ERRORS: ${{ inputs.warnings_as_errors && '-Xswiftc -warnings-as-errors' || '' }}
TEST_FILTER: ${{ inputs.test_filter != '' && format('--filter={0}', inputs.test_filter) || '' }}
WITH_COVERAGE: ${{ inputs.with_coverage && '--enable-code-coverage' || '' }}
IOS_SCHEME_NAME: ${{ inputs.ios_scheme_name }}
IOS_XCODEBUILD_ACTION: ${{ inputs.ios_xcodebuild_action }}

jobs:
api-breakage:
Expand Down Expand Up @@ -224,6 +236,19 @@ jobs:
run: |
swift test ${PACKAGE_ROOT} ${WITH_TSAN} ${TEST_FILTER} ${EXTRA_FLAGS}
ios-unit:
if: ${{ !(github.event.pull_request.draft || false) && inputs.ios_scheme_name != '' }}
runs-on: macos-15
steps:
- name: Select appropriate Xcode version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Check out code
uses: actions/checkout@v4
- name: Run iOS Tests
run: xcodebuild ${IOS_XCODEBUILD_ACTION} -scheme ${IOS_SCHEME_NAME} -destination 'platform=iOS Simulator,OS=18.0,name=iPhone 16 Pro'

lint:
if: ${{ inputs.with_linting }}
runs-on: ubuntu-latest
Expand Down

0 comments on commit 89ea871

Please sign in to comment.