Skip to content

Commit e12a102

Browse files
josephperrottatscott
authored andcommitted
ci: migrate snapshot publishing from CircleCI to GHA (angular#51957)
Migrate the snapshot publishing from CircleCI to GHA PR Close angular#51957
1 parent 2da3551 commit e12a102

3 files changed

Lines changed: 26 additions & 341 deletions

File tree

.circleci/config.yml

Lines changed: 6 additions & 340 deletions
Original file line numberDiff line numberDiff line change
@@ -1,350 +1,16 @@
1-
# Configuration file for https://circleci.com/gh/angular/angular
1+
# This config is remaining in place to prevent pull requests failing because of CircleCI config missing.
22

3-
# Note: YAML anchors allow an object to be re-used, reducing duplication.
4-
# The ampersand declares an alias for an object, then later the `<<: *name`
5-
# syntax dereferences it.
6-
# See https://blog.daemonl.com/2016/02/yaml.html
7-
# To validate changes, use an online parser, eg.
8-
# https://yaml-online-parser.appspot.com/
9-
10-
# CircleCI configuration version
11-
# Version 2.1 allows for extra config reuse features
12-
# https://circleci.com/docs/2.0/reusing-config/#getting-started-with-config-reuse
133
version: 2.1
144

15-
# We don't want to include the current branch name in the cache key because that would prevent
16-
# PRs from being able to restore the cache since the branch names are always different for PRs.
17-
# The cache key should only consist of dynamic values that change whenever something in the
18-
# cache changes. For example:
19-
# 1) yarn lock file changes --> cached "node_modules" are different.
20-
# 2) bazel repository definitions change --> cached bazel repositories are different.
21-
# Windows needs its own cache key because binaries in node_modules are different.
22-
# **NOTE 1 **: In order to avoid the cache from growing indefinitely and causing slow-downs, we invalidate the cache monthly.
23-
# (See https://support.circleci.com/hc/en-us/articles/360012618473-Creating-a-daily-cache.)
24-
# **NOTE 2 **: If you change the cache key prefix, also sync the cache_key_fallback to match.
25-
# **NOTE 3 **: Keep the static part of the cache key as prefix to enable correct fallbacks.
26-
# **NOTE 4 **: To make sure modified patches can be applied without needing to manually update the cache key,
27-
# the fallback cache key will not match if patches have been modified.
28-
# See https://circleci.com/docs/2.0/caching/#restoring-cache for how prefixes work in CircleCI.
29-
var_3: &cache_key v8-angular-node-16-{{ checksum "month.txt" }}-{{ checksum "patches.hash"}}-{{ checksum ".bazelversion" }}-{{ checksum "yarn.lock" }}-{{ checksum "WORKSPACE" }}-{{ checksum "aio/yarn.lock" }}
30-
# We invalidate the cache if the Bazel version changes because otherwise the `bazelisk` cache
31-
# folder will contain all previously used versions and ultimately cause the cache restoring to
32-
# be slower due to its growing size.
33-
var_4: &cache_key_fallback v8-angular-node-16-{{ checksum "month.txt" }}-{{ checksum "patches.hash"}}-{{ checksum ".bazelversion" }}
34-
35-
# Windows needs its own cache key because binaries in node_modules are different.
36-
var_3_win: &cache_key_win v10-angular-win-node-16-{{ checksum "month.txt" }}-{{ checksum "patches.hash"}}-{{ checksum ".bazelversion" }}-{{ checksum "yarn.lock" }}-{{ checksum "WORKSPACE" }}
37-
var_4_win: &cache_key_win_fallback v10-angular-win-node-16-{{ checksum "month.txt" }}-{{ checksum "patches.hash"}}-{{ checksum ".bazelversion" }}
38-
39-
# Workspace initially persisted by the `setup` job, and then enhanced by `build-npm-packages`.
40-
# https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs
41-
# https://circleci.com/blog/deep-diving-into-circleci-workspaces/
42-
var_5: &workspace_location ~/
43-
44-
# Filter to run a job on builds for pull requests only.
45-
var_6: &only_on_pull_requests
46-
filters:
47-
branches:
48-
only:
49-
- /pull\/\d+/
50-
51-
# Filter to skip a job on builds for pull requests.
52-
var_7: &skip_on_pull_requests
53-
filters:
54-
branches:
55-
ignore:
56-
- /pull\/\d+/
57-
58-
# Filter to run a job on builds for the main branch only.
59-
var_8: &only_on_main_branch
60-
filters:
61-
branches:
62-
only:
63-
- main
64-
65-
# Filter to run a job on all releasable branches.
66-
var_9: &only_release_branches
67-
filters:
68-
branches:
69-
only:
70-
- main
71-
- /\d+\.\d+\.x/
72-
73-
# CircleCI orbs
74-
# https://circleci.com/developer/orbs.
75-
orbs:
76-
node: circleci/node@5.0.1
77-
devinfra: angular/dev-infra@1.0.8
78-
79-
# Executor Definitions
80-
# https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-executors
81-
# **NOTE 1**: Pin to exact images using an ID (SHA). See https://circleci.com/docs/2.0/circleci-images/#using-a-docker-image-id-to-pin-an-image-to-a-fixed-version.
82-
# (Using the tag in not necessary when pinning by ID, but include it anyway for documentation purposes.)
83-
# **NOTE 2**: If you change the version of the docker images, also change the `cache_key` suffix.
84-
# **NOTE 3**: If you change the version of Node.js provided by the docker images, also update `.devcontainer/recommended-Dockerfile` to match the new version.
85-
executors:
86-
default-executor:
87-
parameters:
88-
resource_class:
89-
type: string
90-
default: medium
91-
docker:
92-
- image: cimg/node:18.13.0
93-
resource_class: << parameters.resource_class >>
94-
working_directory: ~/ng
95-
96-
test-browser-executor:
97-
parameters:
98-
resource_class:
99-
type: string
100-
default: medium
101-
docker:
102-
- image: cimg/node:18.13.0-browsers
103-
resource_class: << parameters.resource_class >>
104-
working_directory: ~/ng
105-
106-
windows-executor:
107-
working_directory: ~/ng
108-
resource_class: windows.2xlarge
109-
shell: bash
110-
machine:
111-
image: windows-server-2019-vs2019:201908-02
112-
113-
# Command Definitions
114-
# https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-commands
115-
commands:
116-
custom_attach_workspace:
117-
description: Attach workspace at a predefined location
118-
steps:
119-
- attach_workspace:
120-
at: *workspace_location
121-
122-
# Install java runtime which is required by some integration tests such as
123-
# //integration:hello_world__closure_test, //integration:i18n_test and
124-
# //integration:ng_elements_test to run the closure compiler
125-
install_java:
126-
description: Install java
127-
steps:
128-
- run:
129-
name: Install java
130-
command: |
131-
sudo apt-get update
132-
# Install java runtime
133-
sudo apt-get install default-jre
134-
135-
# Initializes the CI environment by setting up common environment variables.
136-
init_environment:
137-
description: Initializing environment (setting up variables)
138-
steps:
139-
- run:
140-
name: Set up environment
141-
environment:
142-
CIRCLE_GIT_BASE_REVISION: << pipeline.git.base_revision >>
143-
CIRCLE_GIT_REVISION: << pipeline.git.revision >>
144-
command: ./.circleci/env.sh
145-
- devinfra/setup-bazel-remote-exec
146-
- run:
147-
# Configure git as the CircleCI `checkout` command does.
148-
# This is needed because we only checkout on the setup job.
149-
# Add GitHub to known hosts
150-
name: Configure git
151-
command: |
152-
mkdir -p ~/.ssh
153-
echo 'github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=' >> ~/.ssh/known_hosts
154-
git config --global url."ssh://git@github.com".insteadOf "https://github.com" || true
155-
git config --global gc.auto 0 || true
156-
157-
init_saucelabs_environment:
158-
description: Sets up a domain that resolves to the local host.
159-
steps:
160-
- run:
161-
name: Preparing environment for running tests on Sauce Labs.
162-
command: |
163-
# For SauceLabs jobs, we set up a domain which resolves to the machine which launched
164-
# the tunnel. We do this because devices are sometimes not able to properly resolve
165-
# `localhost` or `127.0.0.1` through the SauceLabs tunnel. Using a domain that does not
166-
# resolve to anything on SauceLabs VMs ensures that such requests are always resolved
167-
# through the tunnel, and resolve to the actual tunnel host machine (i.e. the CircleCI VM).
168-
# More context can be found in: https://github.com/angular/angular/pull/35171.
169-
setPublicVar SAUCE_LOCALHOST_ALIAS_DOMAIN "angular-ci.local"
170-
setSecretVar SAUCE_ACCESS_KEY $(echo $SAUCE_ACCESS_KEY | rev)
171-
- run:
172-
# Sets up a local domain in the machine's host file that resolves to the local
173-
# host. This domain is helpful in Sauce Labs tests where devices are not able to
174-
# properly resolve `localhost` or `127.0.0.1` through the sauce-connect tunnel.
175-
name: Setting up alias domain for local host.
176-
command: echo "127.0.0.1 $SAUCE_LOCALHOST_ALIAS_DOMAIN" | sudo tee -a /etc/hosts
177-
178-
save_month_to_file:
179-
description: Store the current year and month in a file, so that it can be used for computing the cache key.
180-
steps:
181-
- run:
182-
name: Save month to file
183-
# Note: Make sure this file is excluded in the `.gitignore` as otherwise the
184-
# snapshot stamping would have the `-with-local-changes` suffix.
185-
command: date +%Y-%m > month.txt
186-
187-
capture_patches_for_cache_key:
188-
description: Hashes all patches so that the cache can be reset upon changes.
189-
steps:
190-
- run: |
191-
md5sum tools/esm-interop/patches/npm/* > patches.hash
192-
193-
yarn_install:
194-
description: Install dependencies
195-
steps:
196-
- run:
197-
name: Running Yarn install
198-
command: yarn install --frozen-lockfile --non-interactive --cache-folder ~/.cache/yarn
199-
# Yarn's requests sometimes take more than 10mins to complete (especially on Windows).
200-
no_output_timeout: 45m
201-
202-
notify_webhook_on_fail:
203-
description: Notify a webhook about failure
204-
parameters:
205-
# `webhook_url_env_var` are secret env vars defined in CircleCI project settings.
206-
# The URLs come from https://angular-team.slack.com/apps/A0F7VRE7N-circleci.
207-
webhook_url_env_var:
208-
type: env_var_name
209-
steps:
210-
- run:
211-
when: on_fail
212-
command: |
213-
notificationJson="{\"text\":\":x: \`$CIRCLE_JOB\` job for $CIRCLE_BRANCH branch failed on build $CIRCLE_BUILD_NUM: $CIRCLE_BUILD_URL :scream:\"}"
214-
curl --request POST --header "Content-Type: application/json" --data "$notificationJson" ${<< parameters.webhook_url_env_var >>}
215-
216-
# Job definitions
217-
# Jobs can include parameters that are passed in the workflow job invocation.
218-
# https://circleci.com/docs/2.0/reusing-config/#authoring-parameterized-jobs
2195
jobs:
220-
setup:
221-
executor: default-executor
222-
steps:
223-
- checkout
224-
- save_month_to_file
225-
- capture_patches_for_cache_key
226-
- init_environment
227-
- devinfra/rebase-pr-on-target-branch:
228-
base_revision: << pipeline.git.base_revision >>
229-
head_revision: << pipeline.git.revision >>
230-
# This cache is saved in the build-npm-packages so that Bazel cache is also included.
231-
- restore_cache:
232-
keys:
233-
- *cache_key
234-
- *cache_key_fallback
235-
- yarn_install
236-
- run: yarn --cwd aio install --frozen-lockfile --non-interactive --cache-folder ~/.cache/yarn
237-
# Make the bazel directories and add a file to them if they don't exist already so that
238-
# persist_to_workspace does not fail.
239-
- run: |
240-
if [ ! -d ~/bazel_repository_cache ]; then
241-
mkdir ~/bazel_repository_cache
242-
touch ~/bazel_repository_cache/MARKER
243-
fi
244-
# Persist any changes at this point to be reused by further jobs.
245-
# **NOTE**: To add new content to the workspace, always persist on the same root.
246-
- persist_to_workspace:
247-
root: *workspace_location
248-
paths:
249-
- ./ng
250-
- ./bazel_repository_cache
251-
252-
# The `build-npm-packages` tasks exist for backwards-compatibility with old scripts and
253-
# tests that rely on the pre-Bazel `dist/packages-dist` output structure (build.sh).
254-
# Having multiple jobs that independently build in this manner duplicates some work; we build
255-
# the bazel packages more than once. Even though we have a remote cache, these jobs will
256-
# typically run in parallel so up-to-date outputs will not be available at the time the build
257-
# starts.
258-
build-npm-packages:
259-
executor:
260-
name: default-executor
261-
resource_class: xlarge
262-
steps:
263-
- custom_attach_workspace
264-
- init_environment
265-
- run: yarn build
266-
267-
# Save the npm packages from //packages/... for other workflow jobs to read
268-
- persist_to_workspace:
269-
root: *workspace_location
270-
paths:
271-
- ng/dist/packages-dist
272-
- ng/dist/angular-in-memory-web-api-dist
273-
- ng/dist/zone.js-dist
274-
275-
# Save dependencies and bazel repository cache to use on subsequent runs.
276-
- save_cache:
277-
key: *cache_key
278-
paths:
279-
- ~/.cache/yarn
280-
- ~/bazel_repository_cache
281-
- ~/.cache/bazelisk
282-
283-
# This job updates the content of repos like github.com/angular/core-builds
284-
# for every green build on angular/angular.
285-
publish_snapshot:
286-
executor: default-executor
287-
steps:
288-
- custom_attach_workspace
289-
- init_environment
290-
# CircleCI has a config setting to force SSH for all github connections
291-
# This is not compatible with our mechanism of using a Personal Access Token
292-
# Clear the global setting
293-
- run: git config --global --unset "url.ssh://git@github.com.insteadof"
294-
- run:
295-
name: Prepare GitHub credentials
296-
command: echo "https://${SNAPSHOT_BUILDS_GITHUB_TOKEN}:@github.com" > ${HOME}/.git_credentials
297-
- run: ./scripts/ci/publish-build-artifacts.sh
298-
299-
aio_monitoring_stable:
300-
executor: test-browser-executor
301-
steps:
302-
- custom_attach_workspace
303-
- init_environment
304-
- run: setPublicVar_CI_STABLE_BRANCH
305-
- run:
306-
name: Check out `aio/` and yarn from the stable branch
307-
command: |
308-
git fetch origin $CI_STABLE_BRANCH
309-
git checkout --force origin/$CI_STABLE_BRANCH -- aio/ .yarn/ .yarnrc
310-
# Ignore yarn's engines check, because we checked out `aio/package.json` from the stable
311-
# branch and there could be a node version skew, which is acceptable in this monitoring job.
312-
- run: yarn config set ignore-engines true
313-
- run:
314-
name: Run tests against https://angular.io/
315-
command: ./aio/scripts/test-production.sh https://angular.io/ $CI_AIO_MIN_PWA_SCORE
316-
- notify_webhook_on_fail:
317-
webhook_url_env_var: SLACK_CARETAKER_WEBHOOK_URL
318-
- notify_webhook_on_fail:
319-
webhook_url_env_var: SLACK_DEV_INFRA_CI_FAILURES_WEBHOOK_URL
320-
321-
aio_monitoring_next:
322-
executor: test-browser-executor
6+
pass:
7+
docker:
8+
- image: cimg/base:2022.05
3239
steps:
324-
- custom_attach_workspace
325-
- init_environment
326-
- run:
327-
name: Run tests against https://next.angular.io/
328-
command: ./aio/scripts/test-production.sh https://next.angular.io/ $CI_AIO_MIN_PWA_SCORE
329-
- notify_webhook_on_fail:
330-
webhook_url_env_var: SLACK_CARETAKER_WEBHOOK_URL
331-
- notify_webhook_on_fail:
332-
webhook_url_env_var: SLACK_DEV_INFRA_CI_FAILURES_WEBHOOK_URL
10+
- run: echo "This too shall pass (always)"
33311

33412
workflows:
33513
version: 2
33614
default_workflow:
33715
jobs:
338-
- setup:
339-
filters:
340-
branches:
341-
ignore: g3
342-
- build-npm-packages:
343-
requires:
344-
- setup
345-
- publish_snapshot:
346-
<<: *only_release_branches
347-
requires:
348-
# Get the artifacts to publish from the build-packages-dist job
349-
# since the publishing script expects the legacy outputs layout.
350-
- build-npm-packages
16+
- pass

.github/workflows/ci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,25 @@ jobs:
195195
env:
196196
SLACK_BOT_TOKEN: ${{ secrets.ANGULAR_ROBOT_SLACK_TOKEN }}
197197

198+
publish-snapshots:
199+
if: github.event_name == 'push'
200+
runs-on:
201+
labels: ubuntu-latest
202+
steps:
203+
- name: Initialize environment
204+
uses: angular/dev-infra/github-actions/npm/checkout-and-setup-node@ba9b4487ced515e5b4d87edd681a3bd9792444d6
205+
with:
206+
cache-node-modules: true
207+
- name: Setup Bazel
208+
uses: angular/dev-infra/github-actions/bazel/setup@ba9b4487ced515e5b4d87edd681a3bd9792444d6
209+
- name: Setup Bazel RBE
210+
uses: angular/dev-infra/github-actions/bazel/configure-remote@ba9b4487ced515e5b4d87edd681a3bd9792444d6
211+
- name: Install node modules
212+
run: yarn install --frozen-lockfile
213+
- run: echo "https://${{secrets.SNAPSHOT_BUILDS_GITHUB_TOKEN}}:@github.com" > ${HOME}/.git_credentials
214+
- run: yarn build
215+
- run: ./scripts/ci/publish-build-artifacts.sh
216+
198217
zone-js:
199218
runs-on:
200219
labels: ubuntu-latest-4core

scripts/ci/publish-build-artifacts.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ function publishAllBuilds() {
152152
}
153153

154154
# See docs/DEVELOPER.md for help
155-
CUR_BRANCH=${CI_BRANCH:-$(git symbolic-ref --short HEAD)}
155+
CUR_BRANCH=$(git symbolic-ref --short HEAD)
156156
if [ $# -gt 0 ]; then
157157
ORG=$1
158158
publishAllBuilds "ssh"

0 commit comments

Comments
 (0)