diff --git a/.github/workflows/bitbar-prepare-artifacts.yaml b/.github/workflows/bitbar-prepare-artifacts.yaml new file mode 100644 index 0000000..b892fe7 --- /dev/null +++ b/.github/workflows/bitbar-prepare-artifacts.yaml @@ -0,0 +1,126 @@ +name: Prepare device farm artifacts +on: + workflow_call: + secrets: + # 1. Open the keychain on your mac and export the signing certificate and private key in a Certificates.p12 file + # 2. Convert your certificate to Base64 string: `base64 Certificates.p12 | pbcopy` + # 3. Update the value of the CERTIFICATES_FILE_BASE64 action secret with the content of the clipboard + # 4. Update the CERTIFICATES_PASSWORD action secret with the one used during the export of the certificate from the keychain + CERTIFICATES_FILE_BASE64: + description: 'Apple signing certificate' + required: true + + # The password for your Apple signing certificate + CERTIFICATES_PASSWORD: + description: 'Apple signing certificate p12 password' + required: true + + # A new keychain will be created during the run. The password could be any new random string. + KEYCHAIN_PASSWORD: + description: 'Keychain password' + required: true + + # 1. Find the 'com.forgerock.FRTestHost' provisioning profile (~/Library/MobileDevice/Provisioning\ Profiles) + # 2. Rename the file to `provisioning_profile.mobileprovision` + # 3. Zip the file: `zip provisioning_profile.mobileprovision.zip provisioning_profile.mobileprovision` + # 4. Convert the file to Base64 string: `base64 provisioning_profile.mobileprovision.zip | pbcopy` + # 5. Update the value of the BUILD_PROVISION_PROFILE_ZIP_BASE64 action secret with the content of the clipboard + BUILD_PROVISION_PROFILE: + description: 'Apple build provisioning profile' + required: true + + SLACK_WEBHOOK: + description: 'Slack Notifier Incoming Webhook URL' + required: true +jobs: + prepare-device-farm-artifacts: + runs-on: macos-14 + + steps: + # Clone the repo + - name: Clone the repository + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.ref }} + repository: ${{github.event.pull_request.head.repo.full_name}} + fetch-depth: 0 + + # Install the Apple certificate and provisioning profile + - name: Install the Apple certificate and provisioning profile + run: | + # Create variables + CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12 + PP_PATH_ZIP=$RUNNER_TEMP/build_pp.mobileprovision.zip + PP_FILENAME=provisioning_profile.mobileprovision + KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db + + # Import certificate and provisioning profile from secrets + echo -n ${{ secrets.CERTIFICATES_FILE_BASE64 }} | base64 --decode -o $CERTIFICATE_PATH + echo -n ${{ secrets.BUILD_PROVISION_PROFILE }} | base64 --decode -o $PP_PATH_ZIP + unzip $PP_PATH_ZIP + + # Create temporary keychain + security create-keychain -p "${{ secrets.KEYCHAIN_PASSWORD }}" $KEYCHAIN_PATH + security set-keychain-settings -lut 21600 $KEYCHAIN_PATH + security unlock-keychain -p "${{ secrets.KEYCHAIN_PASSWORD }}" $KEYCHAIN_PATH + + # Import certificate to keychain + security import $CERTIFICATE_PATH -P "${{ secrets.CERTIFICATES_PASSWORD }}" -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_FILENAME ~/Library/MobileDevice/Provisioning\ Profiles + + # Set target Xcode version. For more details and options see: + # https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11-Readme.md + - name: Select Xcode + run: sudo xcode-select -switch /Applications/Xcode_15.4.app && /usr/bin/xcodebuild -version + + - name: build-for-testing and sign + run: xcodebuild -scheme PingTestHost -sdk iphoneos17.5 -workspace SampleApps/Ping.xcworkspace -configuration Debug clean build BUILD_DIR=/tmp/build/ DEVELOPMENT_TEAM=9QSE66762D -allowProvisioningUpdates -destination generic/platform=iOS -derivedDataPath /tmp/build/derivedData/ build-for-testing + + # Prepare BitBar artifacts: + - name: Prepare BitBar artifacts + run: | + pwd + ls -la + cd /tmp/build/Debug-iphoneos/ + cp -r PingTestHost.app/PlugIns/DavinciTests.xctest . + zip -r -X DavinciTests.xctest.zip DavinciTests.xctest + mkdir Payload + cp -r PingTestHost.app Payload/ + zip --symlinks -qr PingTestHost.ipa Payload + + # Publish e2e tests and app build artifacts + - name: Publish PingTestHost.ipa + uses: actions/upload-artifact@v3 + if: success() + with: + name: PingTestHost.ipa + path: ~/build/Debug-iphoneos/PingTestHost.ipa + + - name: Publish DavinciTests.xctest.zip + uses: actions/upload-artifact@v3 + if: success() + with: + name: DavinciTests.xctest.zip + path: ~/build/Debug-iphoneos/DavinciTests.xctest.zip + + # Send slack notification ONLY if any of the steps above fail + - name: Send slack notification + uses: 8398a7/action-slack@v3 + with: + status: custom + fields: all + custom_payload: | + { + attachments: [{ + title: ':no_entry: Failed to prepare BitBar test artifacts', + color: 'danger', + text: `\nWorkflow: ${process.env.AS_WORKFLOW} -> ${process.env.AS_JOB}\nPull request: ${process.env.AS_PULL_REQUEST}\nCommit: ${process.env.AS_COMMIT} by ${process.env.AS_AUTHOR}`, + }] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + if: failure() \ No newline at end of file diff --git a/.github/workflows/bitbar-results.yaml b/.github/workflows/bitbar-results.yaml new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/bitbar-run.yaml b/.github/workflows/bitbar-run.yaml new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 192f6a1..21bfabc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,18 +10,50 @@ on: - develop jobs: - # Build and run unit tests - build-and-test: - name: Build and test - uses: ./.github/workflows/build-and-test.yaml + # # Build and run unit tests + # build-and-test: + # name: Build and test + # uses: ./.github/workflows/build-and-test.yaml + # secrets: + # SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + + # # Run Mend CLI Scan + # mend-cli-scan: + # name: Mend CLI Scan + # uses: ./.github/workflows/mend-cli-scan.yaml + # secrets: + # MEND_EMAIL: ${{ secrets.MEND_EMAIL }} + # MEND_USER_KEY: ${{ secrets.MEND_USER_KEY }} + # SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + + # Build and sign BitBar test artifacts (FRTestHost.ipa and FRAuthTests.xctest.zip) + bitbar-prepare-artifacts: + name: Prepare device farm artifacts + uses: ./.github/workflows/bitbar-prepare-artifacts.yaml + # needs: build-and-test secrets: + CERTIFICATES_FILE_BASE64: ${{ secrets.CERTIFICATES_FILE_BASE64 }} + CERTIFICATES_PASSWORD: ${{ secrets.CERTIFICATES_PASSWORD }} + KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} + BUILD_PROVISION_PROFILE: ${{ secrets.BUILD_PROVISION_PROFILE_ZIP_BASE64}} SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + + # # Execute e2e test cases in BitBar. The workflow outputs the newly created run id. + # bitbar-run: + # name: Run e2e tests in BitBar + # uses: ./.github/workflows/bitbar-run.yaml + # needs: bitbar-prepare-artifacts + # secrets: + # BITBAR_API_KEY: ${{ secrets.BITBAR_API_KEY }} + # SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} - # Run Mend CLI Scan - mend-cli-scan: - name: Mend CLI Scan - uses: ./.github/workflows/mend-cli-scan.yaml - secrets: - MEND_EMAIL: ${{ secrets.MEND_EMAIL }} - MEND_USER_KEY: ${{ secrets.MEND_USER_KEY }} - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + # # Wait for BitBar test run to finish and publish results + # bitbar-results: + # name: Wait for and publish BitBar test results + # uses: ./.github/workflows/bitbar-results.yaml + # needs: bitbar-run + # secrets: + # BITBAR_API_KEY: ${{ secrets.BITBAR_API_KEY }} + # SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + # with: + # bitbar-run-id: ${{ needs.bitbar-run.outputs.bitbar-run-id }} diff --git a/PingTestHost/PingTestHost.xcodeproj/project.pbxproj b/PingTestHost/PingTestHost.xcodeproj/project.pbxproj index 3b37e25..a5bd7d7 100644 --- a/PingTestHost/PingTestHost.xcodeproj/project.pbxproj +++ b/PingTestHost/PingTestHost.xcodeproj/project.pbxproj @@ -365,9 +365,11 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = 9QSE66762D; + DEVELOPMENT_TEAM = ""; + "DEVELOPMENT_TEAM[sdk=iphoneos*]" = 9QSE66762D; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = PingTestHost/Info.plist; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; @@ -380,10 +382,11 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = "1.0.0"; + MARKETING_VERSION = 1.0.0; PRODUCT_BUNDLE_IDENTIFIER = com.pingidentity.PingTestHost; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; + "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = PingTestHost; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -397,9 +400,11 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = 9QSE66762D; + DEVELOPMENT_TEAM = ""; + "DEVELOPMENT_TEAM[sdk=iphoneos*]" = 9QSE66762D; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = PingTestHost/Info.plist; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; @@ -412,10 +417,11 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = "1.0.0"; + MARKETING_VERSION = 1.0.0; PRODUCT_BUNDLE_IDENTIFIER = com.pingidentity.PingTestHost; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; + "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = PingTestHost; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2";