Skip to content

Commit

Permalink
Merge pull request #251 from DemocracyClub/hotfix/fix-ci
Browse files Browse the repository at this point in the history
Fix CI and get tests running again
  • Loading branch information
VirginiaDooley committed Sep 18, 2024
2 parents 38b2f6c + 0071f77 commit 1838eaa
Show file tree
Hide file tree
Showing 9 changed files with 630 additions and 1,019 deletions.
80 changes: 44 additions & 36 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
version: 2.1

orbs:
python: circleci/[email protected]
python: circleci/[email protected]

jobs:
install_and_update_dependencies:
docker:
- image: circleci/python:3.8.6-node
- image: cimg/python:3.8.6-node
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys:
- v2-dependencies-{{ checksum "Pipfile.lock" }}-{{ checksum "thumbs/Pipfile.lock" }}
- v2-dependencies-default
- run: &install-pipenv sudo pip install -U urllib3 cryptography==3.3.2 pipenv pip --quiet --no-input
- run: sudo pip uninstall -y poetry
- run: pipenv install --dev
- run: pipenv check # before save_cache so an insecure cache is never saved
- v3-dependencies-{{ checksum "Pipfile.lock" }}-{{ checksum "thumbs/Pipfile.lock" }}
- v3-dependencies-default
# Ensure pip and pipenv are installed
- run:
name: Install pipenv
command: |
pip install --upgrade pipenv pip --quiet --no-input
- run: pip uninstall -y poetry
- run:
name: Set up virtual environment
command: |
pipenv sync --dev
- run: make lambda-layers/DependenciesLayer/requirements.txt
- run: pipenv run collectstatic
- run: npm install
- run: npm run build
- persist_to_workspace:
Expand All @@ -28,35 +36,37 @@ jobs:
when: on_success
paths:
- ~/.local/share/virtualenvs/
key: v2-dependencies-{{ checksum "Pipfile.lock" }}-{{ checksum "thumbs/Pipfile.lock" }}

key: v3-dependencies-{{ checksum "Pipfile.lock" }}-{{ checksum "thumbs/Pipfile.lock" }}
run-tests:
docker:
- image: circleci/python:3.8.6
- image: cimg/python:3.8
environment:
CIRCLECI: true
PGHOST: 127.0.0.1
- image: cimg/postgres:16.3
environment:
POSTGRES_USER: electionleaflets
POSTGRES_DB: electionleaflets
working_directory: ~/repo

steps:
- checkout

# Download and cache dependencies
- restore_cache:
keys:
- v2-dependencies-{{ checksum "Pipfile.lock" }}
- v2-dependencies-default
- run: *install-pipenv
# - run:
# command: pipenv run black-check
# name: Black
- run: pipenv run collectstatic
# - run:
# command: pipenv run pytest --flakes
# name: Flakes
# - run:
# command: pipenv run pytest --junitxml=test-results/junit.xml --cov
# name: Run Tests
# - run: |
# if [ -n "$COVERALLS_REPO_TOKEN" ]; then
# pipenv run coveralls
# else
# echo "skipping coverage for forked PR"
# fi
- v3-dependencies-{{ checksum "Pipfile.lock" }}

# Install dependencies
- run:
name: Install dependencies with pipenv
command: |
pipenv sync --dev
# Run your tests
- run:
name: Run tests
command: |
pipenv run test
- store_artifacts:
path: test-results
destination: test-results
Expand All @@ -73,7 +83,6 @@ jobs:
at: ~/repo/
- run: pip install --upgrade pip
- run: pip install -r lambda-layers/DependenciesLayer/requirements.txt
- run: make collectstatic
- run: sam build ${DASH_DASH_DEBUG}

- persist_to_workspace:
Expand All @@ -84,7 +93,7 @@ jobs:

sam_deploy:
docker:
- image: circleci/python:3.8.6
- image: cimg/python:3.8.6
working_directory: ~/repo/
parameters:
dc-environment:
Expand All @@ -108,10 +117,9 @@ jobs:
at: ~/repo/
- restore_cache:
keys:
- v2-dependencies-{{ checksum "Pipfile.lock" }}
- v2-dependencies-default
- run: *install-pipenv

- v3-dependencies-{{ checksum "Pipfile.lock" }}
- v3-dependencies-default
- run: pip install -U pip pipenv --quiet --no-input
- run: printenv DC_DEPLOY_NAME DJANGO_SETTINGS_MODULE SAM_CONFIG_FILE SAM_LAMBDA_CONFIG_ENV SAM_PUBLIC_CONFIG_ENV
- run: printenv SECRET_KEY | md5sum
- run: printenv AWS_ACCESS_KEY_ID | md5sum
Expand Down
19 changes: 8 additions & 11 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
aws-sam-cli = "==1.40.1"

[packages]
boto3 = "*"
aws-wsgi = {ref = "a5b800373c326e75f705d400c48f7df301409724", git = "https://github.com/DemocracyClub/awsgi.git"}
Expand All @@ -20,7 +17,7 @@ django-extensions = "==3.1.5"
django-localflavor = "==1.1"
django-markdown-deux = "==1.0.5"
django-storages = "==1.7"
django-uk-political-parties = {git = "https://github.com/DemocracyClub/django-uk-political-parties.git"}
django-uk-political-parties = {ref = "master", git = "https://github.com/DemocracyClub/django-uk-political-parties.git"}
djangorestframework = ">=3.9.1"
durationpy = "==0.4"
enum34 = "==1.1.6"
Expand Down Expand Up @@ -57,20 +54,19 @@ unittest2 = "==1.1.0"
wsgi-request-logger = "==0.4.6"
Django = "==2.2.27"
Pillow = "==9.0.1"
python-Levenshtein = "==0.12.0"
python-Levenshtein = "==0.12.1"
PyYAML = ">=4.2b1"
Unidecode = "==0.4.20"
aloe-django = "==0.2.0"
factory-boy = "*"
responses = "*"
django-ses = "==2.6.0"
future = "==0.16.0"
django-pipeline = "==1.6.14"
docutils = "==0.14"
django-static-jquery = "==2.1.4"
setuptools = "==62.1.0"
setuptools = "*"
faker = "*"
werkzeug = "==2.0.3"
werkzeug = "*"
black = "==19.10b0"
django-s3file = "==5.4.0"
psycopg2-binary = "*"
Expand All @@ -81,13 +77,14 @@ libsass = "*"
django-formtools = "==2.2"
django-debug-toolbar = "*"
django-filter = "*"
click = "==8.0.4"
flask = "==2.0.2"
click = "*"
flask = "==2.3.2"
certifi = "*"

[scripts]
collectstatic = "python manage.py collectstatic -c --noinput"
createcachetable = "python manage.py createcachetable"
pytest = "pytest"
coveralls = "coveralls"
migratedb = "python manage.py migrate --noinput"
thumbs_sam_build = "bash -c 'cd thumbs && sam build'"
test = "bash -c 'DJANGO_SETTINGS_MODULE=electionleaflets.settings.testing python manage.py test'"
Loading

0 comments on commit 1838eaa

Please sign in to comment.