Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflow to test conda packages #1935

Merged
merged 56 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
94c0dc9
Add workflow to test conda packages
roomrys Sep 4, 2024
4929114
Try using -c local
Sep 4, 2024
ab1ee76
Use v3 artifact (to not rebuild between while debugging)
Sep 4, 2024
dcf8bc1
Try downloading build from another workflow run
roomrys Sep 4, 2024
d2f908e
Try downloading to mock channel folder
roomrys Sep 4, 2024
83615b8
Try uploading entire build directory
roomrys Sep 4, 2024
a8062b7
Use ' instead of " around Windows runner.os
roomrys Sep 4, 2024
b16e091
Comment all non-Windows OS's
roomrys Sep 4, 2024
ce6a75f
Use build instead of $BUILD_PATH
roomrys Sep 4, 2024
afda184
Change run-id and do not rebuild
roomrys Sep 4, 2024
e0c4dfb
Add RUN_BUILD_JOB env variable
roomrys Sep 4, 2024
dcd2949
Replace and with &&
roomrys Sep 4, 2024
20de414
Set-up miniconda
roomrys Sep 4, 2024
c70a4d8
List what is in the build download directory
roomrys Sep 4, 2024
9b445c3
Try file:/// instead of file://
roomrys Sep 4, 2024
ca1f95d
Try using file://$(pwd)/build
roomrys Sep 4, 2024
12b203b
Run conda index on the build folder
roomrys Sep 4, 2024
4b8957c
Try using conda-index instead
roomrys Sep 4, 2024
74093f4
Try using conda-build index
roomrys Sep 4, 2024
532eb59
Add a before and after search for package
roomrys Sep 4, 2024
6b7620b
Use github.envents.inputs instead of env in name
roomrys Sep 4, 2024
9efed16
Retry using conda-index
roomrys Sep 4, 2024
e693eae
Remove search before conda-index
roomrys Sep 4, 2024
c18455e
Retry using conda-build index
roomrys Sep 4, 2024
93bfef4
Try removing file://
roomrys Sep 4, 2024
eaf1562
Remove conda search
roomrys Sep 4, 2024
f084ddc
Use . instead of $(pwd)
roomrys Sep 4, 2024
79225c3
Move sleap right after conda create
roomrys Sep 4, 2024
bf03882
pip install only dev_requirements.txt for testing
roomrys Sep 4, 2024
fe5aa50
Rebuild packages for all OS's
roomrys Sep 4, 2024
8b5e45d
Activate environment and test in one step
roomrys Sep 4, 2024
7511000
Set RUN_BUILD_JOB to false
roomrys Sep 4, 2024
d95c2b8
Set overwrite to true on upload
roomrys Sep 4, 2024
cfefd80
Attmept to fix dynamic build job name
roomrys Sep 4, 2024
67c6680
Attempt 2 to fix dynamic build job name
roomrys Sep 4, 2024
583ddc7
See if job name works for build job false
roomrys Sep 4, 2024
166d1eb
Rebuild win and linux each uploading to different artifact names
roomrys Sep 5, 2024
cdac265
Update run id
Sep 5, 2024
61fefc0
Use steps.step-id.outputs instead of env for run id
Sep 5, 2024
d09b3b0
Use different conditional syntax for windows runner
Sep 5, 2024
bb8ea09
Use different conditional syntax for windows runner try 2
Sep 5, 2024
48303f3
Use static run ids
Sep 5, 2024
77338d2
Flip conditional for set-run-id
Sep 5, 2024
945e2e5
Rebuild for all os's
Sep 5, 2024
4b3ed81
Rename build_ci to build_pypi_ci
Sep 5, 2024
8b162ae
Change job name to "Set run id"
Sep 5, 2024
5000be9
Test that current run id is used
Sep 5, 2024
65cb196
Try using github.run_id in windows runner
Sep 5, 2024
67539f9
Now try flipped conditional for set run id
Sep 5, 2024
2f62c7f
Try to merge set run id for all OS's
Sep 5, 2024
0c3e477
Flip conditional for use current run id
Sep 5, 2024
376cd90
Separate test package step
Sep 5, 2024
185796f
Conda activate before testing package
Sep 5, 2024
d9bebd2
Rename sleap_test to sleap_ci
Sep 5, 2024
b18753b
Merge Build conda package step for all OS's
Sep 5, 2024
efb2295
Rename job to Run tests using "package"
Sep 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 179 additions & 0 deletions .github/workflows/build_conda_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
# 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"

# If RUN_BUILD_JOB is set to true, then RUN_ID will be overwritten to the current run id
env:
RUN_BUILD_JOB: true
RUN_ID: 10713717594 # Only used if RUN_BUILD_JOB is false (to dowload build artifact)

jobs:
build:
name: Build package from push (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["windows-2022", "ubuntu-22.04", "macos-14"]
# 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
- 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
- name: Build conda package
if: env.RUN_BUILD_JOB == 'true'
shell: bash -l {0}
run: |
conda build ${{ matrix.conda-folder }} --output-folder build

# 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 package (${{ 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"]
# 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
# 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 id for conda package download
shell: bash -l {0}
if: env.RUN_BUILD_JOB == 'true'
run: echo "RUN_ID=${{ github.run_id }}" >> $GITHUB_ENV
roomrys marked this conversation as resolved.
Show resolved Hide resolved

# 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]
with:
miniforge-version: latest
condarc-file: ${{ matrix.condarc }}
python-version: ${{ matrix.pyver }}
conda-solver: "libmamba"

- name: Create conda environment
shell: bash -l {0}
run: conda create sleap -y -n sleap_ci -c ./build ${{ matrix.conda-channels }}

- name: Install packages for testing
shell: bash -l {0}
run: |
conda activate sleap_ci
pip install -r "dev_requirements.txt"

# Note: "conda activate" does not persist across steps
- name: Print environment info
shell: bash -l {0}
run: |
conda activate sleap_ci
conda info
conda list
pip freeze

- name: Test package
shell: bash -l {0}
run: |
conda activate sleap_ci
${{ matrix.test_args}}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Run tests using built wheels.
name: Build CI (no upload)
name: Build PyPI CI (no upload)

# Run when changes to pip wheel
on:
push:
paths:
- 'setup.py'
- 'requirements.txt'
- 'dev_requirements.txt'
- 'jupyter_requirements.txt'
- 'pypi_requirements.txt'
- 'environment_build.yml'
- '.github/workflows/build_ci.yml'
- "setup.py"
- "requirements.txt"
- "dev_requirements.txt"
- "jupyter_requirements.txt"
- "pypi_requirements.txt"
- "environment_build.yml"
- ".github/workflows/build_pypi_ci.yml"

jobs:
build:
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
shell: bash -l {0}
run: |
python setup.py bdist_wheel

# Upload artifact "tests" can use it
- name: Upload wheel artifact
uses: actions/upload-artifact@v4
Expand All @@ -66,7 +66,7 @@ jobs:
tests:
name: Run tests using wheel (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: build # Ensure the build job has completed before starting this job.
needs: build # Ensure the build job has completed before starting this job.
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -103,12 +103,12 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.pyver }}

# Download wheel
- name: Download wheel artifact
uses: actions/download-artifact@v4
Expand Down Expand Up @@ -144,8 +144,8 @@ jobs:
run: |
which python
pip freeze

# Install and test the wheel
- name: Test the built wheel
run: |
${{ matrix.test_args}}
${{ matrix.test_args}}
Loading