Skip to content

Commit

Permalink
legacy ui tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kshann committed Mar 25, 2024
1 parent a53810b commit 95cb548
Show file tree
Hide file tree
Showing 3 changed files with 166 additions and 2 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ui_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
163 changes: 163 additions & 0 deletions .github/workflows/ui_tests_legacy_os.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion UITests/TabBarTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 95cb548

Please sign in to comment.