-
Notifications
You must be signed in to change notification settings - Fork 449
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a3a004
commit 5f8391a
Showing
5 changed files
with
469 additions
and
407 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
# Javascript Node CircleCI 2.0 configuration file | ||
# | ||
# Check https://circleci.com/docs/2.0/language-javascript/ for more details | ||
# | ||
version: 2 | ||
|
||
defaults: &defaults | ||
working_directory: ~/repo | ||
docker: | ||
- image: cimg/node:lts-browsers | ||
|
||
set_env: &set_env | ||
name: Setup Environment Variables | ||
command: | | ||
if [[ $CIRCLE_PULL_REQUEST ]] | ||
then | ||
echo 'Fetching Base Commit from GitHub' | ||
echo 'export CIRCLE_PR_NUMBER="${CIRCLE_PR_NUMBER:-${CIRCLE_PULL_REQUEST##*/}}"' >> $BASH_ENV | ||
source $BASH_ENV | ||
echo "export CIRCLE_PR_BASE_SHA=`curl -s https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/pulls/${CIRCLE_PR_NUMBER} | jq -r '.base.sha'`" >> $BASH_ENV | ||
echo 'export AFFECTED_ARGS="--base ${CIRCLE_PR_BASE_SHA}"' >> $BASH_ENV | ||
else | ||
echo 'Fetching Base Commit from Deploy Cache' | ||
if [[ ! -f dist/last-deploy.txt ]] | ||
then | ||
mkdir dist && git rev-parse HEAD~1 > dist/last-deploy.txt | ||
fi | ||
echo 'export AFFECTED_ARGS="--base $(cat dist/last-deploy.txt)"' >> $BASH_ENV | ||
fi | ||
source $BASH_ENV | ||
echo $AFFECTED_ARGS | ||
node -v | ||
yarn -v | ||
yarn_cache: &yarn_cache | ||
keys: | ||
- node-deps-node16-{{ checksum "yarn.lock" }} | ||
# fallback to using the latest cache if no exact match is found | ||
- node-deps-node16- | ||
|
||
deploy_cache: &deploy_cache | ||
key: last-deploy-sha | ||
|
||
yarn_install: &yarn_install | ||
name: Install Dependencies | ||
command: yarn install --frozen-lockfile --non-interactive | ||
|
||
jobs: | ||
install: | ||
<<: *defaults | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
<<: *yarn_cache | ||
- run: rm -rf node_modules | ||
- run: | ||
<<: *yarn_install | ||
- save_cache: | ||
key: node-deps-node16-{{ checksum "yarn.lock" }} | ||
paths: | ||
- ~/.cache | ||
- node_modules | ||
check-formatting: | ||
<<: *defaults | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
<<: *deploy_cache | ||
- run: | ||
<<: *set_env | ||
- restore_cache: | ||
<<: *yarn_cache | ||
- run: yarn format:check ${AFFECTED_ARGS} | ||
lint: | ||
<<: *defaults | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
<<: *deploy_cache | ||
- run: | ||
<<: *set_env | ||
- restore_cache: | ||
<<: *yarn_cache | ||
- run: yarn affected:lint ${AFFECTED_ARGS} --parallel --exclude shared-assets shared-styles | ||
build: | ||
<<: *defaults | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
<<: *deploy_cache | ||
- run: | ||
<<: *set_env | ||
- restore_cache: | ||
<<: *yarn_cache | ||
- run: yarn affected:build -- ${AFFECTED_ARGS} --parallel --configuration production | ||
- save_cache: | ||
key: build-{{ .Environment.CIRCLE_WORKFLOW_ID }} | ||
paths: | ||
- dist | ||
- store_artifacts: | ||
path: dist | ||
test: | ||
<<: *defaults | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
<<: *deploy_cache | ||
- run: | ||
<<: *set_env | ||
- restore_cache: | ||
<<: *yarn_cache | ||
- run: yarn affected -- -t test ${AFFECTED_ARGS} --parallel -- --ci --runInBand | ||
e2e: | ||
<<: *defaults | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
<<: *deploy_cache | ||
- run: | ||
<<: *set_env | ||
- restore_cache: | ||
<<: *yarn_cache | ||
- run: yarn affected:e2e -- ${AFFECTED_ARGS} --configuration production --parallel false -- --headless | ||
- store_artifacts: | ||
path: dist/cypress | ||
|
||
deploy: | ||
<<: *defaults | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
<<: *deploy_cache | ||
- run: | ||
<<: *set_env | ||
- restore_cache: | ||
<<: *yarn_cache | ||
- restore_cache: | ||
key: build-{{ .Environment.CIRCLE_WORKFLOW_ID }} | ||
- run: yarn affected -- --target deploy ${AFFECTED_ARGS} | ||
- run: git rev-parse HEAD > dist/last-deploy.txt | ||
- save_cache: | ||
key: last-deploy-sha | ||
paths: | ||
- dist/last-deploy.txt | ||
|
||
workflows: | ||
version: 2 | ||
pr_check: | ||
jobs: | ||
- install | ||
- check-formatting: | ||
requires: | ||
- install | ||
- lint: | ||
requires: | ||
- install | ||
- test: | ||
requires: | ||
- install | ||
- build: | ||
requires: | ||
- install | ||
- e2e: | ||
requires: | ||
- install | ||
- deploy: | ||
filters: | ||
branches: | ||
only: | ||
- master | ||
requires: | ||
- check-formatting | ||
- lint | ||
- test | ||
- build | ||
- e2e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
launch-templates: | ||
custom-linux: | ||
resource-class: 'docker_linux_amd64/medium' | ||
image: 'ubuntu22.04-node20.9-v2' | ||
init-steps: | ||
- name: Checkout | ||
uses: 'nrwl/nx-cloud-workflows/v3.1/workflow-steps/checkout/main.yaml' | ||
- name: Restore Node Modules Cache | ||
uses: 'nrwl/nx-cloud-workflows/v3.1/workflow-steps/cache/main.yaml' | ||
env: | ||
KEY: 'package-lock.json|yarn.lock|pnpm-lock.yaml' | ||
PATHS: 'node_modules' | ||
BASE_BRANCH: 'main' | ||
- name: Install Node Modules | ||
uses: 'nrwl/nx-cloud-workflows/v3.1/workflow-steps/install-node-modules/main.yaml' | ||
- name: Install Browsers (if needed) | ||
uses: 'nrwl/nx-cloud-workflows/v3.1/workflow-steps/install-browsers/main.yaml' | ||
- name: Setup Cypress | ||
script: 'yarn cypress install' |
Oops, something went wrong.