From 78a7ac85c21eb48493935b5668ba0c526652bb72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20P?= Date: Wed, 2 Feb 2022 20:57:28 +0100 Subject: [PATCH] [DEVX-1470] Add bundle+tests on MacOS (#171) --- .github/workflows/kitchen-sink.yml | 1 - .github/workflows/release.yml | 128 +++++++++++++----- .github/workflows/test.yml | 56 +++++++- package-lock.json | 12 +- .../.sauce/config_on_sauce.yml | 3 +- .../.sauce/config_on_sauce_mac.yml | 22 +++ tests/post-release/.sauce/config_mac.yml | 31 +++++ .../.sauce/{config.yml => config_win.yml} | 13 +- tests/sauce-connect/.sauce/config.yml | 4 +- tests/sauce-connect/.sauce/config_mac.yml | 21 +++ 10 files changed, 244 insertions(+), 47 deletions(-) create mode 100644 tests/kitchen-sink-tests/.sauce/config_on_sauce_mac.yml create mode 100644 tests/post-release/.sauce/config_mac.yml rename tests/post-release/.sauce/{config.yml => config_win.yml} (72%) create mode 100644 tests/sauce-connect/.sauce/config_mac.yml diff --git a/.github/workflows/kitchen-sink.yml b/.github/workflows/kitchen-sink.yml index ca16f02f..7ef4242a 100644 --- a/.github/workflows/kitchen-sink.yml +++ b/.github/workflows/kitchen-sink.yml @@ -39,4 +39,3 @@ jobs: working-directory: ./tests/kitchen-sink-tests sauce-username: ${{ secrets.SAUCE_USERNAME }} sauce-access-key: ${{ secrets.SAUCE_ACCESS_KEY }} - testing-environment: "" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7d302dcc..f21c8844 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -218,9 +218,81 @@ jobs: asset_name: sauce-cypress-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-cypress-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-cypress-macos.zip + asset_path: ./sauce-cypress-macos.zip + asset_name: sauce-cypress-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 @@ -263,34 +335,28 @@ jobs: - name: cloud tests working-directory: ./tests/post-release 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 + + 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 + working-directory: ./tests/post-release + run: | + npx saucectl run --runner-version "github-release: ${{ steps.parse_version.outputs.version }}" --config ./.sauce/config_mac.yml - - name: Notify slack on failure - uses: 8398a7/action-slack@v3 - if: failure() - 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 - }] - }] - } diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 89231dca..1f37e84d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -92,9 +92,56 @@ jobs: run: | npx saucectl run --config .sauce/config_on_sauce.yml --runner-version "url: https://storage.googleapis.com/${{ secrets.GCS_RUNNER_BUCKET }}/sauce-cypress-runner-${{ github.run_id }}.zip" + build-mac-bundle-and-test: + runs-on: macos-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + ref: ${{ github.ref }} + fetch-depth: 0 + + - name: Use Node.js v14.x + uses: actions/setup-node@v1 + with: + node-version: 14.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 + + - run: npm ci --production + + - name: Bundle Directory + run: bash ./scripts/bundle.sh + + - name: Archive bundle + run: zip -r sauce-cypress-macos.zip bundle/ + + - name: Upload to GCS + run: | + gsutil cp ./sauce-cypress-macos.zip gs://${{ secrets.GCS_RUNNER_BUCKET }}/sauce-cypress-macos-${{ github.run_id }}.zip + + - name: Test on Sauce (Kitchen Sink) + working-directory: ./tests/kitchen-sink-tests + run: | + npx saucectl run --config .sauce/config_on_sauce_mac.yml --runner-version "url: https://storage.googleapis.com/${{ secrets.GCS_RUNNER_BUCKET }}/sauce-cypress-macos-${{ github.run_id }}.zip" + run-bundle-with-sauce-connect: runs-on: ubuntu-latest - needs: [build-windows-bundle-and-test] + needs: [build-windows-bundle-and-test, build-mac-bundle-and-test] steps: - name: Checkout runner uses: actions/checkout@v2 @@ -124,7 +171,12 @@ jobs: tunnelIdentifier: github-cypress-sc-check-tunnel scVersion: 4.7.1 - - name: run saucectl + - name: run saucectl (Windows) run: | saucectl run --config .sauce/config.yml --runner-version "url: https://storage.googleapis.com/${{ secrets.GCS_RUNNER_BUCKET }}/sauce-cypress-runner-${{ github.run_id }}.zip" working-directory: ./tests/sauce-connect/ + + - name: run saucectl (MacOS) + run: | + saucectl run --config .sauce/config_mac.yml --runner-version "url: https://storage.googleapis.com/${{ secrets.GCS_RUNNER_BUCKET }}/sauce-cypress-macos-${{ github.run_id }}.zip" + working-directory: ./tests/sauce-connect/ diff --git a/package-lock.json b/package-lock.json index 911ccce0..98b2b51e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3051,9 +3051,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001239", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001239.tgz", - "integrity": "sha512-cyBkXJDMeI4wthy8xJ2FvDU6+0dtcZSJW3voUF8+e9f1bBeuvyZfc3PNbkOETyhbR+dGCPzn9E7MA3iwzusOhQ==", + "version": "1.0.30001304", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001304.tgz", + "integrity": "sha512-bdsfZd6K6ap87AGqSHJP/s1V+U6Z5lyrcbBu3ovbCCf8cSYpwTtGrCBObMpJqwxfTbLW6YTIdbb1jEeTelcpYQ==", "dev": true, "funding": { "type": "opencollective", @@ -24226,9 +24226,9 @@ "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==" }, "caniuse-lite": { - "version": "1.0.30001239", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001239.tgz", - "integrity": "sha512-cyBkXJDMeI4wthy8xJ2FvDU6+0dtcZSJW3voUF8+e9f1bBeuvyZfc3PNbkOETyhbR+dGCPzn9E7MA3iwzusOhQ==", + "version": "1.0.30001304", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001304.tgz", + "integrity": "sha512-bdsfZd6K6ap87AGqSHJP/s1V+U6Z5lyrcbBu3ovbCCf8cSYpwTtGrCBObMpJqwxfTbLW6YTIdbb1jEeTelcpYQ==", "dev": true }, "capital-case": { diff --git a/tests/kitchen-sink-tests/.sauce/config_on_sauce.yml b/tests/kitchen-sink-tests/.sauce/config_on_sauce.yml index 545e6f7e..d6600307 100644 --- a/tests/kitchen-sink-tests/.sauce/config_on_sauce.yml +++ b/tests/kitchen-sink-tests/.sauce/config_on_sauce.yml @@ -15,7 +15,8 @@ cypress: version: 8.3.0 suites: - - name: "kitchen-sink on Sauce" + - name: "kitchen-sink on Sauce (Windows)" + platformName: "Windows 10" browser: "chrome" config: testFiles: [ "examples/*.*" ] diff --git a/tests/kitchen-sink-tests/.sauce/config_on_sauce_mac.yml b/tests/kitchen-sink-tests/.sauce/config_on_sauce_mac.yml new file mode 100644 index 00000000..d4568cf3 --- /dev/null +++ b/tests/kitchen-sink-tests/.sauce/config_on_sauce_mac.yml @@ -0,0 +1,22 @@ +apiVersion: v1alpha +kind: cypress +sauce: + metadata: + tags: + - e2e + - release team + - kitchen-sink + build: Release $CI_COMMIT_SHORT_SHA + region: us-west-1 +defaults: + mode: sauce +cypress: + configFile: cypress.json + version: 9.3.1 + +suites: + - name: "kitchen-sink on Sauce (MacOS)" + platformName: "macOS 11.00" + browser: "chrome" + config: + testFiles: [ "examples/*.*" ] diff --git a/tests/post-release/.sauce/config_mac.yml b/tests/post-release/.sauce/config_mac.yml new file mode 100644 index 00000000..8a163850 --- /dev/null +++ b/tests/post-release/.sauce/config_mac.yml @@ -0,0 +1,31 @@ +apiVersion: v1alpha +kind: cypress +sauce: + region: us-west-1 + concurrency: 2 + metadata: + tags: + - e2e + - post release + build: Github Run $GITHUB_RUN_ID +cypress: + configFile: cypress.json + version: 9.3.1 +rootDir: ./ + +suites: + - name: "Post Release Test (MacOS) 1/2" + browser: "chrome" + platformName: "macOS 11.00" + config: + testFiles: [ "**/*.spec.js" ] + - name: "Post Release Test (MacOS) 2/2" + browser: "firefox" + platformName: "macOS 11.00" + config: + testFiles: [ "**/*.spec.js" ] + +notifications: + slack: + channels: ["devx"] + send: fail diff --git a/tests/post-release/.sauce/config.yml b/tests/post-release/.sauce/config_win.yml similarity index 72% rename from tests/post-release/.sauce/config.yml rename to tests/post-release/.sauce/config_win.yml index 02167918..779e2355 100644 --- a/tests/post-release/.sauce/config.yml +++ b/tests/post-release/.sauce/config_win.yml @@ -15,13 +15,18 @@ cypress: configFile: "cypress.json" rootDir: ./ suites: - - name: "Post Release Test 1/2" + - name: "Post Release Test (Windows) 1/2" browser: "chrome" platformName: "Windows 10" config: - testFiles: [ "**/*.*" ] - - name: "Post Release Test 2/2" + testFiles: [ "**/*.spec.js" ] + - name: "Post Release Test (Windows) 2/2" browser: "firefox" platformName: "Windows 10" config: - testFiles: [ "**/*.*" ] + testFiles: [ "**/*.spec.js" ] + +notifications: + slack: + channels: ["devx"] + send: fail diff --git a/tests/sauce-connect/.sauce/config.yml b/tests/sauce-connect/.sauce/config.yml index 34aba2af..2422878f 100644 --- a/tests/sauce-connect/.sauce/config.yml +++ b/tests/sauce-connect/.sauce/config.yml @@ -15,7 +15,7 @@ cypress: version: 8.6.0 suites: - - name: "kitchen-sink on Sauce" + - name: "kitchen-sink on Sauce (Windows)" browser: "chrome" config: - testFiles: [ "*.*" ] + testFiles: [ "*.spec.js" ] diff --git a/tests/sauce-connect/.sauce/config_mac.yml b/tests/sauce-connect/.sauce/config_mac.yml new file mode 100644 index 00000000..a13bdc0a --- /dev/null +++ b/tests/sauce-connect/.sauce/config_mac.yml @@ -0,0 +1,21 @@ +apiVersion: v1alpha +kind: cypress +sauce: + metadata: + tags: + - sauce-connect + build: Pre-Release sauce-connect test + region: us-west-1 + tunnel: + name: github-cypress-sc-check-tunnel +defaults: + mode: sauce +cypress: + configFile: cypress.json + version: 9.3.1 +suites: + - name: "kitchen-sink on Sauce (MacOS)" + platformName: "macOS 11.00" + browser: "chrome" + config: + testFiles: [ "*.spec.js" ]