11name : CI
22
3+ concurrency :
4+ group : ${{ github.workflow }}-${{ github.ref }}
5+ cancel-in-progress : true
6+
37on :
48 pull_request :
59 branches :
1115env :
1216 DEFAULT_PYTHON_VERSION : " 3.8"
1317
18+ defaults :
19+ run :
20+ shell : bash -l {0}
21+
1422jobs :
15- build :
23+ style :
24+ name : Style
1625 runs-on : ubuntu-latest
1726
1827 steps :
@@ -25,12 +34,102 @@ jobs:
2534
2635 - name : Install requirements
2736 run : |
28- pip install -r requirements.txt
37+ grep -E '^black' dev-requirements.txt | xargs pip install
38+
39+ - name : Debug info
40+ run : |
41+ pip freeze
42+
43+ - name : Run black
44+ 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
69+
70+ steps :
71+ - uses : actions/checkout@v3
72+
73+ - uses : conda-incubator/setup-miniconda@v2
74+ with :
75+ miniconda-version : " latest"
76+ python-version : ${{ env.DEFAULT_PYTHON_VERSION }}
77+
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
88+ with :
89+ 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]
29107
30108 - name : Debug info
31109 run : |
110+ source .venv/bin/activate
32111 pip freeze
33112
34- - name : Run tests
113+ - name : ${{ matrix.task.name }}
114+ run : |
115+ 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
130+
131+ - name : Clean up
132+ if : always()
35133 run : |
36- pytest .
134+ source .venv/bin/activate
135+ pip uninstall --yes arrayfire
0 commit comments