From 07558cc824d8ab1938987242ba4ee454fe5a7e32 Mon Sep 17 00:00:00 2001 From: Jonathan Wren Date: Mon, 26 Oct 2020 09:40:00 -0700 Subject: [PATCH] Moved repeated commands into commands section for reuse in jobs Circle apparently allows you to separate custom commands into their own key, and then reuse them at will in jobs. --- .circleci/config.yml | 88 ++++++++++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 36 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7c3cee78..49f2efee 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,19 +5,20 @@ executors: docker: - image: circleci/python:3.7.9 resource_class: small + python38: docker: - image: circleci/python:3.8.6 resource_class: small + python39: docker: - image: circleci/python:3.9.0 resource_class: small -aliases: - linux_test: &linux_test +commands: + get_poetry_deps: steps: - - checkout - run: name: Checking Python version command: python --version > /tmp/pythonversion @@ -32,51 +33,28 @@ aliases: key: 'deps-00-{{ checksum "poetry.lock" }}-{{ checksum "/tmp/pythonversion" }}' paths: - ~/project/.venv - - run: poetry install + + pytest: + steps: - run: name: Tests - Pytest - when: always command: > poetry run pytest --junitxml=reports/pytest/results.xml + + behave: + steps: - run: name: Tests - Behave - when: always command: > poetry run behave --no-skipped --format progress2 --junit --junit-directory reports/behave - - store_test_results: - path: reports - -jobs: - linux_test_37: - executor: python37 - <<: *linux_test - - linux_test_38: - executor: python38 - <<: *linux_test - - linux_test_39: - executor: python39 - <<: *linux_test lint: - executor: python39 steps: - - checkout - - run: python --version > /tmp/pythonversion - - restore_cache: - key: 'deps-00-{{ checksum "poetry.lock" }}-{{ checksum "/tmp/pythonversion" }}' - - run: poetry config --local virtualenvs.in-project true - - run: poetry install --no-root --remove-untracked - - save_cache: - key: 'deps-00-{{ checksum "poetry.lock" }}-{{ checksum "/tmp/pythonversion" }}' - paths: - - ~/project/.venv - run: name: Poetry Check command: | @@ -93,10 +71,48 @@ jobs: poetry run pyflakes --version poetry run pyflakes jrnl features tests +aliases: + linux_test: &linux_test + steps: + - checkout + - get_poetry_deps + - run: poetry install + - pytest: + when: always + - behave: + when: always + - store_test_results: + path: reports + +jobs: + test_37_linux: + executor: python37 + <<: *linux_test + + test_38_linux: + executor: python38 + <<: *linux_test + + test_39_linux: + executor: python39 + <<: *linux_test + + linting: + executor: python39 + steps: + - checkout + - get_poetry_deps + - lint + workflows: + version: 2 main: jobs: - - lint - - linux_test_37 - - linux_test_38 - - linux_test_39 + - linting: + name: Linting and Formatting + - test_37_linux: + name: Python 3.7 - Linux + - test_38_linux: + name: Python 3.8 - Linux + - test_39_linux: + name: Python 3.9 - Linux