@@ -20,116 +20,74 @@ defaults:
20
20
shell : bash -l {0}
21
21
22
22
jobs :
23
- style :
24
- name : Style
23
+ code_style :
24
+ name : ${{ matrix.check.name }}
25
25
runs-on : ubuntu-latest
26
-
26
+ strategy :
27
+ matrix :
28
+ check :
29
+ - name : Code Formatting | black
30
+ command : black --check .
31
+ - name : Import Ordering | isort
32
+ command : isort --check .
33
+ - name : Linting | flake8
34
+ command : flake8 .
35
+ - name : Type Checking | mypy
36
+ command : mypy . --cache-dir=/dev/null
27
37
steps :
28
38
- uses : actions/checkout@v3
29
-
39
+
30
40
- name : Setup Python
31
41
uses : actions/setup-python@v4
32
42
with :
33
43
python-version : ${{ env.DEFAULT_PYTHON_VERSION }}
34
44
35
- - name : Install requirements
36
- run : |
37
- grep -E '^black' dev-requirements.txt | xargs pip install
45
+ - name : Cache Python Environment
46
+ uses : actions/cache@v2
47
+ with :
48
+ path : .venv
49
+ key : ${{ runner.os }}-pyenv-${{ hashFiles('dev-requirements.txt') }}
50
+ restore-keys : |
51
+ ${{ runner.os }}-pyenv-
38
52
39
- - name : Debug info
53
+ - name : Install Development Requirements
40
54
run : |
41
- pip freeze
55
+ python -m venv .venv
56
+ source .venv/bin/activate
57
+ pip install -r dev-requirements.txt
42
58
43
- - name : Run black
59
+ - name : Run Code Style Check
44
60
run : |
45
- black --check .
46
-
47
- checks :
48
- name : ${{ matrix.task.name }}
49
- runs-on : ${{ matrix.task.runs_on }}
50
- timeout-minutes : 30
51
- strategy :
52
- fail-fast : false
53
- matrix :
54
- task :
55
- - name : Lint
56
- runs_on : ubuntu-latest
57
- coverage_report : false
58
- platform : cpu
59
- run : |
60
- make flake8
61
- make import-sort
62
- make typecheck
63
-
64
- - name : CPU Tests
65
- runs_on : ubuntu-latest
66
- coverage_report : true
67
- platform : cpu
68
- run : make tests
61
+ source .venv/bin/activate
62
+ ${{ matrix.check.command }}
69
63
64
+ unit_tests :
65
+ name : Unit Tests
66
+ runs-on : ubuntu-latest
70
67
steps :
71
68
- uses : actions/checkout@v3
72
-
73
- - uses : conda-incubator/setup-miniconda@v2
69
+
70
+ - name : Setup Python
71
+ uses : actions/setup-python@v4
74
72
with :
75
- miniconda-version : " latest"
76
73
python-version : ${{ env.DEFAULT_PYTHON_VERSION }}
77
74
78
- - name : Set build variables
79
- run : |
80
- # Get the exact Python version to use in the cache key.
81
- echo "PYTHON_VERSION=$(python --version)" >> $GITHUB_ENV
82
- echo "RUNNER_ARCH=$(uname -m)" >> $GITHUB_ENV
83
- # Use week number in cache key so we can refresh the cache weekly.
84
- echo "WEEK_NUMBER=$(date +%V)" >> $GITHUB_ENV
85
-
86
- - uses : actions/cache@v3
87
- id : virtualenv-cache
75
+ - name : Cache Python Environment
76
+ uses : actions/cache@v2
88
77
with :
89
78
path : .venv
90
- key : >
91
- ${{ env.CACHE_PREFIX }}-${{ env.WEEK_NUMBER }}-${{ runner.os }}-${{ env.RUNNER_ARCH }}-
92
- ${{ env.PYTHON_VERSION }}-${{ matrix.task.platform }}-${{ hashFiles('setup.py') }}-
93
- ${{ hashFiles('*requirements.txt') }}
94
-
95
- - name : Setup virtual environment (no cache hit)
96
- if : steps.virtualenv-cache.outputs.cache-hit != 'true'
97
- run : |
98
- python${{ env.DEFAULT_PYTHON_VERSION }} -m venv .venv
99
- source .venv/bin/activate
100
- make install
101
-
102
- - name : Setup virtual environment (cache hit)
103
- if : steps.virtualenv-cache.outputs.cache-hit == 'true'
104
- run : |
105
- source .venv/bin/activate
106
- pip install --no-deps -e .[all]
107
-
108
- - name : Debug info
109
- run : |
110
- source .venv/bin/activate
111
- pip freeze
79
+ key : ${{ runner.os }}-pyenv-${{ hashFiles('requirements.txt') }}
80
+ restore-keys : |
81
+ ${{ runner.os }}-pyenv-
112
82
113
- - name : ${{ matrix.task.name }}
83
+ - name : Install Development Requirements
114
84
run : |
85
+ python -m venv .venv
115
86
source .venv/bin/activate
116
- ${{ matrix.task.run }}
117
-
118
- - name : Prepare coverage report
119
- if : matrix.task.coverage_report
120
- run : |
121
- mkdir coverage
122
- mv coverage.xml coverage/
123
-
124
- - name : Save coverage report
125
- if : matrix.task.coverage_report
126
- uses : actions/upload-artifact@v3
127
- with :
128
- name : ${{ matrix.task.name }}-coverage
129
- path : ./coverage
87
+ pip install -r requirements.txt
130
88
131
- - name : Clean up
132
- if : always()
89
+ - name : Run Tests
133
90
run : |
134
91
source .venv/bin/activate
135
- pip uninstall --yes arrayfire
92
+ make tests
93
+
0 commit comments