Skip to content

Commit f933524

Browse files
josephperrottalxhub
authored andcommitted
ci: migrate saucelabs bazel job to Github Actions (angular#51945)
Use Github Actions to run saucelabs bazel jobs PR Close angular#51945
1 parent fe81ff8 commit f933524

3 files changed

Lines changed: 32 additions & 45 deletions

File tree

.circleci/config.yml

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -249,33 +249,6 @@ jobs:
249249
- ./ng
250250
- ./bazel_repository_cache
251251

252-
# NOTE: This is currently limited to main builds only. See the `monitoring` configuration.
253-
saucelabs:
254-
executor:
255-
name: default-executor
256-
# In order to avoid the bottleneck of having a slow host machine, we acquire a better
257-
# container for this job. This is necessary because we launch a lot of browsers concurrently
258-
# and therefore the tunnel and Karma need to process a lot of file requests and tests.
259-
resource_class: xlarge
260-
environment:
261-
NUMBER_OF_PARALLEL_BROWSERS: 2
262-
steps:
263-
- custom_attach_workspace
264-
- init_environment
265-
- init_saucelabs_environment
266-
- run:
267-
name: Start Saucelabs daemon service
268-
command: yarn bazel run //tools/saucelabs-daemon/background-service -- ${NUMBER_OF_PARALLEL_BROWSERS}
269-
background: true
270-
- run:
271-
name: Run Bazel tests on Saucelabs
272-
command: |
273-
TESTS=$(./node_modules/.bin/bazelisk query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "fixme-saucelabs", ...)')
274-
yarn bazel test --config=saucelabs --jobs=${NUMBER_OF_PARALLEL_BROWSERS} ${TESTS}
275-
no_output_timeout: 40m
276-
- notify_webhook_on_fail:
277-
webhook_url_env_var: SLACK_DEV_INFRA_CI_FAILURES_WEBHOOK_URL
278-
279252
# The `build-npm-packages` tasks exist for backwards-compatibility with old scripts and
280253
# tests that rely on the pre-Bazel `dist/packages-dist` output structure (build.sh).
281254
# Having multiple jobs that independently build in this manner duplicates some work; we build
@@ -375,21 +348,3 @@ workflows:
375348
# Get the artifacts to publish from the build-packages-dist job
376349
# since the publishing script expects the legacy outputs layout.
377350
- build-npm-packages
378-
379-
monitoring:
380-
jobs:
381-
- setup
382-
- saucelabs:
383-
# Testing saucelabs via Bazel currently taking longer than the legacy saucelabs job as it
384-
# each karma_web_test target is provisioning and tearing down browsers which is adding
385-
# a lot of overhead. Running once daily in the main branch to avoid wasting resources and
386-
# slowing down CI for PRs.
387-
# TODO: Run this job on all branches (including PRs) once karma_web_test targets can
388-
# share provisioned browsers and we can remove the legacy saucelabs job.
389-
requires:
390-
- setup
391-
triggers:
392-
- schedule:
393-
<<: *only_on_main_branch
394-
# Runs monitoring jobs at 10:00AM every day.
395-
cron: '0 10 * * *'

.github/workflows/ci-privileged.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,31 @@ jobs:
6262
run: KARMA_WEB_TEST_MODE=SL_REQUIRED yarn karma start ./karma-js.conf.js --single-run
6363
- name: Stop Saucelabs tunnel service
6464
run: ./tools/saucelabs/sauce-service.sh stop
65+
66+
bazel-saucelabs:
67+
runs-on: ubuntu-latest-4core
68+
env:
69+
JOBS: 2
70+
steps:
71+
- name: Initialize environment
72+
uses: angular/dev-infra/github-actions/npm/checkout-and-setup-node@1befe6d24fd5cab818e7f8bada40ab364781b8a8
73+
with:
74+
cache-node-modules: true
75+
# Checking out the pull request commit is intended here as we need to run the changed code tests.
76+
ref: ${{ github.event.pull_request.head.sha }}
77+
- name: Install node modules
78+
run: yarn install --frozen-lockfile
79+
- name: Setup Bazel
80+
uses: angular/dev-infra/github-actions/bazel/setup@1befe6d24fd5cab818e7f8bada40ab364781b8a8
81+
- name: Setup Bazel Remote Caching
82+
uses: angular/dev-infra/github-actions/bazel/configure-remote@ba9b4487ced515e5b4d87edd681a3bd9792444d6
83+
- name: Set up Sauce Tunnel Daemon
84+
run: yarn bazel run //tools/saucelabs-daemon/background-service -- $JOBS &
85+
env:
86+
SAUCE_TUNNEL_IDENTIFIER: angular-framework-${{ github.run_number }}
87+
SAUCE_USERNAME: ${{ vars.SAUCE_USERNAME }}
88+
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
89+
- name: Run all saucelabs bazel tests
90+
run: |
91+
TESTS=$(./node_modules/.bin/bazelisk query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "fixme-saucelabs", ...)')
92+
yarn bazel test --config=saucelabs --jobs=$JOBS ${TESTS}

tools/defaults.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,10 @@ def karma_web_test_suite(
338338
tags = tags + [
339339
"manual",
340340
"no-remote-exec",
341+
# Requires network to be able to access saucelabs daemon
342+
"requires-network",
343+
# Prevent the sandbox from being used so that it can communicate with the saucelabs daemon
344+
"no-sandbox",
341345
"saucelabs",
342346
],
343347
configuration_env_vars = ["KARMA_WEB_TEST_MODE"],

0 commit comments

Comments
 (0)