-
Notifications
You must be signed in to change notification settings - Fork 1
143 lines (140 loc) · 4.72 KB
/
build-py310-cpu.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: build for python 3.10 on CPU
on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: read
jobs:
build:
name: build
runs-on: ubuntu-latest
timeout-minutes: 30
defaults:
run:
shell: bash -el {0} # required otherwise conda will not be activated for "run" steps
env:
W_ENV_NAME: buildenv
W_REQ_CONDA: .github/workflow-env-py310-cpu.yml
W_REQ_PIP: requirements.txt
W_CACHE_NUMBER: 0 # increase to reset cache
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2 # stuck cache download should stop after X minutes
W_CACHE_KILL: 3 # hard kill a stuck cache download after X minutes
steps:
#
- name: Checkout code
uses: actions/checkout@v4
#
- name: Setup conda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: ${{ env.W_ENV_NAME }}
miniforge-variant: Mambaforge
miniforge-version: latest
use-mamba: true
#
- name: Collect information
id: collect-info
run: |
conda info
echo "----------"
_now=$(date -u '+%s')
echo "today=$(date -u '+%Y%m%d' -d @${_now})" >> $GITHUB_OUTPUT
echo "thisweek=$(date -u '+%V' -d @${_now})" >> $GITHUB_OUTPUT
echo "env_conda=$CONDA" >> $GITHUB_OUTPUT
mkdir -p /tmp/dummydir1
echo "pipdummy written to tempdir" > /tmp/dummydir1/pipdummy.txt
cat /tmp/dummydir1/pipdummy.txt
echo "----------"
echo "saved output:"
cat $GITHUB_OUTPUT
#
- name: Check if pip should update
uses: actions/cache/restore@v4
timeout-minutes: 1
continue-on-error: true
with:
path: /tmp/dummydir1
key: pipupdate-${{ runner.os }}--${{ runner.arch }}--${{ env.W_ENV_NAME }}--date-${{
steps.collect-info.outputs.today }}-conda-${{
hashFiles(env.W_REQ_CONDA) }}-pip-${{
hashFiles(env.W_REQ_PIP)}}-cachenum-${{
env.W_CACHE_NUMBER }}
id: cache-pipdummy-restore
#
- name: Save that pip will update
uses: actions/cache/save@v4
timeout-minutes: 1
continue-on-error: true
with:
path: /tmp/dummydir1
key: ${{ steps.cache-pipdummy-restore.outputs.cache-primary-key }}
id: cache-pipdummy-save
if: steps.cache-pipdummy-restore.outputs.cache-hit != 'true'
#
- name: Restore cache for conda env # cannot see $CONDA here so use output from previous step
uses: actions/cache/restore@v4
timeout-minutes: ${{ fromJSON(env.W_CACHE_KILL) }} # fromJSON is required to convert to int
continue-on-error: true
with:
path: ${{ steps.collect-info.outputs.env_conda }}/envs/${{ env.W_ENV_NAME }}
key: conda-${{ runner.os }}--${{ runner.arch }}--${{ env.W_ENV_NAME }}--calweek-${{
steps.collect-info.outputs.thisweek }}--conda-${{
hashFiles(env.W_REQ_CONDA) }}--cachenum-${{
env.W_CACHE_NUMBER }}--commit-${{ github.sha }}
restore-keys: conda-${{ runner.os }}--${{ runner.arch }}--${{ env.W_ENV_NAME }}--calweek-${{
steps.collect-info.outputs.thisweek }}--conda-${{
hashFiles(env.W_REQ_CONDA) }}--cachenum-${{
env.W_CACHE_NUMBER }}
id: cache-conda-restore
#
- name: Conda install packages
run: |
mamba env update -q -n ${{ env.W_ENV_NAME }} -f ${{ env.W_REQ_CONDA }}
if: steps.cache-conda-restore.outputs.cache-matched-key == ''
id: conda-install
#
- name: Pip install packages
run: |
python -m pip install --progress-bar off -U pip
pip install --progress-bar off -U -r ${{ env.W_REQ_PIP }}
pip install --progress-bar off -U pytest pytest-cov pylint
if: |
steps.cache-conda-restore.outputs.cache-matched-key == '' ||
steps.cache-pipdummy-restore.outputs.cache-hit != 'true'
id: pip-install
#
- name: Conda list
run: conda list
#
- name: Pip list
run: pip list
#
- name: Save cache for conda env
uses: actions/cache/save@v4
timeout-minutes: ${{ fromJSON(env.W_CACHE_KILL) }} # fromJSON is required to convert to int
continue-on-error: true
with:
path: ${{ steps.collect-info.outputs.env_conda }}/envs/${{ env.W_ENV_NAME }}
key: ${{ steps.cache-conda-restore.outputs.cache-primary-key }}
id: cache-conda-save
if: |
steps.cache-conda-restore.outputs.cache-matched-key == '' ||
steps.cache-pipdummy-restore.outputs.cache-hit != 'true'
#
- name: Install code
run: |
python -m pip install -U -e .
#
- name: Run pytest
run: |
python -m pytest tests --cov
#
- name: Run pylint
continue-on-error: true
run: |
pylint ovqa
pylint tests
#