forked from HHS/TANF-app
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2259 from raft-tech/1373-split-circleci-config
split config file with continuation orb
- Loading branch information
Showing
18 changed files
with
842 additions
and
773 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
version: 2.1 | ||
|
||
orbs: | ||
node: circleci/[email protected] | ||
terraform: circleci/[email protected] | ||
jq: circleci/[email protected] | ||
|
||
executors: | ||
docker-executor: | ||
docker: | ||
- image: cimg/python:3.10.4 | ||
user: root | ||
machine-executor: | ||
machine: | ||
docker_layer_caching: false | ||
image: ubuntu-2204:2022.10.1 | ||
|
||
parameters: | ||
run_dev_deployment: | ||
type: boolean | ||
default: false | ||
|
||
run_owasp_scan: | ||
type: boolean | ||
default: false | ||
|
||
target_env: | ||
type: string | ||
default: '' |
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,66 @@ | ||
# commands: | ||
docker-compose-check: | ||
steps: | ||
- run: | ||
name: Ensure docker-compose exists, otherwise install it. | ||
command: ./scripts/docker-compose-check.sh | ||
|
||
docker-compose-up-backend: | ||
steps: | ||
- run: | ||
name: Build and spin-up Django API service | ||
command: cd tdrs-backend; docker-compose up -d --build | ||
|
||
upload-codecov: | ||
description: Uploads testing code coverage results to Codecov | ||
parameters: | ||
component: | ||
description: The component of the application being tested, either backend or frontend. | ||
type: enum | ||
enum: [ "backend", "frontend" ] | ||
coverage-report: | ||
description: The path to the coverage report being uploaded. | ||
type: string | ||
steps: | ||
- run: | ||
name: Ensure Codecov uploader is installed, otherwise install it. | ||
command: ./scripts/codecov-check.sh | ||
- run: | ||
name: Determine Codecov metric flag | ||
command: | | ||
if [ "$CIRCLE_BRANCH" == "main" ] ; then | ||
CURRENT_FLAG=main-<<parameters.component>> | ||
elif [ "$CIRCLE_BRANCH" == "master" ] ; then | ||
CURRENT_FLAG=master-<<parameters.component>> | ||
else | ||
CURRENT_FLAG=dev-<<parameters.component>> | ||
fi | ||
echo "export CURRENT_FLAG=$CURRENT_FLAG" >> $BASH_ENV | ||
- run: | ||
name: Upload code coverage report if target branch | ||
command: codecov -t "$CODECOV_TOKEN" -f <<parameters.coverage-report>> -F "$CURRENT_FLAG" | ||
|
||
install-nodejs-machine: | ||
description: | | ||
Installs our target version of Node.JS using NVM (Node Version Manager) | ||
from the install location provided by machine executor images. | ||
steps: | ||
- run: | ||
name: Install Node.JS | ||
command: | | ||
sudo apt-get update | ||
sudo apt-get install -y libgbm-dev | ||
source /opt/circleci/.nvm/nvm.sh | ||
nvm install v16.13 | ||
nvm alias default v16.13 | ||
echo 'export NVM_DIR="/opt/circleci/.nvm"' >> $BASH_ENV | ||
echo "[ -s \"$NVM_DIR/nvm.sh\" ] && . \"$NVM_DIR/nvm.sh\"" >> $BASH_ENV | ||
disable-npm-audit: | ||
steps: | ||
- run: | ||
name: Disable npm audit warnings in CI | ||
command: npm set audit false | ||
|
||
# This allows us to use the node orb to install packages within other commands | ||
install-nodejs-packages: node/install-packages |
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,53 @@ | ||
# jobs: | ||
test-backend: | ||
executor: machine-executor | ||
steps: | ||
- checkout | ||
- docker-compose-check | ||
- docker-compose-up-backend | ||
- run: | ||
name: Execute Python Linting Test | ||
command: cd tdrs-backend; docker-compose run --rm web bash -c "flake8 ." | ||
- run: | ||
name: Run Unit Tests And Create Code Coverage Report | ||
command: | | ||
cd tdrs-backend; | ||
docker-compose run --rm web bash -c "./wait_for_services.sh && pytest --cov-report=xml" | ||
- upload-codecov: | ||
component: backend | ||
coverage-report: ./tdrs-backend/coverage.xml | ||
|
||
test-frontend: | ||
executor: machine-executor | ||
working_directory: ~/tdp-apps | ||
steps: | ||
- checkout | ||
- install-nodejs-machine | ||
- disable-npm-audit | ||
- install-nodejs-packages: | ||
app-dir: tdrs-frontend | ||
- run: | ||
name: Run ESLint | ||
command: cd tdrs-frontend; npm run lint | ||
- run: | ||
name: Run Pa11y Accessibility Tests | ||
command: cd tdrs-frontend; mkdir pa11y-screenshots/; npm run test:accessibility | ||
- run: | ||
name: Run Jest Unit Tests | ||
command: cd tdrs-frontend; npm run test:ci | ||
- upload-codecov: | ||
component: frontend | ||
coverage-report: ./tdrs-frontend/coverage/lcov.info | ||
- store_artifacts: | ||
path: tdrs-frontend/pa11y-screenshots/ | ||
|
||
secrets-check: | ||
executor: docker-executor | ||
steps: | ||
- checkout | ||
- run: | ||
name: "git-secrets: Scan repository for committed secrets" | ||
command: ./scripts/git-secrets-check.sh | ||
- run: | ||
name: "trufflehog: Scan repository for committed secrets" | ||
command: ./scripts/trufflehog-check.sh $CIRCLE_BRANCH |
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,14 @@ | ||
# workflows: | ||
build-and-test: | ||
unless: | ||
or: | ||
- << pipeline.parameters.run_dev_deployment >> | ||
- << pipeline.parameters.run_owasp_scan >> | ||
jobs: | ||
- secrets-check | ||
- test-frontend: | ||
requires: | ||
- secrets-check | ||
- test-backend: | ||
requires: | ||
- secrets-check |
Oops, something went wrong.