From f57c197846b6bc5a4d10b8f8bc202d5cba964fea Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Sun, 27 Aug 2023 17:44:37 +0200 Subject: [PATCH] test: run webkit in github actions safari --- .github/workflows/browserstack.yml | 104 ----------------------------- .github/workflows/retry.yml | 16 ----- .github/workflows/test.yml | 10 ++- tap/.browsers.sh | 9 --- tap/browserstack.cjs | 37 ---------- 5 files changed, 9 insertions(+), 167 deletions(-) delete mode 100644 .github/workflows/browserstack.yml delete mode 100644 .github/workflows/retry.yml delete mode 100644 tap/browserstack.cjs diff --git a/.github/workflows/browserstack.yml b/.github/workflows/browserstack.yml deleted file mode 100644 index c9292f5d1a..0000000000 --- a/.github/workflows/browserstack.yml +++ /dev/null @@ -1,104 +0,0 @@ -name: Browserstack - -on: - push: - branches: [main] - pull_request: - branches: [main] - pull_request_target: - types: [labeled] - branches: [main] - schedule: - - cron: '11 11 * * 1' - workflow_dispatch: - -jobs: - unlabel: - if: ${{ github.event_name == 'pull_request_target' && github.event.label.name == 'trigger-browserstack' }} - runs-on: ubuntu-latest - steps: - - run: gh pr edit $PR --repo $REPO --remove-label "trigger-browserstack" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR: ${{ github.event.number }} - REPO: ${{ github.event.repository.full_name }} - - gate: - runs-on: ubuntu-latest - if: ${{ !startsWith(github.event_name, 'pull_request') || (github.event_name == 'pull_request_target' && github.event.label.name == 'trigger-browserstack') }} - steps: - - run: echo The Show Must Go On - - build: - needs: - - gate - uses: ./.github/workflows/build.yml - - cert: - needs: - - gate - uses: panva/.github/.github/workflows/cert-for-browserstack.yml@main - with: - subdomain: jose - secrets: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - - browserstack: - needs: - - build - - cert - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - browser: - - browserstack:android - - browserstack:ios - - browserstack:safari - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Cache letsencrypt - id: cert - uses: actions/cache@v3 - with: - path: letsencrypt - key: ${{ needs.cert.outputs.cache-key }} - fail-on-cache-miss: true - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: lts/hydrogen # 18 - cache: 'npm' - - run: npm clean-install - - run: npm install --global testcafe@2 testcafe-browser-provider-browserstack@1 - - name: Load cached dist - uses: actions/cache@v3 - id: dist - with: - path: dist - key: ${{ needs.build.outputs.cache-key }} - fail-on-cache-miss: true - - name: BrowserStack Env Setup - uses: browserstack/github-actions/setup-env@63b648e87c6c2b48039b6e7af80b259c60d85f99 - with: - username: ${{ secrets.BROWSERSTACK_USERNAME }} - access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} - build-name: 'BUILD_INFO' - project-name: 'REPO_NAME' - - name: Start BrowserStackLocal Tunnel - uses: browserstack/github-actions/setup-local@63b648e87c6c2b48039b6e7af80b259c60d85f99 - with: - local-testing: 'start' - local-logging-level: 'all-logs' - local-identifier: 'random' - - name: Run Test Suite - run: npm run tap:browsers - env: - BROWSER: ${{ matrix.browser }} - - name: Stop BrowserStackLocal - if: ${{ always() }} - uses: browserstack/github-actions/setup-local@63b648e87c6c2b48039b6e7af80b259c60d85f99 - with: - local-testing: 'stop' diff --git a/.github/workflows/retry.yml b/.github/workflows/retry.yml deleted file mode 100644 index 8f249dc820..0000000000 --- a/.github/workflows/retry.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Retry - -on: - workflow_run: - workflows: [Browserstack] - types: - - completed - -jobs: - retry: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.run_attempt == 1 }} - steps: - - run: gh api -XPOST ${{ github.event.workflow_run.rerun_url }}-failed-jobs - env: - GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a6d50015e4..c22b238442 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -187,7 +187,7 @@ jobs: browsers: needs: - build - runs-on: ubuntu-latest + runs-on: ${{ matrix.runs-on || 'ubuntu-latest' }} strategy: fail-fast: false matrix: @@ -195,6 +195,9 @@ jobs: - chrome:headless - firefox:headless - edge:headless + include: + - runs-on: macos-13 + browser: safari steps: - name: Checkout uses: actions/checkout@v3 @@ -205,6 +208,11 @@ jobs: cache: 'npm' - run: npm clean-install - run: npm install --global testcafe@2 + - name: Add rows to the TCC.db + if: ${{ matrix.runs-on == 'macos-13' }} + run: | + sudo sqlite3 "$HOME/Library/Application Support/com.apple.TCC/TCC.db" "INSERT OR REPLACE INTO access VALUES('kTCCServiceAppleEvents','com.devexpress.testcafe-browser-tools',0,2,3,1,X'fade0c0000000068000000010000000700000007000000080000001443fa4ca5141baeda21aeca1f50894673b440d4690000000800000014f8afcf6e69791b283e55bd0b03e39e422745770e0000000800000014bf4fc1aed64c871a49fc6bc9dd3878ce5d4d17c6',NULL,0,'com.apple.Safari',X'fade0c000000002c00000001000000060000000200000010636f6d2e6170706c652e53616661726900000003',NULL,1687952810);" + sudo sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" "INSERT OR REPLACE INTO access VALUES('kTCCServiceScreenCapture','com.devexpress.testcafe-browser-tools',0,2,3,1,X'fade0c0000000068000000010000000700000007000000080000001443fa4ca5141baeda21aeca1f50894673b440d4690000000800000014f8afcf6e69791b283e55bd0b03e39e422745770e0000000800000014bf4fc1aed64c871a49fc6bc9dd3878ce5d4d17c6',NULL,0,'UNUSED',NULL,0,1687952810);" - name: Load cached dist uses: actions/cache@v3 id: dist diff --git a/tap/.browsers.sh b/tap/.browsers.sh index 53ed496f99..8582264fc5 100755 --- a/tap/.browsers.sh +++ b/tap/.browsers.sh @@ -12,15 +12,6 @@ SSL="" if [[ -z $CI ]]; then BROWSER="chrome:headless" -else - if [[ "$BROWSER" == "browserstack"* ]]; then - if [[ "$BROWSER" != "browserstack:android"* ]]; then - HOSTNAME="jose.panva.me" - SSL="key=./letsencrypt/config/live/jose.panva.me/privkey.pem;cert=./letsencrypt/config/live/jose.panva.me/cert.pem;rejectUnauthorized=true;" - fi - BROWSER=$(NODE_PATH=$(npm root -g) node ./tap/browserstack.cjs $BROWSER) - echo "Using $BROWSER" - fi fi testcafe "$BROWSER" --skip-js-errors --ssl "$SSL" --hostname "$HOSTNAME" tap/.browser.ts diff --git a/tap/browserstack.cjs b/tap/browserstack.cjs deleted file mode 100644 index d3f404c622..0000000000 --- a/tap/browserstack.cjs +++ /dev/null @@ -1,37 +0,0 @@ -const browserstack = require('testcafe-browser-provider-browserstack') -const { parseArgs } = require('node:util') - -const { - positionals: { 0: identifier }, -} = parseArgs({ allowPositionals: true }) - -function majorMinorSort(a, b) { - const va = parseFloat(a.split('@')[1]) - const vb = parseFloat(b.split('@')[1]) - - return va < vb ? 1 : -1 -} - -browserstack - .init() - .then(() => browserstack.getBrowserList()) - .then((browserlist) => { - let result - switch (identifier) { - case 'browserstack:android': - ;[result] = browserlist.filter((id) => id.startsWith('Google Pixel')).sort(majorMinorSort) - break - case 'browserstack:safari': - ;[result] = browserlist - .filter((id) => !!new RegExp(`safari@\\\d+\\\.\\\d+:[^W]`).exec(id)) - .sort(majorMinorSort) - break - case 'browserstack:ios': - ;[result] = browserlist.filter((id) => id.startsWith('iPhone')).sort(majorMinorSort) - break - default: - throw new TypeError('unsupported browser identifier') - } - - console.log(`browserstack:${result}`) - })