2024-07-17 18:12:43 +00:00
|
|
|
# Main build and test pipeline.
|
|
|
|
#
|
2017-08-25 18:05:25 +00:00
|
|
|
# CircleCI automatically reads this file from our repo and uses it for
|
|
|
|
# configuration. Docs:
|
2022-10-08 15:29:59 +00:00
|
|
|
# https://circleci.com/docs/2.1/configuration-reference/
|
|
|
|
# https://circleci.com/docs/2.1/sample-config/
|
|
|
|
version: 2.1
|
2017-08-25 18:05:25 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
docker:
|
2023-09-21 15:44:06 +00:00
|
|
|
- image: cimg/python:3.11
|
2017-08-25 18:05:25 +00:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
|
|
|
|
- restore_cache:
|
2024-05-16 20:22:38 +00:00
|
|
|
key: venv-7-{{ .Branch }}-{{ checksum "requirements.txt" }}
|
2017-08-25 18:05:25 +00:00
|
|
|
|
|
|
|
- run:
|
2022-10-08 15:29:59 +00:00
|
|
|
name: Base dependencies
|
|
|
|
command: |
|
2023-02-27 20:27:25 +00:00
|
|
|
# google-cloud-sdk: https://cloud.google.com/sdk/docs/install#deb
|
|
|
|
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
|
|
|
|
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
|
2022-10-08 15:29:59 +00:00
|
|
|
sudo apt-get update
|
2024-04-17 18:36:28 +00:00
|
|
|
sudo apt-get install -y apt-transport-https ca-certificates gnupg google-cloud-sdk google-cloud-cli-firestore-emulator default-jre
|
2022-10-08 15:29:59 +00:00
|
|
|
|
|
|
|
- run:
|
|
|
|
name: Python dependencies
|
2017-08-25 18:05:25 +00:00
|
|
|
command: |
|
2023-06-20 14:02:20 +00:00
|
|
|
pip install -U pip flake8
|
2022-10-08 15:29:59 +00:00
|
|
|
pip -V
|
|
|
|
# make sure we install these at head, below
|
2024-05-16 20:23:37 +00:00
|
|
|
pip uninstall -y arroba dag-json granary lexrpc oauth-dropins
|
2019-12-26 06:20:57 +00:00
|
|
|
pip install -U -r requirements.txt
|
|
|
|
pip install coverage coveralls
|
2017-08-25 18:05:25 +00:00
|
|
|
|
2023-09-21 15:54:57 +00:00
|
|
|
ln -sf `pyenv prefix`/lib/python3.11/site-packages/oauth_dropins/fonts oauth_dropins_fonts
|
|
|
|
ln -sf `pyenv prefix`/lib/python3.11/site-packages/oauth_dropins/static oauth_dropins_static
|
2023-06-14 13:47:30 +00:00
|
|
|
|
2019-12-26 06:20:57 +00:00
|
|
|
- run:
|
|
|
|
name: Build and test
|
|
|
|
command: |
|
2024-04-17 18:36:28 +00:00
|
|
|
CLOUDSDK_CORE_PROJECT=brid-gy gcloud emulators firestore start --host-port=:8089 --database-mode=datastore-mode < /dev/null >& /tmp/firestore-emulator.log &
|
2019-12-26 06:20:57 +00:00
|
|
|
sleep 5s
|
2022-10-08 15:29:59 +00:00
|
|
|
python -m coverage run --source=. --omit=appengine_config.py,logs.py,tests/\* -m unittest discover -v
|
2019-12-26 06:20:57 +00:00
|
|
|
python -m coverage html -d /tmp/coverage_html
|
2019-08-13 14:14:53 +00:00
|
|
|
if [ "$COVERALLS_REPO_TOKEN" != "" ]; then coveralls || true; fi
|
2017-08-25 18:05:25 +00:00
|
|
|
|
2023-06-20 14:02:20 +00:00
|
|
|
# check for unintentionally overridden test methods
|
|
|
|
# https://flake8.pycqa.org/en/latest/user/error-codes.html#error-codes
|
|
|
|
# https://flake8.pycqa.org/en/latest/user/options.html#cmdoption-flake8-select
|
|
|
|
flake8 --select=F811 tests/test_*.py
|
|
|
|
|
2023-09-18 18:17:32 +00:00
|
|
|
# only runs if all previous steps succeed, including tests
|
2023-07-15 15:03:52 +00:00
|
|
|
# https://circleci.com/docs/configuration-reference/#the-when-attribute
|
|
|
|
- run:
|
|
|
|
name: Deploy
|
|
|
|
command: |
|
2023-07-15 21:40:27 +00:00
|
|
|
echo $CIRCLE_BRANCH
|
2023-07-15 15:03:52 +00:00
|
|
|
if [ $CIRCLE_BRANCH = "main" ]; then
|
|
|
|
echo $FLASK_SECRET_KEY > flask_secret_key
|
|
|
|
echo $GCLOUD_SERVICE_KEY | gcloud auth activate-service-account --key-file=-
|
2024-06-14 22:35:24 +00:00
|
|
|
gcloud -q app deploy --no-cache --project bridgy-federated app.yaml index.yaml queue.yaml
|
|
|
|
|
|
|
|
# can't deploy router here yet because we need the limited_domains
|
|
|
|
# file. next step would be to put it into a circle env var.
|
|
|
|
#
|
|
|
|
# WHEN WE DO, we have to do it in a separate gcloud command
|
|
|
|
# because Flex services don't support --no-cache, but we need it
|
|
|
|
# for the default service
|
2024-06-14 22:19:50 +00:00
|
|
|
# https://issuetracker.google.com/issues/347268867
|
2024-06-14 22:35:24 +00:00
|
|
|
# gcloud -q app deploy --project bridgy-federated router.yaml
|
2023-07-15 15:03:52 +00:00
|
|
|
fi
|
2023-06-14 13:47:30 +00:00
|
|
|
|
2017-08-25 18:05:25 +00:00
|
|
|
- save_cache:
|
2024-05-16 20:22:38 +00:00
|
|
|
key: venv-7-{{ .Branch }}-{{ checksum "requirements.txt" }}
|
2017-08-25 18:05:25 +00:00
|
|
|
paths:
|
2022-10-08 15:29:59 +00:00
|
|
|
- /home/circleci/.pyenv
|
2022-10-23 02:56:46 +00:00
|
|
|
# Ideally we'd cache these, but they need root, and the cimg/python
|
|
|
|
# Docker image's default user is circleci :/
|
|
|
|
# https://github.com/cypress-io/circleci-orb/issues/269
|
|
|
|
#
|
|
|
|
# - /usr/lib/google-cloud-sdk
|
|
|
|
# - /usr/lib/jvm/java-11-openjdk-amd64
|
2017-08-25 18:05:25 +00:00
|
|
|
|
|
|
|
- store_artifacts:
|
|
|
|
path: /tmp/coverage_html
|