Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: test matrix workflow for optional SDKs #888

Merged
merged 49 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
d61f2d8
Setup nol pay package.swift
jnewc May 29, 2024
d46857e
Fix workflow
jnewc May 29, 2024
2f40d3c
Fix package.swift
jnewc May 29, 2024
9288ff5
workflow tweaks
jnewc May 29, 2024
81bf529
Workflow fixes
jnewc May 30, 2024
bde94ab
Update .gitignore
jnewc May 30, 2024
442b2e6
correct error in sdk-tests
jnewc May 30, 2024
c188c1f
Merge branch 'master' into jn/nol-pay-test
jnewc May 30, 2024
45542e2
Add optional sdk workflow
jnewc May 30, 2024
f062541
Fix action
jnewc May 30, 2024
c7f5612
Rework structure of tests and test packages
jnewc May 30, 2024
4aa84fd
Fix tests
jnewc May 30, 2024
80c943e
Move raw data manager typealias
jnewc May 30, 2024
9271522
Add Klarna to optional sdk workflow
jnewc May 30, 2024
58398e1
Adapt optional sdk workflow for separating coverage files
jnewc May 30, 2024
5211bea
fix vars in workflow
jnewc May 30, 2024
595dd3a
Add validation equatable extensions to test support
jnewc May 30, 2024
89bee41
Move mock api client to test support + delete empty file
jnewc May 30, 2024
06f309e
invalidSetting -> invalidValue in klarna test
jnewc May 30, 2024
5b2d90b
Tweak test plan + disable tests not mocked properly
jnewc May 30, 2024
5e02bf8
Remove build log archiving for optional sdk jobs
jnewc May 30, 2024
b6ce0fd
tweak coverage passing
jnewc May 30, 2024
d6eb627
tweak coverage passing 2
jnewc May 30, 2024
01c27c7
Remove ipay88 test
jnewc May 31, 2024
59073a2
Add 3DS package swift + tests
jnewc May 31, 2024
07564ae
Add 3DS to optional sdk workflow
jnewc May 31, 2024
a90b5e3
Remove debug app tests from unit tests plan due to cocoapods causing …
jnewc May 31, 2024
d4b5a6a
Remove duplicate test scheme
jnewc May 31, 2024
caece81
Split sdk and app test targets + workflow jobs
jnewc May 31, 2024
45cf062
Fix workflow fastlane test input
jnewc May 31, 2024
2cc149f
Fix app + core sdk test workflow
jnewc May 31, 2024
85976ca
Fix app test fastlane lane
jnewc Jun 3, 2024
bd6272e
Tweaks to workflow and fastfile
jnewc Jun 3, 2024
bab3ca9
pod reintegrate to fix build error
jnewc Jun 3, 2024
c5eabaa
pod install -> fastlane
jnewc Jun 3, 2024
ee77675
Reorganise workflow and re-enable sonar scanner
jnewc Jun 3, 2024
cb93c37
Update sonar action artifacts download
jnewc Jun 3, 2024
36927bf
add debug items to workflow
jnewc Jun 3, 2024
939ba4f
fix artifact paths
jnewc Jun 3, 2024
647fc20
Correct sonar xml path
jnewc Jun 4, 2024
e4f3cb6
Enable sonar debugging
jnewc Jun 4, 2024
85c94e2
Try glob format instead
jnewc Jun 4, 2024
0a51e2e
More debugging + fix test plans
jnewc Jun 4, 2024
7ce845c
important new line
jnewc Jun 4, 2024
32bf128
Revert coverage paths
jnewc Jun 4, 2024
982c3ab
Remove verbose sonar flag
jnewc Jun 4, 2024
973e40e
Tidy workflows
jnewc Jun 4, 2024
b6c6173
Add development package swift for use when testing all test-ready opt…
jnewc Jun 4, 2024
227e0e2
Tidy sonar props + update exclusions
jnewc Jun 4, 2024
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
36 changes: 22 additions & 14 deletions .github/actions/sdk-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ inputs:
fastlane-session:
description: Fastlane session
required: true
fastlane-test-lane:
description: The fastlane test lane to run
required: false
default: test_sdk
match-keychain-name:
description: Match keychain name
required: true
Expand All @@ -28,9 +32,13 @@ inputs:
source-branch:
description: Source branch
required: true
coverage-file-name:
description: Name of the generic coverage file
required: true
sdk-name:
description: The name of the SDK, if running SDK tests
required: false
package-swift:
description: The swift package file to use, if not default
required: false

