Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👷(global) circleci conditional testing #2131

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 81 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ parameters:
nightly-round:
type: boolean
default: false

aliases:
- &checkout_fun
checkout:
Expand All @@ -36,6 +35,46 @@ aliases:
command: |
sudo apt-get update
sudo apt-get install -y libcairo2-dev
commands:
skip_unchanged:
parameters:
except_branches:
default: master
description: Comma-separated list of git branches where we should never skip tests.
type: string
git_base_branch:
default: origin/master
description: The branch to compare against when looking for changing.
type: string
paths:
description: The paths to look for changes in.
type: string
description: Skip if no changes to "<< parameters.paths >>"
steps:
- *checkout_fun
- run:
name: Check if job should be skipped
# Skip job when there is no diff in the paths
# except when the branch is the base one or the job is run on a tag
command: |
GIT_BASE_BRANCH=<<parameters.git_base_branch>>
PATHS=<<parameters.paths>>
EXCEPT_BRANCHES=<<parameters.except_branches>>
echo "GIT_BASE_BRANCH=$GIT_BASE_BRANCH"
echo "PATHS=$PATHS"
echo "EXCEPT_BRANCHES=$EXCEPT_BRANCHES"

IFS=' ' read -ra paths_arr \<<< "$PATHS"
echo "paths_arr=" "${paths_arr[@]}"

CHANGED_FILES="$(git diff "$GIT_BASE_BRANCH"..."$CIRCLE_BRANCH" --name-only --diff-filter=ACMRT "${paths_arr[@]}")";
echo "CHANGED_FILES=$CHANGED_FILES"

