Skip to content

Commit

Permalink
5 circle ci configuration (#6)
Browse files Browse the repository at this point in the history
* #5: Create CI configuration and a build script

* #5: Create CI configuration and a build script
 - add master-branch filter
 - adjust loglevel for npm installation
  • Loading branch information
dartandrevinsky authored Apr 22, 2021
1 parent 1eddde3 commit 5e2b94c
Show file tree
Hide file tree
Showing 3 changed files with 234 additions and 139 deletions.
30 changes: 30 additions & 0 deletions .circleci/config.yml
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
66 changes: 66 additions & 0 deletions build-and-test-all.sh
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 || :
Loading

0 comments on commit 5e2b94c

Please sign in to comment.