setup veresion for pytest #2336
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches-ignore: | |
- 'main' | |
env: | |
BUILDER_VERSION: v0.9.52 | |
BUILDER_SOURCE: releases | |
BUILDER_HOST: https://d19elf31gohf1l.cloudfront.net | |
PACKAGE_NAME: aws-crt-swift | |
RUN: ${{ github.run_id }}-${{ github.run_number }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: us-east-1 | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: GitHub Action for SwiftLint | |
uses: norio-nomura/action-swiftlint@3.2.1 | |
linux: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
image: | |
- ubuntu-x64 | |
- al2-x64 | |
# issue to fix centos opened against apple here: https://github.com/apple/swift-docker/issues/258 | |
# - centos-x64 | |
steps: | |
- name: Build ${{ env.PACKAGE_NAME }} | |
run: | | |
aws s3 cp --debug s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh | |
./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-swift-5-${{ matrix.image }} build -p ${{ env.PACKAGE_NAME }} | |
osx: | |
runs-on: ${{ matrix.runner }} | |
env: | |
DEVELOPER_DIR: /Applications/Xcode.app | |
XCODE_DESTINATION: 'OS X' | |
NSUnbufferedIO: YES | |
strategy: | |
fail-fast: false | |
matrix: | |
# This matrix runs tests on Mac, on oldest & newest supported Xcodes | |
runner: | |
- macos-12 | |
- macos-13 | |
- macos-14 | |
- macos-13-xlarge | |
- macos-14-xlarge | |
steps: | |
- name: Build ${{ env.PACKAGE_NAME }} + consumers | |
run: | | |
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')" | |
chmod a+x builder | |
./builder build -p ${{ env.PACKAGE_NAME }} | |
ios-integration-test: | |
runs-on: macos-14 | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
env: | |
DEVELOPER_DIR: /Applications/Xcode.app | |
XCODE_DESTINATION: 'OS X' | |
NSUnbufferedIO: YES | |
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.MOBILEPROVISION_BASE64 }} | |
KEYCHAIN_PASSWORD: ${{ secrets.TEST_KEYCHAIN_PASSWORD }} | |
CI_TEST_SECRET_MANAGER_ROLE: arn:aws:iam::976188456881:role/CI_TEST_PROVIDER_ASSUME_ROLE | |
steps: | |
- name: Build ${{ env.PACKAGE_NAME }} + consumers | |
run: | | |
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')" | |
chmod a+x builder | |
./builder build -p ${{ env.PACKAGE_NAME }} | |
- name: configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
role-to-assume: ${{ env.CI_TEST_SECRET_MANAGER_ROLE }} | |
aws-region: us-east-1 | |
- name: Install the Apple certificate and provisioning profile | |
run: | | |
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12 | |
PP_PATH=$RUNNER_TEMP/mqttclient.mobileprovision | |
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db | |
pkcs12_identity_base64=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/test/base64_pkcs12" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") | |
pkcs12_identity_pw=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/test/pw_pkcs12" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") | |
provision_base64=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/test/provision_base64" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") | |
# import certificate and provisioning profile from secrets | |
echo -n "$pkcs12_identity_base64" | base64 --decode -o $CERTIFICATE_PATH | |
echo -n "$provision_base64" | base64 --decode -o $PP_PATH | |
# create temporary keychain | |
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH | |
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH | |
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH | |
# import certificate to keychain | |
security import $CERTIFICATE_PATH -P "$pkcs12_identity_pw" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH | |
security list-keychain -d user -s $KEYCHAIN_PATH | |
# apply provisioning profile | |
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles | |
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles | |
- name: Buil Test App | |
run: | | |
xcode-select --print-path | |
pwd | |
cd aws-crt-swift/Test/IntegrationTests/MqttClient | |
pwd | |
xcodebuild -resolvePackageDependencies | |
echo "start build app" | |
xcodebuild -scheme "MqttClient" \ | |
-archivePath $RUNNER_TEMP/MqttClient.xcarchive \ | |
-configuration Release \ | |
-destination generic/platform=iOS \ | |
clean archive -allowProvisioningUpdates | |
- name: Export ipa | |
run: | | |
cd aws-crt-swift/Test/IntegrationTests/MqttClient | |
exportFileData=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/iOSApp/exportOption" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") | |
echo -n "$exportFileData" | base64 --decode -o ExportOptions.plist | |
xcodebuild -exportArchive -archivePath $RUNNER_TEMP/MqttClient.xcarchive -exportOptionsPlist ExportOptions.plist -exportPath output | |
cd output | |
ls | |
- name: Setup Device Farm test file and environment | |
# Device Farm Instructions: https://docs.aws.amazon.com/devicefarm/latest/developerguide/test-types-appium.html | |
run: | | |
cd aws-crt-swift/Test/IntegrationTests/MqttClient | |
pwd | |
pip install virtualenv | |
virtualenv --help | |
virtualenv workspace | |
cd workspace | |
source bin/activate | |
pip install -r ../DeviceFarmScript/requirements.txt | |
# Create a test bundle folder for upload | |
mkdir tests | |
cp ../DeviceFarmScript/mqtt_ios_test.py tests/ | |
find tests/ | |
py.test --collect-only tests/ | |
cd tests/ | |
find . -name '__pycache__' -type d -exec rm -r {} + | |
find . -name '*.pyc' -exec rm -f {} + | |
find . -name '*.pyo' -exec rm -f {} + | |
find . -name '*~' -exec rm -f {} + | |
cd .. | |
pip freeze > requirements.txt | |
zip -r test_bundle.zip tests/ requirements.txt | |
- name: configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
role-to-assume: arn:aws:iam::976188456881:role/CI_DEVICE_FARM_ROLE | |
aws-region: us-west-2 | |
- name: Execute device farm test | |
run: | | |
cd aws-crt-swift/Test/IntegrationTests/MqttClient | |
pip install -r ./DeviceFarmScript/requirements.txt | |
ls | |
python ./DeviceFarmScript/run_ios_ci.py \ | |
--run_id ${{ github.run_id }} \ | |
--run_attempt ${{ github.run_attempt }} \ | |
--project_arn $(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/DeviceFarm/ProjectArn" --query "SecretString" | cut -f2 -d\") \ | |
--device_pool_arn $(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/DeviceFarm/iOS13PoolArn" --query "SecretString" | cut -f2 -d\") \ | |
--app_file_path ./output/MqttClient.ipa \ | |
--test_file_path ./workspace/test_bundle.zip \ | |
--test_spec_file_path ./DeviceFarmScript/test_spec.yml | |
devices: | |
runs-on: ${{ matrix.runner }} | |
env: | |
DEVELOPER_DIR: /Applications/${{ matrix.xcode }}.app/Contents/Developer | |
XCODE_DESTINATION: ${{matrix.target.destination}} | |
NSUnbufferedIO: YES | |
strategy: | |
fail-fast: false | |
matrix: | |
# This matrix runs tests on iOS, tvOS & watchOS, on oldest & newest supported Xcodes | |
runner: | |
- macos-12 | |
- macos-13 | |
- macos-14 | |
- macos-13-xlarge | |
- macos-14-xlarge | |
target: | |
[{ os: ios, destination: 'iOS Simulator,OS=16.1,name=iPhone 14'}, | |
{ os: ios, destination: 'iOS Simulator,OS=17.2,name=iPhone 15'}, | |
{ os: tvos, destination: 'tvOS Simulator,OS=16.1,name=Apple TV 4K (3rd generation) (at 1080p)'}, | |
{ os: tvos, destination: 'tvOS Simulator,OS=17.2,name=Apple TV 4K (3rd generation) (at 1080p)'}, | |
{ os: watchos, destination: 'watchOS Simulator,OS=10.2,name=Apple Watch SE (40mm) (2nd generation)'}, | |
{ os: watchos, destination: 'watchOS Simulator,OS=9.1,name=Apple Watch Series 5 (40mm)'}] | |
xcode: | |
- Xcode_14.1 | |
- Xcode_15.2 | |
exclude: | |
# Don't run old macOS with new Xcode | |
- runner: macos-13-xlarge | |
xcode: Xcode_15.2 | |
- runner: macos-12 | |
xcode: Xcode_15.2 | |
- runner: macos-13 | |
xcode: Xcode_15.2 | |
# Don't run new macOS with old Xcode | |
- runner: macos-14-xlarge | |
xcode: Xcode_14.1 | |
- runner: macos-14 | |
xcode: Xcode_14.1 | |
# Don't run old simulators with new Xcode | |
- target: { os: tvos, destination: 'tvOS Simulator,OS=16.1,name=Apple TV 4K (3rd generation) (at 1080p)'} | |
xcode: Xcode_15.2 | |
- target: { os: ios, destination: 'iOS Simulator,OS=16.1,name=iPhone 14'} | |
xcode: Xcode_15.2 | |
# Don't run new simulators with old Xcode | |
- target: { os: tvos, destination: 'tvOS Simulator,OS=17.2,name=Apple TV 4K (3rd generation) (at 1080p)'} | |
xcode: Xcode_14.1 | |
- target: { os: ios, destination: 'iOS Simulator,OS=17.2,name=iPhone 15'} | |
xcode: Xcode_14.1 | |
- target: { os: watchos, destination: 'watchOS Simulator,OS=10.2,name=Apple Watch SE (40mm) (2nd generation)'} | |
xcode: Xcode_14.1 | |
- target: { os: watchos, destination: 'watchOS Simulator,OS=9.1,name=Apple Watch Series 5 (40mm)'} | |
xcode: Xcode_15.2 | |
steps: | |
- name: Build ${{ env.PACKAGE_NAME }} + consumers | |
run: | | |
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')" | |
chmod a+x builder | |
./builder build -p ${{ env.PACKAGE_NAME }} --target=${{ matrix.target.os }}-armv8 | |
check-submodules: | |
runs-on: ubuntu-22.04 # latest | |
steps: | |
- name: Checkout Source | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- name: Check Submodules | |
# note: using "@main" because "@${{env.BUILDER_VERSION}}" doesn't work | |
# https://github.com/actions/runner/issues/480 | |
uses: awslabs/aws-crt-builder/.github/actions/check-submodules@main |