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

[Resolves #894] Switch to using poetry #1323

Merged
merged 31 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
95f7392
update ci with poetry
zaro0508 Apr 11, 2023
f08d2ae
don't diff poetry.lock file
zaro0508 Apr 11, 2023
b692e90
remove setuptools manifest file
zaro0508 Apr 11, 2023
a87ae8f
fix typo in ci file
zaro0508 Apr 11, 2023
bd23927
fix job in ci file
zaro0508 Apr 11, 2023
ad0fdaa
remove references to setup.py and setup.cfg
zaro0508 Apr 11, 2023
d0b18fd
clean up tox configs
zaro0508 Apr 11, 2023
489bcbc
test install deps with extras
zaro0508 Apr 11, 2023
f20d3db
fix docker build
zaro0508 Apr 11, 2023
498d072
update docker to use python:3.8-alpine
zaro0508 Apr 11, 2023
de46d42
run unit tests in parallel
zaro0508 Apr 11, 2023
a5fe98a
restore cache to speed up poetry install
zaro0508 Apr 11, 2023
99615d4
restore cache to speed up pre-commit checks
zaro0508 Apr 11, 2023
3e38e0d
replace with static cache version
zaro0508 Apr 11, 2023
eb3a6e2
Merge branch 'master' into z_poetry
zaro0508 Apr 11, 2023
73d432e
fixes from review
zaro0508 Apr 11, 2023
40e8cc4
make ci restore multiple caches
zaro0508 Apr 11, 2023
f83cf0c
cache .tox for circleci
zaro0508 Apr 11, 2023
5a3c0f4
fix docs job
zaro0508 Apr 11, 2023
7a0ae3c
there's only one cache
zaro0508 Apr 11, 2023
a34b559
add support for python 3.7
zaro0508 Apr 17, 2023
3e965bf
update poetry lock file
zaro0508 Apr 18, 2023
020492b
Merge branch 'master' into z_poetry
zaro0508 Apr 18, 2023
633b14d
fixes from review
zaro0508 Apr 18, 2023
2f445a6
update precommit
zaro0508 Apr 18, 2023
5bbbafc
remove setup.cfg
zaro0508 Apr 18, 2023
2c0f643
fix doc
zaro0508 Apr 18, 2023
739369b
restore makefile and update tests and docs
zaro0508 Apr 18, 2023
1e6b70f
running tests in parallel on CI doesn't work
zaro0508 Apr 19, 2023
fba2403
update version
zaro0508 Apr 19, 2023
f2b8727
Update Makefile
zaro0508 Apr 20, 2023
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
175 changes: 75 additions & 100 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ aliases:
REPOSITORY_PATH: '/home/circleci/docs'
DEPLOYMENT_GIT_SSH: 'git@github.com:Sceptre/sceptre.github.io.git'
steps:
- checkout
- restore_cache:
key: sceptre-v1-{{ checksum "pyproject.toml" }}-{{ checksum "poetry.lock" }}-{{ checksum ".pre-commit-config.yaml" }}-{{ checksum "tox.ini" }}
- add_ssh_keys:
fingerprints:
- '80:24:c0:40:28:36:f1:80:7f:fd:15:c3:09:cf:86:fc'
Expand All @@ -27,82 +30,58 @@ aliases:
name: 'Build and deploy docs'
command: |
chmod +x .circleci/add-known-hosts.sh
./.circleci/add-known-hosts.sh
pyenv global venv
poetry run ./.circleci/add-known-hosts.sh
chmod +x .circleci/github-pages.sh
./.circleci/github-pages.sh
poetry run ./.circleci/github-pages.sh

jobs:
build:
docker:
- image: sceptreorg/sceptre-circleci:2.0.0
steps:
- checkout
- run:
name: 'Creating Virtualenv'
command: |
pyenv virtualenv 3.9.4 venv
- restore_cache:
key:
sceptre-{{ .Environment.CACHE_VERSION }}-dependencies-{{ arch }}-{{
checksum "requirements/prod.txt" }}-{{ checksum
"requirements/dev.txt" }}
key: sceptre-v1-{{ checksum "pyproject.toml" }}-{{ checksum "poetry.lock" }}-{{ checksum ".pre-commit-config.yaml" }}-{{ checksum "tox.ini" }}
- run:
name: 'Installing Dependencies'
command: |
pyenv global venv
make install-dev
- save_cache:
key:
sceptre-{{ .Environment.CACHE_VERSION }}-dependencies-{{ arch }}-{{
checksum "requirements/prod.txt" }}-{{ checksum
"requirements/dev.txt" }}
paths:
- ../.pyenv/versions/3.9.4/envs/venv
command: poetry install --all-extras -v
- run:
name: 'Installing Sceptre'
command: |
pyenv global venv
pip install .
- persist_to_workspace:
root: /home/circleci
name: Run pre-commit
command: poetry run pre-commit run --all-files --show-diff-on-failure
- run:
name: Build package
command: poetry build
- save_cache:
key: sceptre-v1-{{ checksum "pyproject.toml" }}-{{ checksum "poetry.lock" }}-{{ checksum ".pre-commit-config.yaml" }}-{{ checksum "tox.ini" }}
paths:
- project
- .pyenv
- '~/.cache/pypoetry'
- '~/.cache/pre-commit'
- '.tox'

lint-and-unit-tests:
unit-tests:
docker:
- image: sceptreorg/sceptre-circleci:2.0.0
steps:
- attach_workspace:
at: /home/circleci
- checkout
- restore_cache:
keys:
- sceptre-{{ .Environment.CACHE_VERSION }}-dependencies-{{ arch }}-{{
checksum "requirements/prod.txt" }}-{{ checksum "requirements/dev.txt" }}
- sceptre-{{ .Environment.CACHE_VERSION }}-dependencies-{{ arch }}-{{
checksum "requirements/prod.txt" }}-{{ checksum
"requirements/dev.txt" }}-{{ checksum "tox.ini" }}
key: sceptre-v1-{{ checksum "pyproject.toml" }}-{{ checksum "poetry.lock" }}-{{ checksum ".pre-commit-config.yaml" }}-{{ checksum "tox.ini" }}
- run:
name: 'Linting'
name: Unit Tests
command: |
pyenv global venv
make lint
- run:
name: 'Unit Test'
command: |
pyenv global venv
make test-all
- save_cache:
key:
sceptre-{{ .Environment.CACHE_VERSION }}-{{ arch
}}-{{ checksum "requirements/prod.txt" }}-{{ checksum
"requirements/dev.txt" }}-{{ checksum "tox.ini" }}
paths:
- .tox
poetry run tox -e clean
poetry run tox
poetry run tox -e report
- store_test_results:
path: coverage.xml
path: test-reports
- store_artifacts:
path: htmlcov
destination: coverage-reports
- save_cache:
key: sceptre-v1-{{ checksum "pyproject.toml" }}-{{ checksum "poetry.lock" }}-{{ checksum ".pre-commit-config.yaml" }}-{{ checksum "tox.ini" }}
paths:
- '~/.cache/pypoetry'
- '~/.cache/pre-commit'
- '.tox'

integration-tests:
parallelism: 2
Expand All @@ -111,23 +90,19 @@ jobs:
environment:
AWS_DEFAULT_REGION: eu-west-1
steps:
- attach_workspace:
at: /home/circleci
- checkout
- restore_cache:
key:
sceptre-{{ .Environment.CACHE_VERSION }}-dependencies-{{ arch }}-{{
checksum "requirements/prod.txt" }}-{{ checksum
"requirements/dev.txt" }}
key: sceptre-v1-{{ checksum "pyproject.toml" }}-{{ checksum "poetry.lock" }}-{{ checksum ".pre-commit-config.yaml" }}-{{ checksum "tox.ini" }}
- run:
name: 'Integration Testing'
command: |
pyenv global venv
mkdir -p ~/.aws
echo -e "[default]\nregion=eu-west-1\nsource_profile=default\nrole_arn=arn:aws:iam::743644221192:role/sceptre-integration-test-ServiceRole-1SHK9LY0T6P3F" > ~/.aws/config
echo -e "[default]\nregion=eu-west-1\naws_access_key_id=$CI_SERVICE_AWS_ACCESS_KEY_ID\naws_secret_access_key=$CI_SERVICE_AWS_SECRET_ACCESS_KEY" > ~/.aws/credentials
behave --junit \
--junit-directory build/behave \
$(circleci tests glob "integration-tests/features/*.feature" | circleci tests split --split-by=timings)
poetry run behave \
--junit \
--junit-directory build/behave \
$(circleci tests glob "integration-tests/features/*.feature" | circleci tests split --split-by=timings)
- store_test_results:
path: build/behave
destination: build/behave
Expand Down Expand Up @@ -156,32 +131,29 @@ jobs:

deploy-docs-tag: *docs-job

deploy-pypi:
deploy-pypi-test:
docker:
- image: sceptreorg/sceptre-circleci:2.0.0
steps:
- attach_workspace:
at: /home/circleci
- checkout
- restore_cache:
key:
sceptre-{{ .Environment.CACHE_VERSION }}-dependencies-{{ arch }}-{{
checksum "requirements/prod.txt" }}-{{ checksum
"requirements/dev.txt" }}
key: sceptre-v1-{{ checksum "pyproject.toml" }}-{{ checksum "poetry.lock" }}-{{ checksum ".pre-commit-config.yaml" }}-{{ checksum "tox.ini" }}
- run:
name: 'Installing Dependencies'
name: Test upload to PyPi
command: |
pyenv global venv
make install-dev
- run:
name: 'Create Distributions'
command: |
pyenv global venv
make dist
poetry config repositories.test-pypi "https://test.pypi.org/legacy/"
poetry publish --build -r test-pypi -u $PYPI_TEST_USER -p $PYPI_TEST_PASSWORD

deploy-pypi-prod:
docker:
- image: sceptreorg/sceptre-circleci:2.0.0
steps:
- checkout
- restore_cache:
key: sceptre-v1-{{ checksum "pyproject.toml" }}-{{ checksum "poetry.lock" }}-{{ checksum ".pre-commit-config.yaml" }}-{{ checksum "tox.ini" }}
- run:
name: 'Upload Distributions'
command: |
pyenv global venv
twine upload -u $PYPI_USERNAME -p $PYPI_PASSWORD dist/*
name: Upload to PyPi
command: poetry publish --build -u $PYPI_PROD_USER -p $PYPI_PROD_PASSWORD

deploy-latest-dockerhub:
executor: docker-publisher
Expand Down Expand Up @@ -237,15 +209,15 @@ workflows:
filters:
branches:
only: /^pull\/.*/
- lint-and-unit-tests:
- unit-tests:
requires:
- build
filters:
branches:
only: /^pull\/.*/
- build-docker-image:
requires:
- lint-and-unit-tests
- build
filters:
branches:
only: /^pull\/.*/
Expand All @@ -256,7 +228,7 @@ workflows:
filters:
branches:
ignore: /^pull\/.*/
- lint-and-unit-tests:
- unit-tests:
requires:
- build
filters:
Expand All @@ -269,41 +241,42 @@ workflows:
filters:
branches:
ignore: /^pull\/.*/
- deploy-pypi-test:
context: sceptre-core
requires:
- unit-tests
filters:
tags:
only: /^v([0-9]+)\.([0-9]+)\.([0-9]+)(?:([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/
branches:
ignore: /.*/
- deploy-docs-branch:
context: sceptre-core
requires:
- lint-and-unit-tests
- unit-tests
- integration-tests
filters:
branches:
ignore: /^pull\/.*/
- build-docker-image:
requires:
- lint-and-unit-tests
- integration-tests
- unit-tests
filters:
branches:
ignore: /^pull\/.*/
- deploy-latest-dockerhub:
context: sceptreorg-dockerhub
requires:
- integration-tests
- build-docker-image
filters:
branches:
ignore: /^pull\/.*/

publish:
jobs:
- build:
filters:
tags:
only: /^v([0-9]+)\.([0-9]+)\.([0-9]+)(?:([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/
branches:
ignore: /.*/
- deploy-pypi:
- deploy-pypi-prod:
context: sceptre-core
requires:
- build
filters:
tags:
only: /^v([0-9]+)\.([0-9]+)\.([0-9]+)(?:([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/
Expand All @@ -312,15 +285,15 @@ workflows:
- deploy-docs-tag:
context: sceptre-core
requires:
- deploy-pypi
- deploy-pypi-prod
filters:
tags:
only: /^v([0-9]+)\.([0-9]+)\.([0-9]+)(?:([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/
branches:
ignore: /.*/
- build-docker-image:
requires:
- deploy-pypi
- deploy-pypi-prod
filters:
tags:
only: /^v([0-9]+)\.([0-9]+)\.([0-9]+)(?:([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/
Expand All @@ -338,6 +311,8 @@ workflows:
- tweet-release:
context: sceptreorg-twitter
requires:
- deploy-pypi-prod
- deploy-docs-tag
- deploy-dockerhub-tagged
filters:
tags:
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
poetry.lock binary
zaro0508 marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
- [ ] Commit message starts with `[Resolve #issue-number]`.
- [ ] Added/Updated unit tests.
- [ ] Added/Updated integration tests (if applicable).
- [ ] All unit tests (`make test`) are passing.
- [ ] All unit tests (`poetry run tox`) are passing.
- [ ] Used the same coding conventions as the rest of the project.
- [ ] The new code passes pre-commit validations (`pre-commit run --all-files`).
- [ ] The new code passes pre-commit validations (`poetry run pre-commit run --all-files`).
- [ ] The PR relates to _only_ one subject with a clear title.
and description in grammatically correct, complete sentences.

Expand Down
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ repos:
# pre-commit's default_language_version, see
# https://pre-commit.com/#top_level-default_language_version
language_version: python3.10
- repo: https://github.com/python-poetry/poetry
rev: '1.4.0'
hooks:
- id: poetry-check
- id: poetry-lock
language_version: python3.10
zaro0508 marked this conversation as resolved.
Show resolved Hide resolved
args: ['--check']
- repo: https://github.com/AleksaC/circleci-cli-py
rev: v0.1.25638
hooks:
Expand Down
Loading