Skip to content

Commit 0ceadd4

Browse files
authored
Added CircleCI config.yml (#20)
* Added CircleCI config.yml - run all tox factors per python environment - run lint - cache pip wheels at ~/.cache/pip - write junit.xml for circleci to track individual tests
1 parent ad7c1f8 commit 0ceadd4

File tree

2 files changed

+88
-1
lines changed

2 files changed

+88
-1
lines changed

.circleci/config.yml

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
version: 2.1
2+
3+
commands:
4+
run_with_pip_cache:
5+
description: Run the passed steps with a restored pip cache
6+
parameters:
7+
cache_key_base:
8+
type: string
9+
description: Base part of the cache key. Version and a more specific checksum of files will be added too.
10+
cache_key_version:
11+
type: string
12+
description: Version prefix. Can be changed to invalidate caches.
13+
default: v1
14+
steps:
15+
type: steps
16+
steps:
17+
- run: cat tox.ini dev-constraints.txt > check.txt
18+
- restore_cache:
19+
name: Restoring pip wheel cache
20+
keys:
21+
- &key_full << parameters.cache_key_version >>-<< parameters.cache_key_base >>-{{ checksum "check.txt" }}
22+
- &key << parameters.cache_key_version >>-<< parameters.cache_key_base >>
23+
- steps: << parameters.steps >>
24+
- save_cache:
25+
name: Saving base pip wheel cache
26+
key: *key
27+
paths:
28+
- ~/.cache/pip
29+
- save_cache:
30+
name: Saving checksummed pip wheel cache
31+
key: *key_full
32+
paths:
33+
- ~/.cache/pip
34+
35+
setup:
36+
description: Checkout code and install tox
37+
steps:
38+
- checkout
39+
- run: sudo pip install tox-factor
40+
41+
jobs:
42+
lint:
43+
docker:
44+
- image: circleci/python:3.8
45+
steps:
46+
- setup
47+
- run_with_pip_cache:
48+
cache_key_base: lint-python3.8
49+
steps:
50+
- run: tox -e lint-ci
51+
52+
tests:
53+
parameters:
54+
python3_minor:
55+
type: integer
56+
description: The x in python3.x
57+
docker:
58+
- image: circleci/python:3.<< parameters.python3_minor >>
59+
steps:
60+
- setup
61+
- run_with_pip_cache:
62+
cache_key_base: test-python3.<< parameters.python3_minor >>
63+
steps:
64+
- run:
65+
name: Run tox test factors for python3.<< parameters.python3_minor >>
66+
command: >
67+
tox
68+
-s false
69+
-pauto
70+
-f py3<< parameters.python3_minor >>-ci
71+
-- '--junitxml=../test-results/$TOX_ENV_NAME/junit.xml'
72+
- store_test_results:
73+
path: test-results
74+
- store_artifacts:
75+
path: test-results
76+
77+
workflows:
78+
version: 2
79+
main:
80+
jobs:
81+
- lint
82+
- tests:
83+
name: tests-python3.<< matrix.python3_minor >>
84+
matrix:
85+
parameters:
86+
python3_minor: [4, 5, 6, 7, 8]

tox.ini

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ commands_pre =
6262
test: pip install .
6363

6464
commands =
65-
test: pytest
65+
; use subshell to allow using tox envars in substitution
66+
test: bash -c 'pytest {posargs}'
6667

6768
whitelist_externals = bash
6869

0 commit comments

Comments
 (0)