Skip to content

Commit

Permalink
ci: migrate saucelabs tests to GHA
Browse files Browse the repository at this point in the history
Move Saucelabs testing from CircleCI to GHA
  • Loading branch information
josephperrott committed Oct 3, 2023
1 parent 47ac55f commit 1046da2
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 8 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/ci-privileged.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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-4core
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 in Saucelabs
run: ./scripts/circleci/run-saucelabs-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
12 changes: 6 additions & 6 deletions test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ 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}`;
const testPlatform = process.env['TEST_PLATFORM'];
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 = 'saucelabs';

// This defines how often a given browser should be launched in the same CircleCI
// container. This is helpful if we want to shard tests across the same browser.
Expand Down

0 comments on commit 1046da2

Please sign in to comment.