sourcecred/.circleci/config.yml

151 lines
4.1 KiB
YAML

# JavaScript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
# See https://circleci.com/docs/2.0/config-intro/#section=configuration for spec
#
version: 2.1
orbs:
# https://circleci.com/orbs/registry/orb/circleci/docker
docker: circleci/docker@0.5.20
executors:
node10:
docker:
- image: circleci/node:10
working_directory: ~/repo
node12:
docker:
- image: circleci/node:12
working_directory: ~/repo
commands:
set_up_node_modules:
description: "load node_modules, updating and storing back into cache if necessary"
parameters:
node_version:
description: Which node version we're caching packages for
type: integer
default: 12
steps:
- restore_cache:
keys:
- v1-node<< parameters.node_version >>-dependencies-{{ checksum "package.json" }}
# fall back to using the latest cache if no exact match is found
- v1-node<< parameters.node_version >>-dependencies-
- run: yarn install
- save_cache:
paths:
- node_modules
key: v1-node<< parameters.node_version >>-dependencies-{{ checksum "package.json" }}
jobs:
test:
executor: node12
steps:
- checkout
- set_up_node_modules
- run: yarn test --ci
test_full:
executor: node12
steps:
- checkout
- set_up_node_modules
- run: yarn test --full --ci
test_full_10:
executor: node10
steps:
- checkout
- set_up_node_modules:
node_version: 10
- run: yarn test --full --ci
workflows:
version: 2.0
commit:
jobs:
- test
# We also run full-tests on each commit, but they're not configured as
# blocking checks. Thus, in the case that they complete before you want
# to merge your pull request, they provide information, and otherwise
# they don't get in your way.
- test_full
- test_full_10
- docker/publish:
deploy: false
image: sourcecred/sourcecred
tag: latest
cache_from: node:12,sourcecred/sourcecred:dev
requires:
- test
filters:
branches:
ignore:
- master
after_build:
- run:
name: Preview Docker Tag for Build
command: |
DOCKER_TAG=$(docker run sourcecred/sourcecred --version | cut -d' ' -f2)
echo "Version that would be used for Docker tag is ${DOCKER_TAG}"
- docker/publish:
image: sourcecred/sourcecred
cache_from: node:12,sourcecred/sourcecred:dev
requires:
- test
- test_full
- test_full_10
tag: dev
filters:
branches:
only: master
# Separate workflow just for version tag releases.
tagged-release:
jobs:
- test:
filters: &version-tag-only
branches:
ignore: /.*/
tags:
only: /^v.*/
- test_full:
filters: *version-tag-only
- test_full_10:
filters: *version-tag-only
- docker/publish:
filters: *version-tag-only
requires:
- test
- test_full
- test_full_10
image: sourcecred/sourcecred
tag: latest
cache_from: node:12,sourcecred/sourcecred:dev
after_build:
- run:
name: Publish Docker Tag with Sourcecred Version
command: |
DOCKER_TAG=$(docker run sourcecred/sourcecred --version | cut -d' ' -f2)
echo "Version for Docker tag is ${DOCKER_TAG}"
docker tag sourcecred/sourcecred:latest sourcecred/sourcecred:${DOCKER_TAG}
docker push sourcecred/sourcecred:${DOCKER_TAG}
docker push sourcecred/sourcecred:latest
nightly:
triggers:
- schedule:
cron: "0 22 * * *" # 22:00 UTC
filters:
branches:
only:
- master
jobs:
- test_full
- test_full_10