Skip to content

Commit

Permalink
build: add test matrix for multiple python versions (#144)
Browse files Browse the repository at this point in the history
* fix: upload artifacts with different names

* build: add optional input for test python version

* build: try use format()

* build: add python matrix

* chore: add example usage

* build: try add container job

* build: disable other test jobs

* tmp: install lfs in container

* tmp: apt-get update first

* tmp: run container as root

* tmp: make workdir simpler

* build: separate build and test jobs

* chore: clean up

* chore: rename jobs

---------

Co-authored-by: Vishwa Shah <vishwa2710@gmail.com>
  • Loading branch information
alex-liang3 and vishwa2710 authored Jan 14, 2025
1 parent 63b9b21 commit d780c04
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,46 @@ jobs:
- name: Check Python Format
run: make format-check-python-standalone

build-python:
name: Build Python bindings
runs-on: ubuntu-latest
outputs:
python_versions: ${{ steps.python-versions.outputs.value }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Pull Development Image
run: docker pull ${{ env.DOCKER_REGISTRY_PATH }}/${{ inputs.project_name }}-development:${{ inputs.project_version }}
- name: Build Python Bindings
run: make build-packages-python-standalone
- name: Upload Python Bindings
uses: actions/upload-artifact@v4
with:
name: python-bindings # TBM: use a different namespace than in build-packages for now.
path: packages/python/
- id: python-versions
name: Export Python Versions to Environment
run: |
python_versions=$(echo -n "["; find packages/python -name "*.whl" | grep -o "py[0-9]\{2,3\}" | sed 's/py\([0-9]\)\([0-9][0-9]\?\)/\1.\2/' | sed "s/\([0-9.]*\)/'\1'/" | tr '\n' ',' | sed 's/,$//'; echo "]")
echo "Python versions: ${python_versions}"
echo "value=${python_versions}" >> $GITHUB_OUTPUT
test-unit-python:
name: Run Python Unit Tests
runs-on: ubuntu-latest
needs:
- build-python
strategy:
matrix:
python-version: ${{ fromJson(needs.build-python.outputs.python_versions) }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand All @@ -103,5 +140,10 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Pull Development Image
run: docker pull ${{ env.DOCKER_REGISTRY_PATH }}/${{ inputs.project_name }}-development:${{ inputs.project_version }}
- name: Download Python packages
uses: actions/download-artifact@v4
with:
name: python-bindings
path: packages/python/
- name: Run Unit Tests Python
run: make test-unit-python-standalone
run: make ci-test-python ${{ format('test_python_version={0}', matrix.python-version) }}

0 comments on commit d780c04

Please sign in to comment.