Skip to content

Commit

Permalink
ci: migrate saucelabs and browserstack tests to GHA
Browse files Browse the repository at this point in the history
Move Browsestack and Saucelabs testing from CircleCI to GHA
  • Loading branch information
josephperrott committed Oct 3, 2023
1 parent 47ac55f commit 54d8e0c
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 52 deletions.
45 changes: 0 additions & 45 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,47 +205,6 @@ jobs:
- run: bazel test --build_tag_filters=-e2e --test_tag_filters=-e2e --build_tests_only -- src/...
- *slack_notify_on_failure

# ----------------------------------------------------------------------------
# Job that runs the unit tests on Browserstack. The browsers that will be used
# to run the unit tests on Browserstack are set in: test/browser-providers.js
# ----------------------------------------------------------------------------
tests_browserstack:
<<: *job_defaults
resource_class: xlarge
environment:
BROWSER_STACK_USERNAME: 'angulardevops_uNDx4q'
BROWSER_STACK_ACCESS_KEY: 'PXeXP2qrTvRooAFG7DPW'
steps:
- checkout_and_rebase
- *restore_cache
- *setup_bazel_ci_config
- *yarn_install

- run: ./scripts/circleci/run-browserstack-tests.sh
- *slack_notify_on_failure

# ----------------------------------------------------------------------------
# Job that runs the unit tests on Saucelabs. The browsers that will be used
# to run the unit tests on Saucelabs are set in: test/browser-providers.js
# ----------------------------------------------------------------------------
tests_saucelabs:
<<: *job_defaults
resource_class: xlarge
environment:
SAUCE_USERNAME: 'angular-components'
SAUCE_ACCESS_KEY: '687f2bb5cacc-3bcb-5b64-8e8a-3825fc13'
# Note: This number should not be too high because otherwise we might run into
# a rate limit exception.
KARMA_PARALLEL_BROWSERS: 2
steps:
- checkout_and_rebase
- *restore_cache
- *setup_bazel_ci_config
- *yarn_install

- run: ./scripts/circleci/run-saucelabs-tests.sh
- *slack_notify_on_failure

# -------------------------------------------------------------------------------------------
# Job that builds all release packages. The built packages can be then used in the same
# workflow to publish snapshot builds.
Expand Down Expand Up @@ -451,10 +410,6 @@ workflows:
filters: *ignore_presubmit_branch_filter
- tests_browsers:
filters: *ignore_presubmit_branch_filter
- tests_browserstack:
filters: *ignore_presubmit_branch_filter
- tests_saucelabs:
filters: *ignore_presubmit_branch_filter
- build_release_packages:
filters: *ignore_presubmit_branch_filter
- upload_release_packages:
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/ci-privileged.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CI

on:
push:
pull_request_target:
types: [opened, synchronize, reopened]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true

permissions: {}

defaults:
run:
shell: bash

jobs:
saucelabs:
runs-on: ubuntu-latest-8core
env:
SAUCE_USERNAME: ${{ vars.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
KARMA_PARALLEL_BROWSERS: 2
CI_NODE_INDEX: 0
CI_NODE_TOTAL: 1
CI_RUNNER_NUMBER: ${{ github.run_id }}
steps:
- name: Initialize environment
uses: angular/dev-infra/github-actions/npm/checkout-and-setup-node@ba9b4487ced515e5b4d87edd681a3bd9792444d6
with:
cache-node-modules: true
# Checking out the pull request commit is intended here as we need to run the changed code tests.
ref: ${{ github.event.pull_request.head.sha }}
- name: Install node modules
run: yarn install --frozen-lockfile
- name: Setup Bazel
uses: angular/dev-infra/github-actions/bazel/setup@ba9b4487ced515e5b4d87edd681a3bd9792444d6
- name: Run tests on Saucelabs
run: ./scripts/circleci/run-saucelabs-tests.sh

browserstack:
runs-on: ubuntu-latest-8core
env:
BROWSER_STACK_USERNAME: ${{ vars.BROWSER_STACK_USERNAME }}
BROWSER_STACK_ACCESS_KEY: ${{ secrets.BROWSER_STACK_ACCESS_KEY }}
KARMA_PARALLEL_BROWSERS: 2
CI_NODE_INDEX: 0
CI_NODE_TOTAL: 1
CI_RUNNER_NUMBER: ${{ github.run_id }}
steps:
- name: Initialize environment
uses: angular/dev-infra/github-actions/npm/checkout-and-setup-node@ba9b4487ced515e5b4d87edd681a3bd9792444d6
with:
cache-node-modules: true
# Checking out the pull request commit is intended here as we need to run the changed code tests.
ref: ${{ github.event.pull_request.head.sha }}
- name: Install node modules
run: yarn install --frozen-lockfile
- name: Setup Bazel
uses: angular/dev-infra/github-actions/bazel/setup@ba9b4487ced515e5b4d87edd681a3bd9792444d6
- name: Run tests on Browserstack
run: ./scripts/circleci/run-browserstack-tests.sh
4 changes: 2 additions & 2 deletions scripts/saucelabs/start-tunnel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ rm ${tunnelFileName}
# Command arguments that will be passed to sauce-connect.
sauceArgs="--readyfile ${tunnelReadyFile} --pidfile ${tunnelPidFile}"

if [ ! -z "${CIRCLE_BUILD_NUM}" ]; then
sauceArgs="${sauceArgs} --tunnel-identifier angular-material-${CIRCLE_BUILD_NUM}-${CIRCLE_NODE_INDEX}"
if [ ! -z "${CI_RUNNER_NUMBER}" ]; then
sauceArgs="${sauceArgs} --tunnel-identifier angular-material-${CI_RUNNER_NUMBER}-${CI_NODE_INDEX}"
fi

echo "Starting Sauce Connect in the background. Passed arguments: ${sauceArgs}"
Expand Down
10 changes: 5 additions & 5 deletions test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ module.exports = config => {
},
});

if (process.env['CIRCLECI']) {
const containerInstanceIndex = Number(process.env['CIRCLE_NODE_INDEX']);
const maxParallelContainerInstances = Number(process.env['CIRCLE_NODE_TOTAL']);
const tunnelIdentifier = `angular-material-${process.env['CIRCLE_BUILD_NUM']}-${containerInstanceIndex}`;
const buildIdentifier = `circleci-${tunnelIdentifier}`;
if (process.env['CI']) {
const containerInstanceIndex = Number(process.env['CI_NODE_INDEX']) || 0;
const maxParallelContainerInstances = Number(process.env['CI_NODE_TOTAL']) || 1;
const tunnelIdentifier = `angular-material-${process.env['CI_RUNNER_NUMBER']}-${containerInstanceIndex}`;
const buildIdentifier = `ci-${tunnelIdentifier}`;
const testPlatform = process.env['TEST_PLATFORM'];

// This defines how often a given browser should be launched in the same CircleCI
Expand Down

0 comments on commit 54d8e0c

Please sign in to comment.