iOS C++ Unit Tests Bazel target & running on CI (#1534)

This commit is contained in:
Bart Louwers
2023-08-22 21:52:20 +02:00
committed by GitHub
parent e16995ec33
commit 32d65850c9
21 changed files with 308 additions and 155 deletions

View File

@@ -169,7 +169,7 @@ jobs:
cd Payload/RenderTestApp.app/PlugIns
zip -r "$render_test_app_dir"/RenderTest.xctest.zip RenderTest.xctest
echo render_test_artifacts_dir="$render_test_app_dir" >> "$GITHUB_ENV"
- uses: actions/upload-artifact@v3
with:
name: ios-render-test
@@ -177,3 +177,29 @@ jobs:
path: |
${{ env.render_test_artifacts_dir }}/RenderTest.xctest.zip
${{ env.render_test_artifacts_dir }}/RenderTestApp.ipa
# C++ unit tests
- name: Build CppUnitTests .ipa and .xctest for AWS Device Farm
run: |
set -e
bazel run //platform/ios:xcodeproj
build_dir="$(mktemp -d)"
xcodebuild build-for-testing -scheme CppUnitTests -project MapLibre.xcodeproj -derivedDataPath "$build_dir"
ios_cpp_test_app_dir="$(dirname "$(find "$build_dir" -name CppUnitTestsApp.app)")"
cd "$ios_cpp_test_app_dir"
mkdir Payload
mv CppUnitTestsApp.app Payload
zip -r CppUnitTestsApp.zip Payload
mv CppUnitTestsApp.zip CppUnitTestsApp.ipa
cd Payload/CppUnitTestsApp.app/PlugIns
zip -r "$ios_cpp_test_app_dir"/CppUnitTests.xctest.zip CppUnitTests.xctest
echo ios_cpp_test_artifacts_dir="$ios_cpp_test_app_dir" >> "$GITHUB_ENV"
- uses: actions/upload-artifact@v3
with:
name: ios-cpp-unit-tests
retention-days: 3
path: |
${{ env.ios_cpp_test_artifacts_dir }}/CppUnitTests.xctest.zip
${{ env.ios_cpp_test_artifacts_dir }}/CppUnitTestsApp.ipa

View File

@@ -1,4 +1,4 @@
name: ios-render-test
name: ios-device-test
on:
workflow_run:
@@ -7,7 +7,15 @@ on:
- completed
jobs:
ios-render-test:
ios-device-test:
strategy:
matrix:
test: [
{artifactName: ios-render-test, xcTestFile: RenderTest.xctest.zip, ipaFile: RenderTestApp.ipa, name: "iOS Render Tests"},
{artifactName: ios-cpp-unit-tests, xcTestFile: CppUnitTests.xctest.zip, ipaFile: CppUnitTestsApp.ipa, name: "iOS C++ Unit Tests"},
]
max-parallel: 1
fail-fast: true
runs-on: ubuntu-22.04
if: github.repository_owner == 'maplibre'
steps:
@@ -15,9 +23,8 @@ jobs:
- uses: ./.github/actions/download-workflow-run-artifact
with:
artifact-name: ios-render-test
expect-files: "RenderTest.xctest.zip, RenderTestApp.ipa"
artifact-name: ${{ matrix.test.artifactName }}
expect-files: "${{ matrix.test.xcTestFile }}, ${{ matrix.test.ipaFile }}"
- name: Generate token
id: generate_token
@@ -32,7 +39,7 @@ jobs:
token: ${{ steps.generate_token.outputs.token }}
details_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
status: in_progress
name: iOS Render Test
name: ${{ matrix.test.name }}
sha: ${{ github.event.workflow_run.head_sha }}
- name: Configure AWS Credentials
@@ -47,7 +54,7 @@ jobs:
- name: Create upload app
run: |
response=$(aws devicefarm create-upload --type IOS_APP --name RenderTestApp.ipa --project-arn ${{ vars.AWS_DEVICE_FARM_PROJECT_ARN }})
response=$(aws devicefarm create-upload --type IOS_APP --name ${{ matrix.test.ipaFile }} --project-arn ${{ vars.AWS_DEVICE_FARM_PROJECT_ARN }})
echo "$response"
arn="$(jq -r '.upload.arn' <<< "$response")"
url="$(jq -r '.upload.url' <<< "$response")"
@@ -56,17 +63,17 @@ jobs:
- name: Create upload test package
run: |
response=$(aws devicefarm create-upload --type XCTEST_TEST_PACKAGE --name RenderTest.xctest.zip --project-arn ${{ vars.AWS_DEVICE_FARM_PROJECT_ARN }})
response=$(aws devicefarm create-upload --type XCTEST_TEST_PACKAGE --name ${{ matrix.test.xcTestFile }} --project-arn ${{ vars.AWS_DEVICE_FARM_PROJECT_ARN }})
echo "$response"
arn="$(jq -r '.upload.arn' <<< "$response")"
url="$(jq -r '.upload.url' <<< "$response")"
echo "test_package_arn=$arn" >> "$GITHUB_ENV"
echo "test_package_url=$url" >> "$GITHUB_ENV"
- name: Upload iOS Render test
- name: Upload ${{ matrix.test.name }}
run: |
curl -T RenderTestApp.ipa "${{ env.app_url }}"
curl -T RenderTest.xctest.zip "${{ env.test_package_url }}"
curl -T ${{ matrix.test.ipaFile }} "${{ env.app_url }}"
curl -T ${{ matrix.test.xcTestFile }} "${{ env.test_package_url }}"
max_checks=10
sleep_time=5
@@ -92,7 +99,7 @@ jobs:
- name: Schedule test run
uses: realm/aws-devicefarm/test-application@master
with:
name: MapLibre Native iOS Render Test
name: MapLibre Native ${{ matrix.test.name }}
project_arn: ${{ vars.AWS_DEVICE_FARM_PROJECT_ARN }}
device_pool_arn: ${{ vars.AWS_DEVICE_FARM_IPHONE_DEVICE_POOL_ARN }}
app_arn: ${{ env.app_arn }}