Last active
June 23, 2021 04:22
-
-
Save hervenivon/81563806680c9aab1e36c589e9ea7622 to your computer and use it in GitHub Desktop.
circleci config file for node8 and dynamodb on localstack
This file contains hidden or 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
version: 2 | |
references: | |
base_container_config: &base_container_config | |
docker: | |
- image: circleci/node:8 | |
working_directory: ~/repo | |
test_container_config: &test_container_config | |
docker: | |
- image: circleci/node:8 | |
- image: localstack/localstack:latest | |
environment: | |
- DEBUG: 0 | |
- SERVICES: dynamodb | |
working_directory: ~/repo | |
restore_repo: &restore_repo | |
restore_cache: | |
keys: | |
- repo-v1-{{ .Branch }}-{{ .Revision }} | |
- repo-v1-{{ .Branch }} | |
- repo-v1- | |
restore_npm_install: &restore_npm_install | |
restore_cache: | |
keys: | |
- node_modules-v1-cache-{{ checksum "package.json" }} | |
# fallback to using the latest cache if no exact match is found | |
- node_modules-v1-cache | |
jobs: | |
checkout_code: | |
<<: *base_container_config | |
steps: | |
- *restore_repo | |
- checkout | |
- save_cache: | |
key: repo-v1-{{ .Branch }}-{{ .Revision }} | |
paths: | |
- . | |
npm_install: | |
<<: *base_container_config | |
steps: | |
- *restore_repo | |
- *restore_npm_install | |
- run: | |
name: "npm install" | |
command: npm install --update-binary | |
- save_cache: | |
key: node_modules-v1-cache-{{ checksum "package.json" }} | |
paths: | |
- ./node_modules | |
lint: | |
<<: *base_container_config | |
steps: | |
- *restore_repo | |
- *restore_npm_install | |
- run: | |
name: "Linting" | |
command: npm run lint -- --format junit -o reports/junit/js-lint-results.xml | |
test: | |
<<: *test_container_config | |
steps: | |
- *restore_repo | |
- *restore_npm_install | |
- run: | |
name: "Test suite execution" | |
# Because "CredentialsError: Missing credentials in config" | |
# AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_DEFAULT_REGION are mandatory to access dynamodblocal | |
# Set them in circleci project's configuration in "Build settings > Environment Variables" | |
command: | | |
./node_modules/jest/bin/jest.js --ci --testResultsProcessor="jest-junit" --collectCoverage --coverageReporters="lcov" | |
environment: | |
JEST_JUNIT_OUTPUT: "reports/junit/js-test-results.xml" | |
- run: | |
name: "Report to codecov.io" | |
command: ./node_modules/codecov/bin/codecov | |
- store_test_results: #along with linting results | |
path: reports/junit | |
- store_artifacts: | |
path: reports/junit | |
- store_artifacts: | |
path: coverage | |
workflows: | |
version: 2 | |
main: | |
jobs: | |
- checkout_code | |
- npm_install: | |
requires: | |
- checkout_code | |
- lint: | |
requires: | |
- npm_install | |
- test: | |
requires: | |
- npm_install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Update with a cleaner version that uses localstack instead of installing dynamodblocal manually each time.