Skip to content

Commit

Permalink
[DEVX-1470] Add bundle+tests on MacOS (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
FriggaHel authored Feb 2, 2022
1 parent 886e465 commit 78a7ac8
Show file tree
Hide file tree
Showing 10 changed files with 244 additions and 47 deletions.
1 change: 0 additions & 1 deletion .github/workflows/kitchen-sink.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""
128 changes: 97 additions & 31 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}]
}]
}
56 changes: 54 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion tests/kitchen-sink-tests/.sauce/config_on_sauce.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/*.*" ]
22 changes: 22 additions & 0 deletions tests/kitchen-sink-tests/.sauce/config_on_sauce_mac.yml
Original file line number Diff line number Diff line change
@@ -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/*.*" ]
31 changes: 31 additions & 0 deletions tests/post-release/.sauce/config_mac.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions tests/sauce-connect/.sauce/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
21 changes: 21 additions & 0 deletions tests/sauce-connect/.sauce/config_mac.yml
Original file line number Diff line number Diff line change
@@ -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" ]

0 comments on commit 78a7ac8

Please sign in to comment.