150 строки
4.3 KiB
YAML
150 строки
4.3 KiB
YAML
####################
|
|
# CircleCI configuration reference:
|
|
# https://circleci.com/docs/2.0/configuration-reference
|
|
####################
|
|
# CircleCI built-in environment variables:
|
|
# https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables
|
|
####################
|
|
|
|
|
|
####################
|
|
# Templates: see "anchors" in https://learnxinyminutes.com/docs/yaml/
|
|
####################
|
|
|
|
install_dependencies: &install_dependencies
|
|
name: install dependencies
|
|
command: |
|
|
# Update stretch repositories
|
|
# source:https://stackoverflow.com/a/76095392
|
|
sed -i \
|
|
-e 's/deb.debian.org/archive.debian.org/g' \
|
|
-e 's|security.debian.org|archive.debian.org/|g' \
|
|
-e '/stretch-updates/d' /etc/apt/sources.list
|
|
apt update
|
|
apt install -y libsnappy-dev openjdk-8-jre-headless
|
|
pip install tox==4.6.4 coverage==5.3
|
|
|
|
save_cache_settings: &save_cache_settings
|
|
key: v1-python_mozetl-{{ checksum "setup.py" }}
|
|
paths:
|
|
- ~/python_mozetl/.tox
|
|
|
|
restore_cache_settings: &restore_cache_settings
|
|
key: v1-python_mozetl-{{ checksum "setup.py" }}
|
|
|
|
early_return_for_skip_tests: &early_return_for_skip_tests
|
|
name: Early return if the latest non-merge commit message contains "[skip-tests]"
|
|
command: |
|
|
COMMIT_MESSAGE=$(git log --format=%B --no-merges -n 1)
|
|
if [[ "$COMMIT_MESSAGE" =~ "[skip-tests]" ]]; then
|
|
echo "Skipping tests due to [skip-tests] flag, so marking this step successful"
|
|
circleci step halt
|
|
fi
|
|
|
|
test_settings: &test_settings
|
|
working_directory: ~/python_mozetl
|
|
steps:
|
|
- checkout
|
|
- run: *early_return_for_skip_tests
|
|
- restore_cache: *restore_cache_settings
|
|
- run: *install_dependencies
|
|
- run:
|
|
name: run tests
|
|
command: |
|
|
circleci tests glob "tests/**/test*.py" > tests.txt
|
|
tox -e $CIRCLE_JOB -- \
|
|
$(circleci tests split --split-by=timings tests.txt | tr -d '\r') \
|
|
--junitxml=test-reports/junit.xml
|
|
- run:
|
|
name: submit code coverage data
|
|
command: |
|
|
# convert `.coverage` to `coverage.xml`
|
|
coverage xml -i
|
|
bash <(curl -s https://codecov.io/bash)
|
|
- store_test_results:
|
|
path: test-reports
|
|
- store_artifacts:
|
|
path: test-reports
|
|
|
|
####################
|
|
# Jobs: see https://circleci.com/docs/2.0/jobs-steps/
|
|
####################
|
|
|
|
version: 2
|
|
jobs:
|
|
py37:
|
|
<<: *test_settings
|
|
parallelism: 4
|
|
docker:
|
|
- image: python:3.7.11-stretch
|
|
|
|
lint:
|
|
docker:
|
|
- image: python:3.7.11-stretch
|
|
working_directory: ~/python_mozetl
|
|
steps:
|
|
- checkout
|
|
- run: *early_return_for_skip_tests
|
|
- restore_cache: *restore_cache_settings
|
|
- run: *install_dependencies
|
|
- run:
|
|
name: run linter
|
|
command: tox -e flake8,black
|
|
- save_cache: *save_cache_settings
|
|
|
|
docs:
|
|
docker:
|
|
- image: python:3.7.11-stretch
|
|
working_directory: ~/python_mozetl
|
|
steps:
|
|
- checkout
|
|
- run: *early_return_for_skip_tests
|
|
- restore_cache: *restore_cache_settings
|
|
- run: *install_dependencies
|
|
- run:
|
|
name: generate docs
|
|
command: tox -e docs
|
|
- persist_to_workspace:
|
|
root: .tox
|
|
paths: docs_out
|
|
|
|
# https://github.com/mozilla/python_moztelemetry/blob/master/.circleci/config.yml#L90
|
|
docs-deploy:
|
|
docker:
|
|
- image: node:8.10.0-stretch
|
|
steps:
|
|
- checkout
|
|
- attach_workspace:
|
|
at: .tox
|
|
# Needed for write access to the GitHub repository;
|
|
# see https://circleci.com/docs/2.0/gh-bb-integration/#deployment-keys-and-user-keys
|
|
- add_ssh_keys:
|
|
fingerprints:
|
|
- "68:ba:7a:c1:36:9a:9e:70:24:b1:c1:20:47:34:d0:43"
|
|
- run:
|
|
name: Deploy docs to gh-pages branch
|
|
command: |
|
|
git config user.email "dataops+ci-bot@mozilla.com"
|
|
git config user.name "CircleCI docs-deploy job"
|
|
npm install -g --silent gh-pages@2.0.1
|
|
gh-pages --dotfiles --message "[skip ci] Updates" --dist .tox/docs_out
|
|
|
|
|
|
####################
|
|
# Workflows: see https://circleci.com/docs/2.0/workflows/
|
|
####################
|
|
|
|
workflows:
|
|
version: 2
|
|
build:
|
|
jobs:
|
|
- py37
|
|
- lint
|
|
- docs
|
|
- docs-deploy:
|
|
requires:
|
|
- docs
|
|
filters:
|
|
branches:
|
|
only: main
|