From 95cb54862d9b50ac19caf400da0e398cb0f01f56 Mon Sep 17 00:00:00 2001 From: Kieran Date: Mon, 25 Mar 2024 23:22:56 +1100 Subject: [PATCH] legacy ui tests --- .github/workflows/ui_tests.yml | 1 - .github/workflows/ui_tests_legacy_os.yml | 163 +++++++++++++++++++++++ UITests/TabBarTests.swift | 4 +- 3 files changed, 166 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ui_tests_legacy_os.yml diff --git a/.github/workflows/ui_tests.yml b/.github/workflows/ui_tests.yml index 6c19272d0b..6f6227eaa7 100644 --- a/.github/workflows/ui_tests.yml +++ b/.github/workflows/ui_tests.yml @@ -73,7 +73,6 @@ jobs: -skipMacroValidation \ -test-iterations 2 \ -retry-tests-on-failure \ - UITEST_MODE=1 \ | tee xcodebuild.log \ | xcbeautify --report junit --report-path . --junit-report-filename ui-tests.xml diff --git a/.github/workflows/ui_tests_legacy_os.yml b/.github/workflows/ui_tests_legacy_os.yml new file mode 100644 index 0000000000..1111565e64 --- /dev/null +++ b/.github/workflows/ui_tests_legacy_os.yml @@ -0,0 +1,163 @@ +name: Sync-End-to-End tests MacOS11/12 + +on: + workflow_dispatch: + # schedule: + # - cron: '0 4 * * *' # run at 4 AM UTC + push: + branches: + - "kieran/ui-test-workflows" + +jobs: + create-notarized-app: + name: Prepare DMG Release + uses: ./.github/workflows/build_notarized.yml + with: + release-type: review + create-dmg: false + branch: ${{ github.ref_name }} + secrets: + BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }} + P12_PASSWORD: ${{ secrets.P12_PASSWORD }} + KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} + REVIEW_PROVISION_PROFILE_BASE64: ${{ secrets.REVIEW_PROVISION_PROFILE_BASE64 }} + RELEASE_PROVISION_PROFILE_BASE64: ${{ secrets.RELEASE_PROVISION_PROFILE_BASE64 }} + DBP_AGENT_RELEASE_PROVISION_PROFILE_BASE64: ${{ secrets.DBP_AGENT_RELEASE_PROVISION_PROFILE_BASE64 }} + DBP_AGENT_REVIEW_PROVISION_PROFILE_BASE64: ${{ secrets.DBP_AGENT_REVIEW_PROVISION_PROFILE_BASE64 }} + NETP_SYSEX_RELEASE_PROVISION_PROFILE_BASE64_V2: ${{ secrets.NETP_SYSEX_RELEASE_PROVISION_PROFILE_BASE64_V2 }} + NETP_SYSEX_REVIEW_PROVISION_PROFILE_BASE64_V2: ${{ secrets.NETP_SYSEX_REVIEW_PROVISION_PROFILE_BASE64_V2 }} + NETP_AGENT_RELEASE_PROVISION_PROFILE_BASE64_V2: ${{ secrets.NETP_AGENT_RELEASE_PROVISION_PROFILE_BASE64_V2 }} + NETP_AGENT_REVIEW_PROVISION_PROFILE_BASE64_V2: ${{ secrets.NETP_AGENT_REVIEW_PROVISION_PROFILE_BASE64_V2 }} + NETP_NOTIFICATIONS_RELEASE_PROVISION_PROFILE_BASE64: ${{ secrets.NETP_NOTIFICATIONS_RELEASE_PROVISION_PROFILE_BASE64 }} + NETP_NOTIFICATIONS_REVIEW_PROVISION_PROFILE_BASE64: ${{ secrets.NETP_NOTIFICATIONS_REVIEW_PROVISION_PROFILE_BASE64 }} + APPLE_API_KEY_BASE64: ${{ secrets.APPLE_API_KEY_BASE64 }} + APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }} + APPLE_API_KEY_ISSUER: ${{ secrets.APPLE_API_KEY_ISSUER }} + ASANA_ACCESS_TOKEN: ${{ secrets.ASANA_ACCESS_TOKEN }} + MM_HANDLES_BASE64: ${{ secrets.MM_HANDLES_BASE64 }} + MM_WEBHOOK_URL: ${{ secrets.MM_WEBHOOK_URL }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_ACCESS_KEY_ID_RELEASE_S3: ${{ secrets.AWS_ACCESS_KEY_ID_RELEASE_S3 }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_SECRET_ACCESS_KEY_RELEASE_S3: ${{ secrets.AWS_SECRET_ACCESS_KEY_RELEASE_S3 }} + + ui-tests-legacy-os: + name: UI Tests legacy OS + needs: create-notarized-app + env: + app-version: ${{ needs.create-notarized-app.outputs.app-version }} + + runs-on: ${{ matrix.runner }} + strategy: + fail-fast: false + matrix: + runner: [ macos-11, macos-12-large ] + + timeout-minutes: 60 + steps: + - name: Check out the code + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Download and unzip artifact + uses: actions/download-artifact@v4 + + - name: Set cache key hash + run: | + has_only_tags=$(jq '[ .pins[].state | has("version") ] | all' DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved) + if [[ "$has_only_tags" == "true" ]]; then + echo "cache_key_hash=${{ hashFiles('DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved') }}" >> $GITHUB_ENV + else + echo "Package.resolved contains dependencies specified by branch or commit, skipping cache." + fi + + - name: Cache SPM + if: env.cache_key_hash + uses: actions/cache@v3 + with: + path: DerivedData/SourcePackages + key: ${{ runner.os }}-spm-${{ env.cache_key_hash }} + restore-keys: | + ${{ runner.os }}-spm- + + - name: Install Apple Developer ID Application certificate + uses: ./.github/actions/install-certs-and-profiles + with: + BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }} + P12_PASSWORD: ${{ secrets.P12_PASSWORD }} + KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} + REVIEW_PROVISION_PROFILE_BASE64: ${{ secrets.REVIEW_PROVISION_PROFILE_BASE64 }} + RELEASE_PROVISION_PROFILE_BASE64: ${{ secrets.RELEASE_PROVISION_PROFILE_BASE64 }} + DBP_AGENT_RELEASE_PROVISION_PROFILE_BASE64: ${{ secrets.DBP_AGENT_RELEASE_PROVISION_PROFILE_BASE64 }} + DBP_AGENT_REVIEW_PROVISION_PROFILE_BASE64: ${{ secrets.DBP_AGENT_REVIEW_PROVISION_PROFILE_BASE64 }} + NETP_SYSEX_RELEASE_PROVISION_PROFILE_BASE64: ${{ secrets.NETP_SYSEX_RELEASE_PROVISION_PROFILE_BASE64_V2 }} + NETP_SYSEX_REVIEW_PROVISION_PROFILE_BASE64: ${{ secrets.NETP_SYSEX_REVIEW_PROVISION_PROFILE_BASE64_V2 }} + NETP_AGENT_RELEASE_PROVISION_PROFILE_BASE64: ${{ secrets.NETP_AGENT_RELEASE_PROVISION_PROFILE_BASE64_V2 }} + NETP_AGENT_REVIEW_PROVISION_PROFILE_BASE64: ${{ secrets.NETP_AGENT_REVIEW_PROVISION_PROFILE_BASE64_V2 }} + NETP_NOTIFICATIONS_RELEASE_PROVISION_PROFILE_BASE64: ${{ secrets.NETP_NOTIFICATIONS_RELEASE_PROVISION_PROFILE_BASE64 }} + NETP_NOTIFICATIONS_REVIEW_PROVISION_PROFILE_BASE64: ${{ secrets.NETP_NOTIFICATIONS_REVIEW_PROVISION_PROFILE_BASE64 }} + + # This first bit is a hack to stop the app building package dependencies that isn't needed by the test runner + - name: Build test runner + run: | + rm -rf LocalPackages + rm -rf /Users/runner/work/macos-browser/macos-browser/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved + sed -i '' '/\/\* Begin XCSwiftPackageProductDependency section \*\//,/\/\* End XCSwiftPackageProductDependency section \*\//d' DuckDuckGo.xcodeproj/project.pbxproj + sed -i '' '/\/\* Begin XCRemoteSwiftPackageReference section \*\//,/\/\* End XCRemoteSwiftPackageReference section \*\//d' DuckDuckGo.xcodeproj/project.pbxproj + set -o pipefail && xcodebuild build-for-testing \ + -scheme "UI Tests" \ + -derivedDataPath DerivedData \ + -configuration Review + + - name: Unzip and Copy app to /DerivedData + run: | + cd DuckDuckGo-review-*.app && unzip DuckDuckGo-*.zip + cp -R "DuckDuckGo Review.app" "../DerivedData/Build/Products/Review/DuckDuckGo Review.app" + + # xcpretty does nothing here + - name: Run tests + run: | + defaults write com.duckduckgo.macos.browser.review moveToApplicationsFolderAlertSuppress 1 + defaults write com.duckduckgo.macos.browser.review onboarding.finished -bool true + set -o pipefail && xcodebuild test \ + -scheme "UI Testing" \ + -derivedDataPath DerivedData \ + -configuration Review \ + -skipPackagePluginValidation \ + -skipMacroValidation \ + -test-iterations 2 \ + -retry-tests-on-failure \ + | tee xcodebuild.log \ + | (if [ "${{ matrix.runner }}" = "macos-11" ]; then + xcpretty --report junit --output ui-tests.xml + else + xcbeautify --report junit --report-path . --junit-report-filename ui-tests.xml + fi) + + # - name: Create Asana task when workflow failed + # if: ${{ failure() }} && github.ref == 'refs/heads/main' + # run: | + # curl -s "https://app.asana.com/api/1.0/tasks" \ + # --header "Accept: application/json" \ + # --header "Authorization: Bearer ${{ secrets.ASANA_ACCESS_TOKEN }}" \ + # --header "Content-Type: application/json" \ + # --data ' { "data": { "name": "GH Workflow Failure - Sync End to end tests", "projects": [ "${{ vars.MACOS_APP_DEVELOPMENT_ASANA_PROJECT_ID }}" ], "notes" : "The end to end workflow has failed. See https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" } }' + + - name: Publish tests report + uses: mikepenz/action-junit-report@v4 + if: always() + with: + check_name: "Test Report ${{ matrix.runner }}" + report_paths: ui-tests.xml + + - name: Upload logs when workflow failed + uses: actions/upload-artifact@v4 + if: always() + with: + name: "BuildLogs ${{ matrix.runner }}" + path: | + xcodebuild.log + DerivedData/Logs/Test/*.xcresult + ~/Library/Logs/DiagnosticReports/* + retention-days: 7 \ No newline at end of file diff --git a/UITests/TabBarTests.swift b/UITests/TabBarTests.swift index d6c7d32937..430d99c646 100644 --- a/UITests/TabBarTests.swift +++ b/UITests/TabBarTests.swift @@ -22,7 +22,9 @@ class TabBarTests: XCTestCase { override func setUpWithError() throws { continueAfterFailure = false - XCUIApplication().launch() + let app = XCUIApplication() + app.launchEnvironment["UITEST_MODE"] = "1" + app.launch() } func testWhenClickingAddTab_ThenTabsOpen() throws {