Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
dianaafanador3 committed Dec 13, 2023
1 parent 9cd36e7 commit d071895
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 57 deletions.
139 changes: 85 additions & 54 deletions .github/workflows/master-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ on:
branches:
- "master"
env:
XCODE_VERSION: "['15.1']" # '14.1', '14.2', '14.3.1', '15.0.1', '15.1'
PLATFORM: "['ios']" # , 'osx', 'watchos', 'tvos', 'catalyst', visionos'
BUILD_PLATFORM: "['ios', 'iossimulator']" # , 'osx', 'watchos', 'watchossimulator', 'tvos', 'tvossimulator', 'catalyst'
XCODE_VERSION: "['14.1', '14.2', '14.3.1', '15.0.1', '15.1']"
PLATFORM: "['ios', 'osx', 'watchos', 'tvos', 'catalyst', visionos']"
BUILD_PLATFORM: "['ios', 'iossimulator', 'osx', 'watchos', 'watchossimulator', 'tvos', 'tvossimulator', 'catalyst']"
DOC_VERSION: '14.3.1'
XCFRAMEWORK_VERSION: '15.0.1'
REALM_VERSION: '15.1'
TEST_VERSION: '15.0.1'
jobs:
prepare:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -111,7 +112,7 @@ jobs:
run: |
workflow_id=$(echo $(ruby ./scripts/xcode_cloud_helper.rb --create-build-workflow "${{ matrix.platform }}-${{ matrix.target }}-${{ matrix.configuration }}" --token ${{ steps.token.outputs.token }} --xcode-version ${{ matrix.xcode-version }}))
echo "WORKFLOW_ID=$workflow_id" >> $GITHUB_OUTPUT
- name: Runs the XCode Cloud workflow created by the prevous step which that a package for ${{ matrix.platform }} in ${{ matrix.xcode-version }} with configuration ${{ matrix.configuration }}
- name: Runs the XCode Cloud workflow created by the previous step
id: build-run
run: |
build_run_id=$(echo $(ruby ./scripts/xcode_cloud_helper.rb --run-release-workflow ${{ steps.create-workflow.outputs.WORKFLOW_ID }} --token ${{ steps.token.outputs.token }} --branch ${{ github.ref_name }}))
Expand Down Expand Up @@ -405,8 +406,19 @@ jobs:
key id: ${{ secrets.APPLE_STORE_CONNECT_KEY_ID }}
# P8 private key. Can get from App Store Connect.
key: ${{ secrets.APPLE_STORE_CONNECT_API_KEY }}
- name: Run release_ios-static_15.1 which runs test over the packages produces by the previous step and wait for it to complete or fail
run: ruby ./scripts/xcode_cloud_helper.rb --run-release-workflow release_test-ios-static_15.1 --token ${{ steps.token.outputs.token }}
- name: Creates on demand XCode Cloud's workflows for running ios-static test
id: create-workflow
run: |
workflow_id=$(echo $(ruby ./scripts/xcode_cloud_helper.rb --create-test-workflow "ios-static-${{ env.TEST_VERSION }}" --token ${{ steps.token.outputs.token }} --xcode-version ${{ env.TEST_VERSION }}))
echo "WORKFLOW_ID=$workflow_id" >> $GITHUB_OUTPUT
- name: Runs the XCode Cloud workflow created by the previous step
id: build-run
run: |
build_run_id=$(echo $(ruby ./scripts/xcode_cloud_helper.rb --run-release-workflow ${{ steps.create-workflow.outputs.WORKFLOW_ID }} --token ${{ steps.token.outputs.token }} --branch ${{ github.ref_name }}))
echo "BUILD_RUN_ID=$build_run_id" >> $GITHUB_OUTPUT
- name: Check build status and wait for it to finish
run: |
ruby ./scripts/xcode_cloud_helper.rb --token ${{ steps.token.outputs.token }} --check-workflow-status ${{ steps.build-run.outputs.BUILD_RUN_ID }}
test-osx-static:
runs-on: ubuntu-latest
name: Run tests on macOS
Expand All @@ -424,14 +436,23 @@ jobs:
key id: ${{ secrets.APPLE_STORE_CONNECT_KEY_ID }}
# P8 private key. Can get from App Store Connect.
key: ${{ secrets.APPLE_STORE_CONNECT_API_KEY }}
- name: Run release_osx_15.1 which runs test over the packages produces by the previous step and wait for it to complete or fail
run: ruby ./scripts/xcode_cloud_helper.rb --run-release-workflow release_test-osx_15.1 --token ${{ steps.token.outputs.token }}
- name: Creates on demand XCode Cloud's workflows for running osx-static test
id: create-workflow
run: |
workflow_id=$(echo $(ruby ./scripts/xcode_cloud_helper.rb --create-test-workflow "osx-static-${{ env.TEST_VERSION }}" --token ${{ steps.token.outputs.token }} --xcode-version ${{ env.TEST_VERSION }}))
echo "WORKFLOW_ID=$workflow_id" >> $GITHUB_OUTPUT
- name: Runs the XCode Cloud workflow created by the previous step
id: build-run
run: |
build_run_id=$(echo $(ruby ./scripts/xcode_cloud_helper.rb --run-release-workflow ${{ steps.create-workflow.outputs.WORKFLOW_ID }} --token ${{ steps.token.outputs.token }} --branch ${{ github.ref_name }}))
echo "BUILD_RUN_ID=$build_run_id" >> $GITHUB_OUTPUT
- name: Check build status and wait for it to finish
run: |
ruby ./scripts/xcode_cloud_helper.rb --token ${{ steps.token.outputs.token }} --check-workflow-status ${{ steps.build-run.outputs.BUILD_RUN_ID }}
test-installation:
runs-on: ubuntu-latest
name: Run installation test for ${{ matrix.platform }}, ${{ matrix.installation }} and ${{ matrix.linkage }}
name: Run installation test
needs: create-final-package
env:
XCODE_VERSION: '14.3.1'
strategy:
matrix:
platform: [ios, osx, watchos, tvos, catalyst]
Expand All @@ -455,48 +476,58 @@ jobs:
key id: ${{ secrets.APPLE_STORE_CONNECT_KEY_ID }}
# P8 private key. Can get from App Store Connect.
key: ${{ secrets.APPLE_STORE_CONNECT_API_KEY }}
- name: Creates an XCode Cloud workflow to run the test and runs build
- name: Creates on demand XCode Cloud's workflows to run installation test for ${{ matrix.platform }}, ${{ matrix.installation }}, ${{ matrix.linkage }}
id: create-workflow
run: |
ruby ./scripts/xcode_cloud_helper.rb --create-release-workflow-and-run test-installation-${{ matrix.platform }}-${{ matrix.installation }}-${{ matrix.linkage }} --xcode-version "$XCODE_VERSION" --token ${{ steps.token.outputs.token }} --team-id ${{ secrets.APPLE_STORE_CONNECT_TEAM_ID }}
test-installation-xcode: # we run this installation tests separatly because we need xcode cloud workflows previsously created with a GITHUB token so we can download the release package for this tests
runs-on: ubuntu-latest
name: Run installation xcframework ${{ matrix.platform }}, ${{ matrix.linkage }} in ${{ matrix.xcode_version }}
needs: create-final-package
strategy:
max-parallel: 5
matrix:
platform: [osx]
xcode_version: ['14.1', '14.2', '14.3.1', '15.0.1', '15.1']
linkage: [dynamic]
include:
- platform: ios
xcode_version: '14.3.1'
linkage: dynamic
- platform: watchos
xcode_version: '14.3.1'
linkage: dynamic
- platform: tvos
xcode_version: '14.3.1'
linkage: dynamic
- platform: catalyst
xcode_version: '14.3.1'
linkage: dynamic
- platform: ios
installation: '14.3.1'
linkage: static
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Token
id: token
uses: yuki0n0/[email protected]
with:
# UUID. Can get from App Store Connect.
issuer id: ${{ secrets.APPLE_STORE_CONNECT_ISSUER_ID }}
# Key ID. Can get from App Store Connect.
key id: ${{ secrets.APPLE_STORE_CONNECT_KEY_ID }}
# P8 private key. Can get from App Store Connect.
key: ${{ secrets.APPLE_STORE_CONNECT_API_KEY }}
- name: Run installation tests for ${{ matrix.platform }} xcframework ${{ matrix.linkage }} in xcode version ${{ matrix.xcode-version }}
workflow_id=$(echo $(ruby ./scripts/xcode_cloud_helper.rb --create-test-workflow "test-installation-${{ matrix.platform }}-${{ matrix.installation }}-${{ matrix.linkage }}" --token ${{ steps.token.outputs.token }} --xcode-version ${{ env.TEST_VERSION }}))
echo "WORKFLOW_ID=$workflow_id" >> $GITHUB_OUTPUT
- name: Runs the XCode Cloud workflow created by the previous step
id: build-run
run: |
ruby ./scripts/xcode_cloud_helper.rb --run-release-workflow "release_test-installation-${{ matrix.platform }}-xcframework-${{ matrix.linkage }}_${{ matrix.xcode-version }}" --token ${{ steps.token.outputs.token }}
build_run_id=$(echo $(ruby ./scripts/xcode_cloud_helper.rb --run-release-workflow ${{ steps.create-workflow.outputs.WORKFLOW_ID }} --token ${{ steps.token.outputs.token }} --branch ${{ github.ref_name }}))
echo "BUILD_RUN_ID=$build_run_id" >> $GITHUB_OUTPUT
- name: Check build status and wait for it to finish
run: |
ruby ./scripts/xcode_cloud_helper.rb --token ${{ steps.token.outputs.token }} --check-workflow-status ${{ steps.build-run.outputs.BUILD_RUN_ID }}
# test-installation-xcode: # we run this installation tests separatly because we need xcode cloud workflows previsously created with a GITHUB token so we can download the release package for this tests
# runs-on: ubuntu-latest
# name: Run installation xcframework ${{ matrix.platform }}, ${{ matrix.linkage }} in ${{ matrix.xcode_version }}
# needs: create-final-package
# strategy:
# max-parallel: 5
# matrix:
# platform: [osx]
# xcode_version: ['14.1', '14.2', '14.3.1', '15.0.1', '15.1']
# linkage: [dynamic]
# include:
# - platform: ios
# xcode_version: '14.3.1'
# linkage: dynamic
# - platform: watchos
# xcode_version: '14.3.1'
# linkage: dynamic
# - platform: tvos
# xcode_version: '14.3.1'
# linkage: dynamic
# - platform: catalyst
# xcode_version: '14.3.1'
# linkage: dynamic
# - platform: ios
# installation: '14.3.1'
# linkage: static
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Get Token
# id: token
# uses: yuki0n0/[email protected]
# with:
# # UUID. Can get from App Store Connect.
# issuer id: ${{ secrets.APPLE_STORE_CONNECT_ISSUER_ID }}
# # Key ID. Can get from App Store Connect.
# key id: ${{ secrets.APPLE_STORE_CONNECT_KEY_ID }}
# # P8 private key. Can get from App Store Connect.
# key: ${{ secrets.APPLE_STORE_CONNECT_API_KEY }}
# - name: Run installation tests for ${{ matrix.platform }} xcframework ${{ matrix.linkage }} in xcode version ${{ matrix.xcode-version }}
# run: |
# ruby ./scripts/xcode_cloud_helper.rb --run-release-workflow "release_test-installation-${{ matrix.platform }}-xcframework-${{ matrix.linkage }}_${{ matrix.xcode-version }}" --token ${{ steps.token.outputs.token }}
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ case "$COMMAND" in
sh build.sh examples-tvos-swift
;;

