@@ -20,116 +20,74 @@ defaults:
2020 shell : bash -l {0}
2121
2222jobs :
23- style :
24- name : Style
23+ code_style :
24+ name : ${{ matrix.check.name }}
2525 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
2737 steps :
2838 - uses : actions/checkout@v3
29-
39+
3040 - name : Setup Python
3141 uses : actions/setup-python@v4
3242 with :
3343 python-version : ${{ env.DEFAULT_PYTHON_VERSION }}
3444
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-
3852
39- - name : Debug info
53+ - name : Install Development Requirements
4054 run : |
41- pip freeze
55+ python -m venv .venv
56+ source .venv/bin/activate
57+ pip install -r dev-requirements.txt
4258
43- - name : Run black
59+ - name : Run Code Style Check
4460 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 }}
6963
64+ unit_tests :
65+ name : Unit Tests
66+ runs-on : ubuntu-latest
7067 steps :
7168 - uses : actions/checkout@v3
72-
73- - uses : conda-incubator/setup-miniconda@v2
69+
70+ - name : Setup Python
71+ uses : actions/setup-python@v4
7472 with :
75- miniconda-version : " latest"
7673 python-version : ${{ env.DEFAULT_PYTHON_VERSION }}
7774
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
8877 with :
8978 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-
11282
113- - name : ${{ matrix.task.name }}
83+ - name : Install Development Requirements
11484 run : |
85+ python -m venv .venv
11586 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
13088
131- - name : Clean up
132- if : always()
89+ - name : Run Tests
13390 run : |
13491 source .venv/bin/activate
135- pip uninstall --yes arrayfire
92+ make tests
93+
0 commit comments