-
Notifications
You must be signed in to change notification settings - Fork 101
185 lines (168 loc) · 6.16 KB
/
build_conda_ci.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# Run tests using built conda packages.
name: Build Conda CI (no upload)
# Run when changes to pip wheel
on:
push:
paths:
- ".conda/meta.yaml"
- ".conda_mac/meta.yaml"
- "setup.py"
- "requirements.txt"
- "dev_requirements.txt"
- "environment_build.yml"
- ".github/workflows/build_conda_ci.yml"
env:
RUN_BUILD_JOB: false
RUN_ID: 10712122474
jobs:
build:
name: >-
${{ github.event.inputs.RUN_BUILD_JOB == 'false'
&& 'Skip '
|| ''}}
Build package from push (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["windows-2022", "ubuntu-22.04"] #, "macos-14"] # TODO(LM): Uncomment
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrixinclude
include:
# Use these variables as defaults
- condarc: .conda/condarc.yaml
- conda-folder: .conda
- pyver: "3.10"
- build-prefix: win
# TODO(LM): Uncomment to run on all os's
- os: "ubuntu-22.04"
build-prefix: linux
# Use special condarc if macos
# - os: "macos-14"
# condarc: .conda_mac/condarc.yaml
# conda-folder: .conda_mac
# build-prefix: osx
steps:
# Setup
- name: Checkout
if: env.RUN_BUILD_JOB == 'true'
uses: actions/checkout@v4
- name: Setup Miniconda
if: env.RUN_BUILD_JOB == 'true'
uses: conda-incubator/[email protected]
with:
miniforge-version: latest
condarc-file: ${{ matrix.condarc }}
python-version: ${{ matrix.pyver }}
environment-file: environment_build.yml
activate-environment: sleap_ci
conda-solver: "libmamba"
- name: Print build environment info
if: env.RUN_BUILD_JOB == 'true'
shell: bash -l {0}
run: |
which python
conda list
pip freeze
# Build conda package (not Windows)
- name: Build conda package (not Windows)
if: runner.os != 'Windows' && env.RUN_BUILD_JOB == 'true'
shell: bash -l {0}
run: |
conda build ${{ matrix.conda-folder }} --output-folder build
echo "BUILD_PATH=$(pwd)/build" >> "$GITHUB_ENV"
# Build conda package (Windows)
- name: Build conda package (Windows)
if: matrix.os == 'windows-2022' && env.RUN_BUILD_JOB == 'true'
shell: powershell
run: |
conda build ${{ matrix.conda-folder }} --output-folder build
echo "BUILD_PATH=\$(pwd)\build" >> "$env:GITHUB_ENV"
# Upload artifact "tests" can use it
- name: Upload conda package artifact
if: env.RUN_BUILD_JOB == 'true'
uses: actions/upload-artifact@v4
with:
name: sleap-build-${{ matrix.build-prefix }}
path: build # Upload entire build directory
retention-days: 1
overwrite: true
tests:
name: Run tests using wheel (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: build # Ensure the build job has completed before starting this job.
strategy:
fail-fast: false
matrix:
os: ["windows-2022", "ubuntu-22.04"] # , "macos-14"] # TODO(LM): Uncomment
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrixinclude
include:
# Default values
- build-prefix: win
- build-suffix: 64
- test_args: pytest --durations=-1 tests/
- condarc: .conda/condarc.yaml
- pyver: "3.10"
- conda-channels: -c conda-forge -c nvidia -c anaconda
# TODO(LM): Uncomment to run on all OS's
# Ubuntu specific values
- os: ubuntu-22.04
build-prefix: linux
# Otherwise core dumped in github actions
test_args: |
sudo apt install xvfb libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0
sudo Xvfb :1 -screen 0 1024x768x24 </dev/null &
export DISPLAY=":1"
pytest tests -k 'not exclude_from_linux_pip_test'
# Use special condarc if macos
# - os: "macos-14"
# build-prefix: osx
# build-suffix: arm64
# condarc: .conda_mac/condarc.yaml
# conda-channels: -c conda-forge -c anaconda
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.pyver }}
- name: Use current run for conda package download
if: env.RUN_BUILD_JOB == 'true'
run: |
echo "RUN_ID=${{ github.run_id }}" >> $GITHUB_ENV
# https://github.com/actions/download-artifact?tab=readme-ov-file#usage
- name: Download conda package artifact
uses: actions/download-artifact@v4
id: download
with:
name: sleap-build-${{ matrix.build-prefix }}
path: build
run-id: ${{ env.RUN_ID }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: List items in current directory
run: |
ls .
ls -R build
- name: Setup Miniconda
uses: conda-incubator/[email protected] # TODO(LM): Upgrade
with:
miniforge-version: latest
condarc-file: ${{ matrix.condarc }}
python-version: ${{ matrix.pyver }}
conda-solver: "libmamba"
# Big step because "conda activate" does not persist across steps
- name: Test package
shell: bash -l {0}
run: |
echo "Create conda environment"
conda create sleap -y -n sleap_test -c ./build ${{ matrix.conda-channels }}
echo "Activate conda environment"
conda activate sleap_test
echo "Install packages for testing"
pip install -r "dev_requirements.txt"
echo "List environment info"
conda info
conda list
pip freeze
echo "Test environment"
${{ matrix.test_args}}