("release_test-ios")
("release-test-ios")
echo "Test run on test action"
;;

Expand Down
61 changes: 61 additions & 0 deletions scripts/release-matrix.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env ruby

module RELEASE
DOCS_XCODE_VERSION = '14.3.1'
XCODE_VERSIONS = ['14.1', '14.2', '14.3.1', '15.0.1', '15.1']
PLATFORMS_NAMES = ['osx': 'macOS', 'ios': 'iOS', 'watchos': 'watchOS', 'tvos': 'tvOS', 'catalyst': 'Catalyst', 'visionos': 'visionOS']

all = ->(v) { true }
latest_only = ->(v) { v == XCODE_VERSIONS.last }
doc_version = ->(v) { v == DOCS_XCODE_VERSION }

PLATFORMS = {
'osx' => all,
'ios' => all,
'watchos' => all,
'tvos' => all,
'catalyst' => all,
'visionos' => latest_only,
}

RELEASE_XCODE_CLOUD_TARGETS = {
'package-docs' => doc_version,
'package' => all,
'test-package-examples' => latest_only,
'test-ios-static' => latest_only,
'test-osx' => latest_only,
'test-installation-osx-xcframework-dynamic' => all,
'test-installation-ios-xcframework-dynamic' => doc_version,
'test-installation-watchos-xcframework-dynamic' => doc_version,
'test-installation-tvos-xcframework-dynamic' => doc_version,
'test-installation-catalyst-xcframework-dynamic' => doc_version,
'test-installation-ios-xcframework-static' => doc_version,
}
end

