.circleci/config.yml
version: 2.1
orbs:
heroku: circleci/heroku@1.0.1
python: circleci/python@2.1.1
executors:
test-and-lint-exc:
docker:
- image: csmcallister/node-pa11y-python
deploy-exc:
docker:
- image: circleci/python:3.11.0a3
jobs:
test:
executor: test-and-lint-exc
steps:
- checkout
- run:
name: setup-test-reporter
command: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
- run:
name: install-deps
command: |
/home/circleci/.pyenv/shims/python -m pip install -r requirements.txt
printenv > .env
- run:
name: flake8
command: |
/home/circleci/.pyenv/shims/python -m flake8
- run:
name: test
command: |
./cc-test-reporter before-build
/home/circleci/.pyenv/shims/python -m coverage run -m pytest
/home/circleci/.pyenv/shims/python -m coverage xml
./cc-test-reporter after-build --debug -t "coverage.py" --exit-code $?
- run:
name: pa11y
command: |
/home/circleci/.pyenv/shims/python -m flask run & sleep 5 && /home/circleci/node_modules/.bin/pa11y-ci --config .pa11yci
- store_artifacts:
path: coverage.xml
destination: coverage.xml
deploy:
executor: deploy-exc
steps:
- checkout
- run:
name: Deploy Master to Heroku
command: |
git push -f https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git master
- run:
name: Coverage Report Update
command: |
(( JOB_NUMBER = $CIRCLE_BUILD_NUM - 1 ))
REPORT_URL=""
c=0
while [ 1 ]
do
REPORT_URL="$(curl -X GET "https://circleci.com/api/v2/project/gh/csmcallister/fed-a11y/$JOB_NUMBER/artifacts?circle-token=$CIRCLE_TOKEN" -H 'Accept: application/json' | grep -o 'https://[^"]*')"
((c=c+1))
if [ -n "$REPORT_URL" ]; then
wget $REPORT_URL
# download test reporter
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
break
else
(( JOB_NUMBER = $JOB_NUMBER - 1 ))
echo $JOB_NUMBER
fi
if [ $c -ge 10 ]; then
echo "Max number of tries exceeded"
break
fi
done
weekly-deploy:
executor: deploy-exc
steps:
- checkout
- run:
name: Deploy Master to Heroku
command: |
git push -f https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git master
workflows:
version: 2
lint-and-test:
jobs:
- test:
filters:
branches:
ignore: master
- deploy:
filters:
branches:
only: master
weekly:
triggers:
- schedule:
cron: "0 6 * * 5"
filters:
branches:
only:
- master
jobs:
- weekly-deploy