Skip to content

Commit

Permalink
Add circleci tests for python versions 3.9, 3.10 & 3.11
Browse files Browse the repository at this point in the history
- Remove functional-ftp circleci job as ftp server docker image is no longer supported (Previously didn't run ftp tests)
- Pin black version number in pipfile to avoid lint/format loop
- Pin moto format number to avoid dependency errors in Python versions > 3.9
- Update pipfile for for black and moto
- Update deprecated moto mock call in conftest.py
  • Loading branch information
STMilligan committed May 1, 2024
1 parent e6e2a09 commit b7032aa
Show file tree
Hide file tree
Showing 5 changed files with 677 additions and 824 deletions.
124 changes: 67 additions & 57 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ version: 2.1

executors:
standard:
parameters:
version:
description: "python version"
default: "3.9"
type: string
docker:
- image: circleci/python:3.9
- image: cimg/python:<< parameters.version >>
environment:
PIPENV_VENV_IN_PROJECT: true
working_directory: "~/lib"
Expand Down Expand Up @@ -42,54 +47,79 @@ commands:
- "./.git"

update_virtualenv:
parameters:
version:
description: "python version"
default: "3.9"
type: string
steps:
- restore_cache:
keys:
- virtualenv-{{ .Environment.CACHE_VERSION }}-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
- virtualenv-{{ .Environment.CACHE_VERSION }}-{{ .Branch }}-
- virtualenv-{{ .Environment.CACHE_VERSION }}-
- virtualenv-<< parameters.version >>{{ .Environment.CACHE_VERSION }}-{{ .Branch }}
- virtualenv-<< parameters.version >>{{ .Environment.CACHE_VERSION }}
- configure_github
- run:
name: Install Python packages
command: make sync
- save_cache:
key: virtualenv-{{ .Environment.CACHE_VERSION }}-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
key: virtualenv-<< parameters.version >>{{ .Environment.CACHE_VERSION }}-{{ .Branch }}
paths:
- "./.venv"

jobs:
lint:
executor: standard
parameters:
version:
description: "python version"
default: "3.9"
type: string
executor:
name: standard
version: << parameters.version >>
steps:
- checkout_source
- update_virtualenv
- update_virtualenv:
version: << parameters.version >>
- run:
name: Run Python linter
command: make lint

unit:
executor: standard
parameters:
version:
description: "python version"
default: "3.9"
type: string
executor:
name: standard
version: << parameters.version >>
steps:
- checkout_source
- update_virtualenv
- update_virtualenv:
version: << parameters.version >>
- run:
name: Run Python unit tests
command: make unit

release:
parameters:
version:
description: "python version"
type: string
default: "3.9"
working_directory: ~/lib

docker:
- image: circleci/python:3.9
- image: cimg/python:<< parameters.version >>

steps:
- checkout_source
- update_virtualenv
- update_virtualenv:
version: "3.9"
- restore_cache:
keys:
- pip-cache-{{ .Environment.CACHE_VERSION }}-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
- pip-cache-{{ .Environment.CACHE_VERSION }}-{{ .Branch }}-
- pip-cache-{{ .Environment.CACHE_VERSION }}-
- virtualenv-<< parameters.version >>{{ .Environment.CACHE_VERSION }}-{{ .Branch }}
- virtualenv-<< parameters.version >>{{ .Environment.CACHE_VERSION }}

- run:
name: verify git tag vs. version
Expand All @@ -110,36 +140,16 @@ jobs:
make release
functional-ftp:
working_directory: ~/lib

docker:
- image: circleci/python:3.9
environment:
TENTACLIO__CONN__FTP_TEST: ftp://octopus:tentacle@localhost

- image: mauler/simple-ftp-server
environment:
FTP_USER: octopus
FTP_PASS: tentacle

steps:
- checkout

- restore_cache:
keys:
- pip-cache-{{ .Environment.CACHE_VERSION }}-{{ .Branch }}-{{ checksum "Pipfile.lock" }}

- run:
name: Install Python packages
command: make sync


functional-sftp:
parameters:
version:
description: "python version"
type: string
default: "3.9"
working_directory: ~/lib

docker:
- image: circleci/python:3.9
- image: cimg/python:<< parameters.version >>
environment:
TENTACLIO__CONN__SFTP_TEST: sftp://octopus:tentacle@localhost:22

Expand All @@ -151,7 +161,8 @@ jobs:

- restore_cache:
keys:
- pip-cache-{{ .Environment.CACHE_VERSION }}-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
- virtualenv-<< parameters.version >>{{ .Environment.CACHE_VERSION }}-{{ .Branch }}
- virtualenv-<< parameters.version >>{{ .Environment.CACHE_VERSION }}

- run:
name: Install Python packages
Expand All @@ -163,7 +174,6 @@ jobs:


workflows:
version: 2

test-build-deploy:
jobs:
Expand All @@ -173,26 +183,26 @@ workflows:
only: /.*/

- unit:
filters:
tags:
only: /.*/
- functional-ftp:
filters:
tags:
only: /.*/
requires:
- lint
- unit
name: unit-<< matrix.version >>
matrix:
parameters:
version: ["3.9","3.10","3.11"]
filters:
tags:
only: /.*/
- functional-sftp:
filters:
tags:
only: /.*/
name: functional-sftp-<< matrix.version >>
matrix:
parameters:
version: ["3.9","3.10","3.11"]
filters:
tags:
only: /.*/
requires:
- lint
- unit
- unit-<< matrix.version >>
- release:
requires:
- functional-ftp
- functional-sftp
filters:
tags:
Expand Down
7 changes: 2 additions & 5 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[requires]
python_version = "3.9"

[dev-packages]
# Symlink to project root
tentaclio = {editable = true,path = "."}
# Linting
black = "*"
black = "==23.9.1"
isort = "*"
flake8 = "*"
mypy = "*"
Expand All @@ -19,7 +16,7 @@ types-paramiko = "*"
types-pyyaml = "*"
types-requests = "*"
# Testing
moto = "*"
moto = "==5.0.6"
pytest = "*"
pytest-cov = "*"
pytest-mock = "*"
Expand Down
Loading

0 comments on commit b7032aa

Please sign in to comment.