Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean staticfiles before collecting #256

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 25 additions & 19 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
version: 2.1

orbs:
python: circleci/python@0.2.1
python: circleci/python@2.1.1
jobs:
install_and_update_dependencies:
executor: python/default
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
- v3-dependencies-{{ checksum "Pipfile.lock" }}-{{ checksum "thumbs/Pipfile.lock" }}
- v3-dependencies-default
- run: pip install pipenv==2024.0.1
- run: pipenv --version
- run: pipenv run pip install -U urllib3==2.2.2 cryptography==3.3.2 pip --quiet --no-input
- run: pipenv run pip uninstall -y poetry
- run: pipenv sync --dev
- run: pipenv check # before save_cache so an insecure cache is never saved
- run: make lambda-layers/DependenciesLayer/requirements.txt
- run: npm install
Expand All @@ -28,22 +30,22 @@ 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.6
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys:
- v2-dependencies-{{ checksum "Pipfile.lock" }}
- v2-dependencies-default
- run: *install-pipenv
- v3-dependencies-{{ checksum "Pipfile.lock" }}
- v3-dependencies-default
# - run:
# command: pipenv run black-check
# name: Black
- run: pipenv sync --dev
- run: pipenv run collectstatic
# - run:
# command: pipenv run pytest --flakes
Expand Down Expand Up @@ -72,6 +74,7 @@ jobs:
- attach_workspace:
at: ~/repo/
- run: pip install --upgrade pip
- run: pip install -r deploy-requirements.txt
- run: pip install -r lambda-layers/DependenciesLayer/requirements.txt
- run: make collectstatic
- run: sam build ${DASH_DASH_DEBUG}
Expand All @@ -81,10 +84,11 @@ jobs:
paths:
- .aws-sam/build/
- thumbs/.aws-sam/build/
- lambda-layers/DependenciesLayer/requirements.txt

sam_deploy:
docker:
- image: circleci/python:3.8.6
- image: cimg/python:3.8.6
working_directory: ~/repo/
parameters:
dc-environment:
Expand All @@ -108,9 +112,8 @@ 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: printenv DC_DEPLOY_NAME DJANGO_SETTINGS_MODULE SAM_CONFIG_FILE SAM_LAMBDA_CONFIG_ENV SAM_PUBLIC_CONFIG_ENV
- run: printenv SECRET_KEY | md5sum
Expand Down Expand Up @@ -139,6 +142,7 @@ jobs:
AppDomain='$PUBLIC_FQDN' \
AppLeafletImagesBucketName='$LEAFLET_IMAGES_BUCKET_NAME' \
"
- run: pipenv run makemigrations
- run: pipenv run migratedb
- run: pipenv run createcachetable
- run: printenv LEAFLET_IMAGES_BUCKET_NAME
Expand Down Expand Up @@ -179,7 +183,9 @@ jobs:
PublicFqdn=$PUBLIC_FQDN \
LeafletsBucketName=$LEAFLET_IMAGES_BUCKET_NAME
"
- run: pip install -U boto3 pipenv --quiet --no-input
- run: pipenv --version
- run: pip install pipenv==2024.0.1 --quiet --no-input
- run: pip install -U boto3 --quiet --no-input
- run: python thumbs/attach_lambda_triggers.py
- run:
name: "Publish a new Sentry Release"
Expand Down Expand Up @@ -214,7 +220,7 @@ workflows:
- run-tests # staging should only deploy if tests pass
- sam_build # deploy needs .aws-sam/build/
context: [ deployment-staging-election-leaflets ]
filters: { branches: { only: [ master ] } }
filters: { branches: { only: [ master, staticfiles-on-stage ] } }

- sam_deploy:
name: sam_deploy_production
Expand Down
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,6 @@ collectstatic = "python manage.py collectstatic -c --noinput"
createcachetable = "python manage.py createcachetable"
pytest = "pytest"
coveralls = "coveralls"
makemigrations = "python manage.py makemigrations"
migratedb = "python manage.py migrate --noinput"
thumbs_sam_build = "bash -c 'cd thumbs && sam build'"
1 change: 1 addition & 0 deletions deploy-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
aws-sam-cli==1.115.0