From 4228eae48e96e5307cb765d5e5fa432d3b4574d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20P?= Date: Wed, 2 Feb 2022 20:22:51 +0100 Subject: [PATCH] [DEVX-1471] Add macOS support (#139) --- .github/workflows/release.yml | 129 +++++++++++++----- .github/workflows/test.yml | 56 +++++++- .../post-release/.sauce/config_mac.yml | 37 +++++ .../.sauce/{config.yml => config_win.yml} | 11 +- .../sauce-connect/.sauce/config.yml | 7 + 5 files changed, 203 insertions(+), 37 deletions(-) create mode 100644 tests/fixtures/post-release/.sauce/config_mac.yml rename tests/fixtures/post-release/.sauce/{config.yml => config_win.yml} (76%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1af570ff..38dba205 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -244,9 +244,81 @@ jobs: asset_name: sauce-playwright-runner.zip asset_content_type: application/zip + release-macos-bundle: + runs-on: macos-latest + needs: [create-release-draft] + steps: + - name: Find matching draft tag + id: prep + run: | + VERSION=$(curl -s -H "Authorization: token ${{ github.token }}" \ + https://api.github.com/repos/${{ github.repository }}/releases | \ + jq -r "[.[] | select(.draft == true) | select(.body | contains(\"- jobId: ${{ github.run_id }}\\n\"))] | first | .tag_name") + RELEASE_ID=$(curl -s -H "Authorization: token ${{ github.token }}" \ + https://api.github.com/repos/${{ github.repository }}/releases | \ + jq -r "[.[] | select(.draft == true) | select(.body | contains(\"- jobId: ${{ github.run_id }}\\n\"))] | first | .id") + + if [ "${VERSION}" = "" ];then + echo "No draft version found" + exit 1 + fi + + ASSET_ID=$(curl -s -H "Authorization: token ${{ github.token }}" \ + https://api.github.com/repos/${{ github.repository }}/releases | \ + jq -r "[.[] | select(.body | contains(\"- jobId: ${{ github.run_id }}\\n\"))] | first | .assets | .[] | select(.name == \"sauce-testcafe-macos.zip\") | .id | select(. != null)") + + echo ::set-output name=version::${VERSION} + echo ::set-output name=release_id::${RELEASE_ID} + echo ::set-output name=asset_id::${ASSET_ID} + + - run: echo "${{ steps.prep.outputs.release_id }} - ${{ steps.prep.outputs.version }} - ${{ steps.prep.outputs.asset_id }}" + + - uses: actions/checkout@v2 + if: ${{ steps.prep.outputs.asset_id == '' }} + with: + ref: ${{ steps.prep.outputs.version }} + + - name: Use Node.js v14.x + if: ${{ steps.prep.outputs.asset_id == '' }} + uses: actions/setup-node@v1 + with: + node-version: 14.x + + - name: Update Release version + if: ${{ steps.prep.outputs.asset_id == '' }} + run: | + npm version --no-git-tag-version ${{ steps.prep.outputs.version }} + + - run: npm ci --production + if: ${{ steps.prep.outputs.asset_id == '' }} + + - name: Bundle Directory + if: ${{ steps.prep.outputs.asset_id == '' }} + run: bash ./scripts/bundle.sh + + - name: List bundle contents + if: ${{ steps.prep.outputs.asset_id == '' }} + run: ls -R bundle/ + + - name: Archive bundle + if: ${{ steps.prep.outputs.asset_id == '' }} + run: zip -r sauce-playwright-macos.zip bundle/ + + - name: Upload Release Asset + if: ${{ steps.prep.outputs.asset_id == '' }} + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: https://uploads.github.com/repos/${{ github.repository }}/releases/${{ steps.prep.outputs.release_id }}/assets?name=sauce-playwright-macos.zip + asset_path: ./sauce-playwright-macos.zip + asset_name: sauce-playwright-macos.zip + asset_content_type: application/zip + publish-release: runs-on: ubuntu-latest - needs: [release-docker, release-windows-bundle] + needs: [release-docker, release-windows-bundle, release-macos-bundle] steps: - name: Find matching draft tag id: prep @@ -286,39 +358,34 @@ jobs: jq -r "[.[] | select(.body | contains(\"- jobId: ${{ github.run_id }}\\n\"))] | first | .tag_name") echo ::set-output name=version::${VERSION} - - name: cloud tests + - name: cloud tests (Windows) working-directory: ./tests/fixtures/post-release env: BUILD_ID: Github RUN ID ${{ env.GITHUB_RUN_ID }} run: | - npx saucectl run --runner-version "github-release: ${{ steps.parse_version.outputs.version }}" + npx saucectl run --runner-version "github-release: ${{ steps.parse_version.outputs.version }}" --config .sauce/config_win.yml - - name: Notify slack on failure - uses: 8398a7/action-slack@v3 - if: failure() + post-release-macos-tests: + runs-on: ubuntu-latest + needs: publish-release + env: + SAUCE_ACCESS_KEY: ${{secrets.SAUCE_ACCESS_KEY}} + SAUCE_USERNAME: ${{secrets.SAUCE_USERNAME}} + steps: + - uses: actions/checkout@master + - name: Install Deps + run: npm ci + - name: Parse release version + id: parse_version + run: | + VERSION=$(curl -s -H "Authorization: token ${{ github.token }}" \ + https://api.github.com/repos/${{ github.repository }}/releases | \ + jq -r "[.[] | select(.body | contains(\"- jobId: ${{ github.run_id }}\\n\"))] | first | .tag_name") + echo ::set-output name=version::${VERSION} + + - name: cloud tests (MacOS) + working-directory: ./tests/fixtures/post-release env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - RELEASE: ${{ steps.parse_version.outputs.version }} - with: - status: custom - fields: commit,workflow,job - custom_payload: | - { - attachments: [{ - mrkdwn_in: ['text'], - title: `${{ github.repository }}@${process.env.RELEASE}`, - title_link: `https://github.com/${{ github.repository }}/releases/${process.env.RELEASE}`, - text: `${process.env.AS_JOB} job failed :homer_back_away:`, - color: 'danger', - fields: [{ - title: 'Commit', - value: `${process.env.AS_COMMIT}`, - short: true - }, - { - title: 'Workflow', - value: `${process.env.AS_WORKFLOW}`, - short: true - }] - }] - } + BUILD_ID: Github RUN ID ${{ env.GITHUB_RUN_ID }} + run: | + npx saucectl run --runner-version "github-release: ${{ steps.parse_version.outputs.version }}" --config .sauce/config_mac.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cbfe4326..65fc462e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -106,11 +106,56 @@ jobs: - name: Test on Sauce working-directory: ./tests/fixtures/post-release run: | - npx saucectl run --runner-version "url: https://storage.googleapis.com/${{ secrets.GCS_RUNNER_BUCKET }}/sauce-playwright-runner-${{ github.run_id }}.zip" + npx saucectl run --runner-version "url: https://storage.googleapis.com/${{ secrets.GCS_RUNNER_BUCKET }}/sauce-playwright-runner-${{ github.run_id }}.zip" --config .sauce/config_win.yml + + build-macos-bundle-and-test: + runs-on: windows-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + ref: ${{ github.ref }} + fetch-depth: 0 + + - name: Setup nodejs + uses: actions/setup-node@v1 + with: + node-version: 16.x + + - name: Set up Python 3.9 + uses: actions/setup-python@v2 + with: + python-version: 3.9 + + - name: Install gcloud SDK + uses: google-github-actions/setup-gcloud@master + with: + service_account_key: ${{ secrets.GCS_RUNNER_SA_KEY }} + project_id: ${{ secrets.GCS_RUNNER_PROJECT_ID }} + env: + CLOUDSDK_PYTHON: ${{env.pythonLocation}}/python + + - name: Update Release version + run: npm version --no-git-tag-version 1.0.0 + + - name: Bundle Directory + run: bash ./scripts/bundle.sh + + - name: Archive bundle + run: zip -r sauce-playwright-macos.zip bundle/ + + - name: Upload to GCS + run: | + gsutil cp ./sauce-playwright-macos.zip gs://${{ secrets.GCS_RUNNER_BUCKET }}/sauce-playwright-macos-${{ github.run_id }}.zip + + - name: Test on Sauce + working-directory: ./tests/fixtures/post-release + run: | + npx saucectl run --runner-version "url: https://storage.googleapis.com/${{ secrets.GCS_RUNNER_BUCKET }}/sauce-playwright-macos-${{ github.run_id }}.zip" --config .sauce/config_mac.yml run-bundle-with-sauce-connect: runs-on: ubuntu-latest - needs: [build-windows-bundle-and-test] + needs: [build-windows-bundle-and-test, build-macos-bundle-and-test] steps: - name: Checkout runner uses: actions/checkout@v2 @@ -142,5 +187,10 @@ jobs: - name: run saucectl (Windows) run: | - saucectl run --config .sauce/config.yml --select-suite "Sauce with sauce-connect (windows)" --runner-version "url: https://storage.googleapis.com/${{ secrets.GCS_RUNNER_BUCKET }}/sauce-playwright-runner-${{ github.run_id }}.zip" + saucectl run --select-suite "Sauce with sauce-connect (windows)" --runner-version "url: https://storage.googleapis.com/${{ secrets.GCS_RUNNER_BUCKET }}/sauce-playwright-runner-${{ github.run_id }}.zip" + working-directory: ./tests/integration/sauce-connect/ + + - name: run saucectl (MacOS) + run: | + saucectl run --select-suite "Sauce with sauce-connect (macOS)" --runner-version "url: https://storage.googleapis.com/${{ secrets.GCS_RUNNER_BUCKET }}/sauce-playwright-macos-${{ github.run_id }}.zip" working-directory: ./tests/integration/sauce-connect/ diff --git a/tests/fixtures/post-release/.sauce/config_mac.yml b/tests/fixtures/post-release/.sauce/config_mac.yml new file mode 100644 index 00000000..a5e79a27 --- /dev/null +++ b/tests/fixtures/post-release/.sauce/config_mac.yml @@ -0,0 +1,37 @@ +apiVersion: v1alpha +kind: playwright +sauce: + region: us-west-1 + concurrency: 3 + metadata: + tags: + - e2e + build: "$BUILD_ID" +rootDir: . +playwright: + # CAUTION: This has to be an already deployed framework version in the cloud. Not necessarily the one you want to test. + # Then use --runner-version to specify the release you actually want to use. + version: 1.15.2 +suites: + - name: "Post Release Test (macOS) - chromium" + platformName: "macOS 11.00" + testMatch: ['.*.js'] + params: + browserName: "chromium" + + - name: "Post Release Test (macOS) - webkit" + platformName: "macOS 11.00" + testMatch: ['.*.js'] + params: + browserName: "webkit" + + - name: "Post Release Test (macOS) - firefox" + platformName: "macOS 11.00" + testMatch: ['.*.js'] + params: + browserName: "firefox" + +notifications: + slack: + channels: ["devx"] + send: fail diff --git a/tests/fixtures/post-release/.sauce/config.yml b/tests/fixtures/post-release/.sauce/config_win.yml similarity index 76% rename from tests/fixtures/post-release/.sauce/config.yml rename to tests/fixtures/post-release/.sauce/config_win.yml index 42ecd21c..96f2bdd2 100644 --- a/tests/fixtures/post-release/.sauce/config.yml +++ b/tests/fixtures/post-release/.sauce/config_win.yml @@ -13,20 +13,25 @@ playwright: # Then use --runner-version to specify the release you actually want to use. version: 1.15.2 suites: - - name: "Post Release Test - chromium" + - name: "Post Release Test (Windows) - chromium" platformName: "Windows 10" testMatch: ['.*.js'] params: browserName: "chromium" - - name: "Post Release Test - webkit" + - name: "Post Release Test (Windows) - webkit" platformName: "Windows 10" testMatch: ['.*.js'] params: browserName: "webkit" - - name: "Post Release Test - firefox" + - name: "Post Release Test (Windows) - firefox" platformName: "Windows 10" testMatch: ['.*.js'] params: browserName: "firefox" + +notifications: + slack: + channels: ["devx"] + send: fail diff --git a/tests/integration/sauce-connect/.sauce/config.yml b/tests/integration/sauce-connect/.sauce/config.yml index 4f3d5539..61247999 100644 --- a/tests/integration/sauce-connect/.sauce/config.yml +++ b/tests/integration/sauce-connect/.sauce/config.yml @@ -20,3 +20,10 @@ suites: browserName: "chromium" testMatch: - "tests/sauce-connect.test.js" + + - name: "Sauce with sauce-connect (macOS)" + platformName: "macOS 11.00" + params: + browserName: "chromium" + testMatch: + - "tests/sauce-connect.test.js"