runs:
using: "composite"
steps:
Expand All @@ -51,10 +59,16 @@ runs:
with:
ruby-version: "3.2"
bundler-cache: true
- name: Setup Package.swift
shell: bash
if: ${{ inputs.package-swift != '' }}
run: |
mv Package.swift Package.swift.orig
cp "${{ inputs.package-swift }}" Package.swift
- name: Build SPM App
shell: bash
run: |
bundle exec fastlane test_spm
bundle exec fastlane ${{ inputs.fastlane-test-lane }}
env:
MATCH_PASSWORD: ${{ inputs.match-password }}
MATCH_GIT_PRIVATE_KEY: ${{ inputs.ssh-private-key }}
Expand All @@ -63,19 +77,13 @@ runs:
MATCH_KEYCHAIN_NAME: ${{ inputs.match-keychain-name }}
MATCH_KEYCHAIN_PASSWORD: ${{ inputs.match-password }}
SOURCE_BRANCH: ${{ inputs.source-branch }}
- name: Archive log
uses: actions/upload-artifact@v4
if: always()
with:
name: fastlane-logs
path: /Users/runner/Library/Logs/scan/PrimerSDKTests.log
retention-days: 1
- name: Prepare coverage reports
shell: bash
if: ${{ inputs.sdk-name != '' }}
run: |
bash Scripts/xccov-to-sonarqube-generic.sh fastlane/test_output/PrimerSDKTests.xcresult/ > coverage.xml
sed "s#$PWD/##g" coverage.xml > ${{ inputs.coverage-file-name }}
sed "s#$PWD/##g" coverage.xml > sonar-coverage-${{ inputs.sdk-name }}.xml
- uses: actions/upload-artifact@master
with:
name: coverage-file
path: ${{ inputs.coverage-file-name }}
name: coverage-file-${{ inputs.sdk-name }}
path: sonar-coverage-${{ inputs.sdk-name }}.xml
8 changes: 4 additions & 4 deletions .github/actions/sonar/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ inputs:
sonar-host:
description: Sonar host URL
required: true
coverage-file-name:
coverage-file-names:
description: Name of the generic coverage file
required: true
branch:
Expand All @@ -29,9 +29,9 @@ inputs:
runs:
using: "composite"
steps:
- uses: actions/download-artifact@master
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e #v4.1.7
with:
name: coverage-file
pattern: coverage-file-*
- name: Install Sonar
shell: bash
run: |
Expand All @@ -43,7 +43,7 @@ runs:
echo "sonar.pullrequest.branch=${{ inputs.branch }}" >> sonar-project.properties
echo "sonar.pullrequest.base=${{ inputs.base-branch }}" >> sonar-project.properties
echo "sonar.scm.revision=${{ inputs.pull-request-sha }}" >> sonar-project.properties
echo "sonar.coverageReportPaths=${{ inputs.coverage-file-name }}" >> sonar-project.properties
echo "sonar.coverageReportPaths=${{ inputs.coverage-file-names }}" >> sonar-project.properties
- name: Run Sonar
shell: bash
run: |
Expand Down
78 changes: 70 additions & 8 deletions .github/workflows/build-test-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ concurrency:
cancel-in-progress: true

jobs:
unit-tests:
unit-tests-sdk:
runs-on: macos-13-large
timeout-minutes: 20
name: "Unit Tests"
name: "Unit Tests - SDK"
steps:
- name: Cancel previous jobs
uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1
Expand All @@ -35,20 +35,81 @@ jobs:
fastlane-password: ${{ secrets.FASTLANE_PASSWORD }}
match-keychain-name: ${{ secrets.MATCH_KEYCHAIN_NAME }}
match-keychain-password: ${{ secrets.MATCH_KEYCHAIN_PASSWORD }}
coverage-file-name: sonar-coverage.xml
sdk-name: sdk

optional-sdk-tests:
name: Optional SDK Tests
runs-on: macos-13-large
strategy:
max-parallel: 3
matrix:
package-swift:
- { name: 'nol-pay', file: 'Package.NolPay.swift' }
- { name: 'klarna', file: Package.Klarna.swift }
- { name: '3DS', file: Package.3DS.swift }
steps:
- name: Cancel previous jobs
uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1
with:
access_token: ${{ github.token }}
- name: Git - Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
ref: ${{ github.ref }}
- name: Run SDK tests
uses: ./.github/actions/sdk-tests
with:
ssh-private-key: ${{ secrets.SSH_KEY }}
known-hosts: ${{ secrets.KNOWN_HOSTS }}
match-password: ${{ secrets.MATCH_PASSWORD }}
match-git-private-key: ${{ secrets.FASTLANE_PASSWORD }}
fastlane-session: ${{ secrets.FASTLANE_SESSION }}
fastlane-password: ${{ secrets.FASTLANE_PASSWORD }}
match-keychain-name: ${{ secrets.MATCH_KEYCHAIN_NAME }}
match-keychain-password: ${{ secrets.MATCH_KEYCHAIN_PASSWORD }}
sdk-name: ${{ matrix.package-swift.name }}
package-swift: ${{ matrix.package-swift.file }}