def get_doc_version
puts "#{RELEASE::DOCS_XCODE_VERSION}"
end

def plaforms_for_version(version)
platforms_version = []
RELEASE::PLATFORMS.each { |platform, filter|
if filter.call(version)
platforms_version.append(platform)
end
}
puts "#{platforms_version.join(",")}"
end

def get_xcode_versions
puts "#{RELEASE::XCODE_VERSIONS.join(",")}"
end

if ARGV[0] == 'docs_version'
get_doc_version
elsif ARGV[0] == 'plaforms_for_version'
version = ARGV[1]
plaforms_for_version(version)
elsif ARGV[0] == 'xcode_versions'
get_xcode_versions
end
13 changes: 11 additions & 2 deletions scripts/xcode_cloud_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,7 @@ def download_artifact_for_build(build_id_run)
[ '--run-release-workflow', GetoptLong::REQUIRED_ARGUMENT ],
[ '--check-workflow-status', GetoptLong::REQUIRED_ARGUMENT ],
[ '--create-build-workflow', GetoptLong::REQUIRED_ARGUMENT ],
[ '--create-test-workflow', GetoptLong::REQUIRED_ARGUMENT ],
[ '--download-build-artifact', GetoptLong::REQUIRED_ARGUMENT ],
[ '--get-token', GetoptLong::NO_ARGUMENT ]
)
Expand Down Expand Up @@ -938,7 +939,8 @@ def download_artifact_for_build(build_id_run)
Check workflow status
--create-build-workflow
Creates a workflow, runs it and wait for it to finish
--create-test-workflow
--download-build-artifact
Expand Down Expand Up @@ -977,7 +979,7 @@ def download_artifact_for_build(build_id_run)
if arg != ''
workflow_id = arg
end
when '--create-workflow', '--create-build-workflow'
when '--create-workflow', '--create-build-workflow', '--create-test-workflow'
if arg != ''
name = arg
end
Expand Down Expand Up @@ -1086,6 +1088,13 @@ def download_artifact_for_build(build_id_run)
workflow_id = create_workflow('build', name, xcode_version, "release-package-")
puts workflow_id
end
elsif option == '--create-test-workflow'
if name == '' || xcode_version == ''
raise 'Needs name and xcode version'
else
workflow_id = create_workflow('test', name, xcode_version, "release-")
puts workflow_id
end
elsif option == '--download-build-artifact'
if build_run_id == ''
raise 'Needs build id name to run.'
Expand Down

0 comments on commit d071895

Please sign in to comment.