Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 41 additions & 28 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,50 @@ on:
pull_request:
branches: [ "main" ]

env:
XCODE_VERSION: '26'
XCODE_PROJECT: "HackerTube.xcodeproj"
SCHEME: "HackerTube"
TEST_PLAN: UnitTests
TEST_RESULT_BUNDLE: "TestResults.xcresult"

# iOS Simulator configuration
TEST_PLATFORM: 'iOS Simulator'
TEST_DEVICE_TYPE: 'iPhone 16'

jobs:
build:
name: Build and Test on iOS Simulator
runs-on: macos-latest

env:
XCODE_PROJECT: "HackerTube.xcodeproj"
SCHEME: "HackerTube"
PLATFORM: 'iOS Simulator'
DEVICE: 'iPhone 16'
TEST_PLAN: UnitTests
TEST_RESULT_BUNDLE: "TestResults.xcresult"
TEST_DEVICE_NAME: 'TestDevice'

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '26.0-beta'

- name: Test
run: |
set -o pipefail && xcodebuild test \
-project "${{ env.XCODE_PROJECT }}" \
-scheme ${{ env.SCHEME }} \
-testPlan "${{ env.TEST_PLAN }}" \
-resultBundlePath "${{ env.TEST_RESULT_BUNDLE }}" \
-destination "platform=${{ env.PLATFORM }},name=${{ env.DEVICE }}" | xcpretty

- name: Upload test result bundle
uses: actions/upload-artifact@v4
with:
name: ${{ env.SCHEME }}-${{ github.sha }}.xcresult
path: ${{ env.TEST_RESULT_BUNDLE }}
- name: Checkout
uses: actions/checkout@v6

- name: Set up Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ env.XCODE_VERSION }}

- name: Create iOS Simulator
run: |
xcrun simctl create "${{ env.TEST_DEVICE_NAME }}" "${{ env.TEST_DEVICE_TYPE }}"

- name: Test
run: |
xcodebuild test \
-project "${{ env.XCODE_PROJECT }}" \
-scheme ${{ env.SCHEME }} \
-testPlan "${{ env.TEST_PLAN }}" \
-resultBundlePath "${{ env.TEST_RESULT_BUNDLE }}" \
-destination "platform=${{ env.TEST_PLATFORM }},name=${{ env.TEST_DEVICE_NAME }}"

- name: Upload test result bundle
uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: ${{ env.SCHEME }}-${{ env.TEST_PLAN }}-${{ github.sha }}.xcresult
path: ${{ env.TEST_RESULT_BUNDLE }}