unit-tests-debug-app:
runs-on: macos-13-large
timeout-minutes: 20
name: "Unit Tests - Debug App"
steps:
- name: Cancel previous jobs
uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1
with:
access_token: ${{ github.token }}
- name: Git - Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
ref: ${{ github.ref }}
- name: Run debug app tests
uses: ./.github/actions/sdk-tests
with:
ssh-private-key: ${{ secrets.SSH_KEY }}
known-hosts: ${{ secrets.KNOWN_HOSTS }}
match-password: ${{ secrets.MATCH_PASSWORD }}
match-git-private-key: ${{ secrets.FASTLANE_PASSWORD }}
fastlane-session: ${{ secrets.FASTLANE_SESSION }}
fastlane-password: ${{ secrets.FASTLANE_PASSWORD }}
match-keychain-name: ${{ secrets.MATCH_KEYCHAIN_NAME }}
match-keychain-password: ${{ secrets.MATCH_KEYCHAIN_PASSWORD }}
fastlane-test-lane: test_debug_app

sonarcloud:
needs:
- unit-tests
- unit-tests-sdk
- optional-sdk-tests
name: SonarCloud
runs-on: macos-13
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- uses: actions/download-artifact@master
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e #v4.1.7
with:
name: coverage-file
pattern: coverage-file-*
- run: mv coverage-file-*/sonar-coverage-*.xml ./
- name: SonarCloud Scan
uses: ./.github/actions/sonar
with:
Expand All @@ -59,11 +120,12 @@ jobs:
branch: ${{ github.head_ref }}
base-branch: ${{ github.base_ref }}
pull-request-sha: ${{ github.event.pull_request.head.sha }}
coverage-file-name: sonar-coverage.xml
coverage-file-names: sonar-coverage-sdk.xml,sonar-coverage-3DS.xml,sonar-coverage-nol-pay.xml,sonar-coverage-klarna.xml

build-and-upload-to-appetize:
needs:
- unit-tests
- unit-tests-sdk
- unit-tests-debug-app
runs-on: macos-13-large
timeout-minutes: 45
name: "Build and upload app to Appetize"
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/test-and-code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ jobs:
fastlane-password: ${{ secrets.FASTLANE_PASSWORD }}
match-keychain-name: ${{ secrets.MATCH_KEYCHAIN_NAME }}
match-keychain-password: ${{ secrets.MATCH_KEYCHAIN_PASSWORD }}
coverage-file-name: sonar-coverage.xml

sonarcloud:
needs:
Expand All @@ -46,14 +45,14 @@ jobs:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- uses: actions/download-artifact@master
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e #v4.1.7
with:
name: coverage-file
name: coverage-file-sdk
- name: SonarCloud Scan
uses: ./.github/actions/sonar
with:
github-token: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
sonar-token: ${{ secrets.SONAR_TOKEN }}
sonar-host: https://sonarcloud.io./
branch: ${{ github.head_ref }}
coverage-file-name: sonar-coverage.xml
coverage-file-names: sonar-coverage-sdk.xml
7 changes: 5 additions & 2 deletions .github/workflows/xcode-versions-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ jobs:
strategy:
max-parallel: 3
matrix:
variant: [cocoapods, spm]
xcode: [14.3.1]
variant:
- cocoapods
- spm
xcode:
- 14.3.1
steps:
- name: Git - Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ playground.xcworkspace
# .swiftpm

.build/

Package.swift.orig

# CocoaPods
#
Expand Down
35 changes: 21 additions & 14 deletions .swiftpm/xcode/xcshareddata/xcschemes/PrimerSDKTests.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
reference = "container:Debug App/Tests/UnitTestsTestPlan.xctestplan">
</TestPlanReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
<TestPlanReference
reference = "container:Debug App/Tests/DebugAppTestPlan.xctestplan">
</TestPlanReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
Expand All @@ -30,23 +40,11 @@
default = "YES">
</TestPlanReference>
</TestPlans>
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "PrimerSDKTests"
BuildableName = "PrimerSDKTests"
BlueprintName = "PrimerSDKTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand All @@ -60,6 +58,15 @@
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "Tests"
BuildableName = "Tests"
BlueprintName = "Tests"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
Loading
Loading