Skip to content

Commit

Permalink
[DEVX-1471] Add macOS support (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
FriggaHel authored Feb 2, 2022
1 parent a70edfc commit 4228eae
Show file tree
Hide file tree
Showing 5 changed files with 203 additions and 37 deletions.
129 changes: 98 additions & 31 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
56 changes: 53 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/
37 changes: 37 additions & 0 deletions tests/fixtures/post-release/.sauce/config_mac.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions tests/integration/sauce-connect/.sauce/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 4228eae

Please sign in to comment.