treeherder/.circleci/config.yml

138 строки
4.2 KiB
YAML

jobs:
javascript-tests:
executor:
name: node/default
# The Node version here must be kept in sync with that in `package.json`.
tag: '21.1.0'
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
- codecov/upload
builds:
docker:
- image: 'cimg/python:3.10-node'
steps:
- checkout
- restore_cache:
name: Restore Yarn Package Cache
keys:
- node-deps-v1-{{ .Branch }}
- run: pip install tox
- run:
command: tox -e docs
name: Build docs
- run:
command: tox -e linters
name: Run linters
python-tests-postgres:
machine:
image: default
steps:
- checkout
- docker/install-docker-compose:
version: 1.29.2
- run:
name: Run tests and coverage within Docker container
command: |
pip install --upgrade pip
pip install tox
tox -e docker-postgres
- codecov/upload
test-docker-build:
docker:
- image: docker:19.03.15
steps:
- setup_remote_docker:
version: docker24
- 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: docker24
- 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
codecov: codecov/codecov@4.1.0
version: 2.1
workflows:
run-tests:
jobs:
- javascript-tests
- builds
- python-tests-postgres
- test-docker-build
- deploy:
filters:
tags:
only: /.*/
branches:
only:
- master
- prototype