treeherder/.circleci/config.yml

139 строки
4.3 KiB
YAML

jobs:
javascript-tests:
executor:
name: node/default
# The Node version here must be kept in sync with that in `package.json`.
tag: '14.16'
steps:
- checkout
- node/install-packages:
# `yarn install --frozen-lockfile` is run and cache is enabled by default for this orb configuration
pkg-manager: yarn
- run:
command: yarn lint
name: Run linting
- run:
command: yarn markdownlint
name: Check markdown linting
- run:
command: yarn test:coverage
name: Run Jest tests
- run:
command: yarn codecov
name: Check code coverage changes
builds:
docker:
- image: 'circleci/python:3.7-node'
steps:
- checkout
- restore_cache:
name: Restore Yarn Package Cache
keys:
- node-deps-v1-{{ .Branch }}
- run: pip install tox
- run:
command: tox -e heroku
name: Run heroku builds and release checks
- run:
command: tox -e docs
name: Build docs
- run:
command: tox -e linters
name: Run linters
python-tests:
machine:
image: ubuntu-2004:202010-01
steps:
- checkout
- docker/install-docker
- docker/install-docker-compose
- run: pip install --upgrade pip
- run: pip install tox codecov
- run: tox -e docker # Run tests and coverage within Docker container
- run: codecov --required -f coverage.xml
test-docker-build:
docker:
- image: docker:19.03.15
steps:
- setup_remote_docker:
version: 19.03.14
- checkout
- run:
name: Create a version.json
command: |
# create a version.json per https://github.com/mozilla-services/Dockerflow/blob/master/docs/version_object.md
printf '{"commit":"%s","version":"%s","source":"https://github.com/%s/%s","build":"%s"}\n' \
"$CIRCLE_SHA1" \
"$CIRCLE_TAG" \
"$CIRCLE_PROJECT_USERNAME" \
"$CIRCLE_PROJECT_REPONAME" \
"$CIRCLE_BUILD_URL" > version.json
- run:
name: Build Docker image
command: docker build -f docker/Dockerfile -t app:build .
deploy:
docker:
- image: docker:19.03.15
steps:
- setup_remote_docker:
version: 19.03.14
- checkout
- run:
name: Create a version.json
command: |
# create a version.json per https://github.com/mozilla-services/Dockerflow/blob/master/docs/version_object.md
printf '{"commit":"%s","version":"%s","source":"https://github.com/%s/%s","build":"%s"}\n' \
"$CIRCLE_SHA1" \
"$CIRCLE_TAG" \
"$CIRCLE_PROJECT_USERNAME" \
"$CIRCLE_PROJECT_REPONAME" \
"$CIRCLE_BUILD_URL" > version.json
- run:
name: Build Docker image
command: docker build -f docker/Dockerfile -t app:build .
- run:
name: Deploy to Dockerhub
command: |
echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin
# deploy master
if [ "${CIRCLE_BRANCH}" == "master" ]; then
docker tag app:build ${DOCKERHUB_REPO}:latest
docker push ${DOCKERHUB_REPO}:latest
docker tag app:build "${DOCKERHUB_REPO}:${CIRCLE_BRANCH}-${CIRCLE_SHA1}"
docker push "${DOCKERHUB_REPO}:${CIRCLE_BRANCH}-${CIRCLE_SHA1}"
elif [ "${CIRCLE_BRANCH}" == "prototype" ]; then
docker tag app:build "${DOCKERHUB_REPO}:${CIRCLE_BRANCH}"
docker push "${DOCKERHUB_REPO}:${CIRCLE_BRANCH}"
elif [ ! -z "${CIRCLE_TAG}" ]; then
# deploy a release tag...
echo "${DOCKERHUB_REPO}:${CIRCLE_TAG}"
docker tag app:build "${DOCKERHUB_REPO}:${CIRCLE_TAG}"
docker images
docker push "${DOCKERHUB_REPO}:${CIRCLE_TAG}"
fi
orbs:
node: circleci/node@4.1.1
docker: circleci/docker@1.5.0
version: 2.1
workflows:
run-tests:
jobs:
- javascript-tests
- builds
- python-tests
- test-docker-build
- deploy:
filters:
tags:
only: /.*/
branches:
only:
- master
- prototype