if [[ -n "${CIRCLE_TAG}" ]] || [[ "$EXCEPT_BRANCHES" == *"${CIRCLE_BRANCH}"* ]] || [ -n "${CHANGED_FILES}" ];
then
exit 0;
fi
circleci step halt;
jobs:
# Git jobs
# Check that the git history is clean and complies with our expectations
Expand Down Expand Up @@ -188,7 +227,6 @@ jobs:
password: $DOCKER_PASS
working_directory: ~/fun
steps:
- checkout
- restore_cache:
keys:
- v2-back-dependencies-{{ .Revision }}
Expand All @@ -210,7 +248,6 @@ jobs:
password: $DOCKER_PASS
working_directory: ~/fun/src/richie
steps:
- *checkout_fun
- restore_cache:
keys:
- v2-back-dependencies-{{ .Revision }}
Expand All @@ -236,7 +273,6 @@ jobs:
password: $DOCKER_PASS
working_directory: ~/fun
steps:
- checkout
- restore_cache:
keys:
- v2-back-dependencies-{{ .Revision }}
Expand Down Expand Up @@ -328,7 +364,6 @@ jobs:
REDIS_MASTER_HOST: redis-primary
working_directory: ~/fun
steps:
- checkout
- restore_cache:
keys:
- v2-back-dependencies-{{ .Revision }}
Expand Down Expand Up @@ -421,7 +456,6 @@ jobs:
REDIS_MASTER_HOST: redis-primary
working_directory: ~/fun
steps:
- checkout
- restore_cache:
keys:
- v2-back-dependencies-{{ .Revision }}
Expand Down Expand Up @@ -508,7 +542,6 @@ jobs:
REDIS_MASTER_HOST: redis-primary
working_directory: ~/fun
steps:
- checkout
- restore_cache:
keys:
- v2-back-dependencies-{{ .Revision }}
Expand Down Expand Up @@ -589,7 +622,6 @@ jobs:
REDIS_MASTER_HOST: redis-primary
working_directory: ~/fun
steps:
- checkout
- restore_cache:
keys:
- v2-back-dependencies-{{ .Revision }}
Expand Down Expand Up @@ -682,7 +714,6 @@ jobs:
password: $DOCKER_PASS
working_directory: ~/fun/src/frontend
steps:
- *checkout_fun
- *restore_node_modules
# If the yarn.lock file is not up-to-date with the package.json file,
# using the --frozen-lockfile should fail.
Expand Down Expand Up @@ -715,7 +746,6 @@ jobs:
password: $DOCKER_PASS
working_directory: ~/fun/src/frontend
steps:
- *checkout_fun
- *restore_node_modules
- run:
name: Build front-end application in production mode
Expand All @@ -742,9 +772,8 @@ jobs:
auth:
username: $DOCKER_USER
password: $DOCKER_PASS
working_directory: ~/fun-site-factory/frontend
working_directory: ~/fun/frontend
steps:
- *checkout_fun
- *restore_node_modules
- run:
name: Initialize a frontend project that uses richie-education module
Expand Down Expand Up @@ -854,7 +883,6 @@ jobs:
password: $DOCKER_PASS
working_directory: ~/fun/src/frontend
steps:
- *checkout_fun
- *restore_node_modules
- run:
name: Lint code with eslint
Expand All @@ -873,7 +901,6 @@ jobs:
resource_class: large
working_directory: ~/fun/src/frontend
steps:
- *checkout_fun
- *restore_node_modules
- run:
name: Run tests
Expand All @@ -885,9 +912,8 @@ jobs:
auth:
username: $DOCKER_USER
password: $DOCKER_PASS
working_directory: ~/wrk
working_directory: ~/fun
steps:
- *checkout_fun
- run:
name: Check SCSS library
command: |
Expand All @@ -910,7 +936,6 @@ jobs:
password: $DOCKER_PASS
working_directory: ~/fun
steps:
- *checkout_fun
- run:
name: Authenticate with registry
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/fun/.npmrc
Expand Down Expand Up @@ -968,34 +993,52 @@ workflows:
#
# Build, lint and test the front-end apps
- build-front:
pre-steps:
- skip_unchanged:
paths: ~/fun/src/frontend
filters:
tags:
only: /.*/
- build-front-production:
pre-steps:
- skip_unchanged:
paths: ~/fun/src/frontend
requires:
- build-front
filters:
tags:
only: /.*/
- build-dependent-front:
pre-steps:
- skip_unchanged:
paths: ~/fun/src/frontend
requires:
- build-front
filters:
tags:
only: /.*/
- lint-front:
pre-steps:
- skip_unchanged:
paths: ~/fun/src/frontend
requires:
- build-front
filters:
tags:
only: /.*/
- test-front:
pre-steps:
- skip_unchanged:
paths: ~/fun/src/frontend
requires:
- lint-front
filters:
tags:
only: /.*/
- test-front-package:
pre-steps:
- skip_unchanged:
paths: ~/fun/src/frontend
requires:
- lint-front
filters:
Expand Down Expand Up @@ -1047,37 +1090,55 @@ workflows:
# Build, lint and test production and development Docker images
# (debian-based)
- build-back:
pre-steps:
- skip_unchanged:
paths: ~/fun/src/richie
filters:
tags:
only: /.*/
- lint-back:
pre-steps:
- skip_unchanged:
paths: ~/fun/src/richie
requires:
- build-back
filters:
tags:
only: /.*/
- test-back-mysql-5:
pre-steps:
- skip_unchanged:
paths: ~/fun/src/richie
requires:
- build-back
- build-front-production
filters:
tags:
only: /.*/
- test-back-mysql-8:
pre-steps:
- skip_unchanged:
paths: ~/fun/src/richie
requires:
- build-back
- build-front-production
filters:
tags:
only: /.*/
- test-back-postgresql:
pre-steps:
- skip_unchanged:
paths: ~/fun/src/richie
requires:
- build-back
- build-front-production
filters:
tags:
only: /.*/
- test-back-postgresql-es6:
pre-steps:
- skip_unchanged:
paths: ~/fun/src/richie
requires:
- build-back
- build-front-production
Expand All @@ -1089,6 +1150,9 @@ workflows:
#
# Extract strings and upload them to our translation management SaaS
- build-back-i18n:
pre-steps:
- skip_unchanged:
paths: ~/fun/src/richie
requires:
- build-back
filters:
Expand Down