Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
ci: convert main CI workflow to Github Actions
Browse files Browse the repository at this point in the history
The CircleCI based CI workflow for the main branch and all potential release
branches is now execute via Github Actions.  The CircleCI configuration temporarily is
still present with an automatically passing test to prevent CircleCI failure.
An additional direct build step has also been added to the build job for both PR and
main CI workflows to ensure that the build that occurs during the deployment script
continues to function.
  • Loading branch information
clydin committed Aug 15, 2024
1 parent daae318 commit bd94d53
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 111 deletions.
115 changes: 6 additions & 109 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,119 +1,16 @@
# Note: YAML anchors allow an object to be re-used, reducing duplication.
# The ampersand declares an alias for an object, then later the `<<: *name`
# syntax dereferences it.
# See https://blog.daemonl.com/2016/02/yaml.html
# To validate changes, use an online parser, eg.
# https://yaml-online-parser.appspot.com/
# This config is remaining in place to prevent pull requests failing because of CircleCI config missing.

# CircleCI configuration version
# Version 2.1 allows for extra config reuse features
# https://circleci.com/docs/2.0/reusing-config/#getting-started-with-config-reuse
version: 2.1

orbs:
browser-tools: circleci/[email protected]
devinfra: angular/[email protected]

# Cache key for CircleCI. We want to invalidate the cache whenever the Yarn lock file changes.
var_1: &cache_key material-angular-io-{{ .Branch }}-{{ checksum "yarn.lock" }}
var_2: &default_docker_image cimg/node:20.11.1-browsers

# Settings common to each job
var_3: &job_defaults
working_directory: ~/material-angular-io
docker:
- image: *default_docker_image

var_4: &save_cache
save_cache:
key: *cache_key
paths:
- 'node_modules'

var_5: &yarn_install
run:
name: 'Installing project dependencies'
command: yarn install --immutable
no_output_timeout: 20m

# https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs
# https://circleci.com/blog/deep-diving-into-circleci-workspaces/
var_6: &workspace_location ~/

commands:
store_build_output:
description: 'Stores build artifacts'
steps:
- run:
name: Move compiled apps to workspace
command: |
set -exu
mkdir -p ~/dist
mv dist/* ~/dist/
- persist_to_workspace:
root: *workspace_location
paths:
- dist

jobs:
lint:
<<: *job_defaults
steps:
- checkout
- restore_cache:
key: *cache_key
- *yarn_install
- run: yarn lint
- *save_cache

build:
<<: *job_defaults
# We generate a lot of chunks with our build. To improve stability and to reduce
# the amount it takes to run, we use a higher resource class with better VM specs.
# https://circleci.com/docs/2.0/configuration-reference/#resource_class
resource_class: large
steps:
- checkout
- restore_cache:
key: *cache_key
- *yarn_install
- run: yarn prod-build
- *save_cache
- store_build_output

test:
<<: *job_defaults
steps:
- checkout
- restore_cache:
key: *cache_key
- *yarn_install
- browser-tools/install-browser-tools
- run: yarn test --watch false --progress=false

lighthouse_audits:
<<: *job_defaults
pass:
docker:
- image: cimg/base:2022.05
steps:
- attach_workspace:
at: *workspace_location
- checkout
- browser-tools/install-chrome
- restore_cache:
key: *cache_key
- *yarn_install
- browser-tools/install-browser-tools
- run:
command: yarn test:audit:ci
environment:
CHROMIUM_BIN: '/usr/bin/google-chrome'
- run: echo "This too shall pass (always)"

workflows:
version: 2
default_workflow:
jobs:
- lint
- build
- test
- lighthouse_audits:
requires:
- build
- pass
76 changes: 76 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: CI

on:
push:
branches:
- main
- "[0-9]+.[0-9]+.x"

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

permissions: {}

defaults:
run:
shell: bash

env:
# TODO: Remove when pnpm is exclusively used.
ASPECT_RULES_JS_FROZEN_PNPM_LOCK: "1"

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Initialize environment
uses: angular/dev-infra/github-actions/npm/checkout-and-setup-node@db91da4e742cd081bfba01db2edc4e816018419b
- name: Install node modules
run: yarn install --immutable
- name: Execute Linting
run: yarn bazel test --test_tag_filters=lint //...

build:
runs-on: ubuntu-latest
steps:
- name: Initialize environment
uses: angular/dev-infra/github-actions/npm/checkout-and-setup-node@db91da4e742cd081bfba01db2edc4e816018419b
- name: Install node modules
run: yarn install --immutable
- name: Execute Direct Production Build (deploy usage)
run: yarn prod-build
- name: Execute Build via Bazel
run: yarn bazel build //...

test:
runs-on: ubuntu-latest
steps:
- name: Initialize environment
uses: angular/dev-infra/github-actions/npm/checkout-and-setup-node@db91da4e742cd081bfba01db2edc4e816018419b
- name: Install node modules
run: yarn install --immutable
- name: Execute Tests
run: yarn bazel test --test_tag_filters=-lint,-e2e,-audit //...
- name: Store Test Logs
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
with:
name: test-logs
path: bazel-testlogs/
retention-days: 14

lighthouse:
runs-on: ubuntu-latest
steps:
- name: Initialize environment
uses: angular/dev-infra/github-actions/npm/checkout-and-setup-node@db91da4e742cd081bfba01db2edc4e816018419b
- name: Install node modules
run: yarn install --immutable
- name: Execute Lighthouse Audit
run: yarn bazel test --test_tag_filters=audit //...
- name: Store Audit Logs
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
with:
name: lighthouse-logs
path: bazel-testlogs/
retention-days: 14
6 changes: 4 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defaults:

env:
# TODO: Remove when pnpm is exclusively used.
ASPECT_RULES_JS_FROZEN_PNPM_LOCK: '1'
ASPECT_RULES_JS_FROZEN_PNPM_LOCK: "1"

jobs:
lint:
Expand All @@ -36,7 +36,9 @@ jobs:
uses: angular/dev-infra/github-actions/npm/checkout-and-setup-node@db91da4e742cd081bfba01db2edc4e816018419b
- name: Install node modules
run: yarn install --immutable
- name: Execute Build
- name: Execute Direct Production Build (deploy usage)
run: yarn prod-build
- name: Execute Build via Bazel
run: yarn bazel build //...

test:
Expand Down

0 comments on commit bd94d53

Please sign in to comment.