-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5: Create CI configuration and a build script
- Loading branch information
1 parent
1eddde3
commit 49d5c7e
Showing
3 changed files
with
234 additions
and
139 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,30 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
docker: | ||
- image: circleci/node:12.18.4-buster-browsers | ||
working_directory: ~/ftgo-consumer-web-ui | ||
steps: | ||
- checkout | ||
- run: | ||
command: | | ||
export CI_ARTEFACTS_PATH=~/ftgo-consumer-web-ui/ci-artefacts | | ||
export JEST_JUNIT_OUTPUT_DIR_PARENT=~/ftgo-consumer-web-ui/reports | | ||
./build-and-test-all.sh | ||
- store_test_results: | ||
path: ~/ftgo-consumer-web-ui/reports | ||
- store_artifacts: | ||
path: ~/ftgo-consumer-web-ui/ci-artefacts | ||
workflows: | ||
version: 2 | ||
build-test-and-deploy: | ||
jobs: | ||
- request-build: | ||
type: approval | ||
# filters: | ||
# branches: | ||
# only: | ||
# - master | ||
- build: | ||
requires: | ||
- request-build |
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 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
echo "00. Environment diagnostics" | ||
|
||
npx envinfo | ||
|
||
|
||
echo "" | ||
echo "" | ||
echo "10. Ensuring required env variables and directories" | ||
|
||
if [[ -z "$JEST_JUNIT_OUTPUT_DIR_PARENT" ]]; then | ||
export JEST_JUNIT_OUTPUT_DIR_PARENT=./reports/ | ||
fi | ||
|
||
rm -rf "$JEST_JUNIT_OUTPUT_DIR_PARENT" | ||
mkdir -p "$JEST_JUNIT_OUTPUT_DIR_PARENT" | ||
|
||
if [[ -z "$JEST_JUNIT_OUTPUT_DIR" ]]; then | ||
export JEST_JUNIT_OUTPUT_DIR=$JEST_JUNIT_OUTPUT_DIR_PARENT/junit/ | ||
mkdir -p "$JEST_JUNIT_OUTPUT_DIR" | ||
fi | ||
|
||
if [[ -z "$CI_ARTEFACTS_PATH" ]]; then | ||
export CI_ARTEFACTS_PATH=$(pwd)/ci-artefacts/ | ||
mkdir -p "$CI_ARTEFACTS_PATH" | ||
fi | ||
mkdir -p "$CI_ARTEFACTS_PATH/npm-logs" | ||
|
||
|
||
echo "" | ||
echo "" | ||
echo "20. Installing dependencies" | ||
|
||
echo "running npm install in $(pwd)" | ||
rm -rf node_modules | ||
rm -f package-lock.json | ||
npm install --no-audit --loglevel verbose | ||
npm audit fix | ||
|
||
|
||
echo "" | ||
echo "" | ||
echo "30. Running tests" | ||
|
||
npm run test | ||
|
||
|
||
echo "" | ||
echo "" | ||
echo "40. Building the site" | ||
|
||
npm run build | ||
|
||
|
||
echo "" | ||
echo "" | ||
echo "50. Archiving and copying the resulted built files" | ||
|
||
tar -czvf "$CI_ARTEFACTS_PATH/build_$(date '+%Y%m%d_%H%M').tar.gz" build | ||
|
||
cp ./junit.xml "$JEST_JUNIT_OUTPUT_DIR/junit_$(date '+%Y%m%d_%H%M').xml" 2>/dev/null || : | ||
|
||
echo "Copy NPM logs" | ||
[ -d "$HOME/.npm/_logs" ] && cp -R ~/.npm/_logs/* "$CI_ARTEFACTS_PATH/npm-logs" 2>/dev/null || : |
Oops, something went wrong.