Skip to content

Commit

Permalink
Split Python and Rust tests in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Luthaf committed Jul 26, 2023
1 parent 1168c9d commit e310f57
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 68 deletions.
108 changes: 108 additions & 0 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Python tests

on:
push:
branches: [master]
pull_request:
# Check all PR

concurrency:
group: python-tests-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}

jobs:
tests:
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} / Python ${{ matrix.python-version }}
container: ${{ matrix.container }}
strategy:
matrix:
include:
- os: ubuntu-20.04
rust-target: x86_64-unknown-linux-gnu
python-version: "3.7"
- os: ubuntu-20.04
rust-target: x86_64-unknown-linux-gnu
python-version: "3.11"
- os: macos-11
rust-target: x86_64-apple-darwin
python-version: "3.11"
steps:
- uses: actions/checkout@v3

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

- name: setup rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
default: true
target: ${{ matrix.rust-target }}

- name: install python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox
echo "tox_version=$(tox --version | awk '{split($0, s," "); print s[1]}')" >> $GITHUB_ENV
- name: Setup sccache
uses: mozilla-actions/[email protected]

- name: Setup sccache environnement variables
run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "CMAKE_C_COMPILER_LAUNCHER=sccache" >> $GITHUB_ENV
echo "CMAKE_CXX_COMPILER_LAUNCHER=sccache" >> $GITHUB_ENV
- name: cache tox environments
uses: actions/cache@v3
with:
path: .tox
key: tox-${{ env.tox_version }}-${{ matrix.os }}-${{ hashFiles('tox.ini') }}

- name: run tox
run: tox

# second set of jobs checking that (non-test) code still compiles/run as expected
prevent-bitrot:
runs-on: ${{ matrix.os }}
name: Python ${{ matrix.python-version }} / check build
strategy:
matrix:
python-version: ['3.7', '3.11']
os: [ubuntu-20.04]
steps:
- uses: actions/checkout@v3

- name: set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: setup rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
default: true
target: x86_64-unknown-linux-gnu

- name: install python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox
echo "tox_version=$(tox --version | awk '{split($0, s," "); print s[1]}')" >> $GITHUB_ENV
- name: cache tox environments
uses: actions/cache@v3
with:
path: .tox
key: tox-${{ env.tox_version }}-${{ matrix.os }}-${{ hashFiles('tox.ini') }}

- name: python build tests
run: tox -e build-python
84 changes: 16 additions & 68 deletions .github/workflows/tests.yml → .github/workflows/rust-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: Rust tests

on:
push:
Expand All @@ -7,61 +7,40 @@ on:
# Check all PR

concurrency:
group: tests-${{ github.ref }}
group: rust-tests-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}

jobs:
tests:
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} / rust ${{ matrix.rust-version }} / ${{ matrix.build-type }} ${{ matrix.extra-name }}
name: ${{ matrix.os }} / rust ${{ matrix.rust-version }} ${{ matrix.extra-name }}
container: ${{ matrix.container }}
strategy:
matrix:
include:
- os: ubuntu-20.04
rust-version: stable
rust-target: x86_64-unknown-linux-gnu
python-version: "3.7"
build-type: debug
- os: ubuntu-20.04
rust-version: stable
rust-target: x86_64-unknown-linux-gnu
python-version: "3.11"
build-type: debug
- os: ubuntu-20.04
rust-version: stable
rust-target: x86_64-unknown-linux-gnu
python-version: "3.11"
build-type: debug
test-static-lib: true
extra-name: static C library
extra-name: / static C library
- os: ubuntu-20.04
rust-version: stable
rust-target: x86_64-unknown-linux-gnu
python-version: "3.11"
build-type: release
cargo-build-flags: --release
do-valgrind: true
- os: ubuntu-20.04
rust-version: "1.63"
rust-target: x86_64-unknown-linux-gnu
python-version: "3.11"
build-type: debug
- os: ubuntu-20.04
rust-version: beta
rust-target: x86_64-unknown-linux-gnu
python-version: "3.11"
build-type: debug
# check the build on a stock Ubuntu 20.04, including cmake 3.16 and Python 3.8
extra-name: / release valgrind
# check the build on a stock Ubuntu 20.04, including cmake 3.16
- os: ubuntu-20.04
rust-version: "1.63"
container: ubuntu:20.04
rust-target: x86_64-unknown-linux-gnu
build-type: debug
extra-name: / cmake 3.16
- os: macos-11
rust-version: stable
rust-target: x86_64-apple-darwin
python-version: "3.11"
build-type: debug
steps:
- name: install dependencies in container
Expand All @@ -78,7 +57,7 @@ jobs:
uses: actions/setup-python@v4
if: "!matrix.container"
with:
python-version: ${{ matrix.python-version }}
python-version: "3.11"

- name: setup rust
uses: actions-rs/toolchain@v1
Expand All @@ -88,12 +67,6 @@ jobs:
default: true
target: ${{ matrix.rust-target }}

- name: install python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox
echo "tox_version=$(tox --version | awk '{split($0, s," "); print s[1]}')" >> $GITHUB_ENV
- name: install valgrind
if: matrix.do-valgrind
run: |
Expand All @@ -110,12 +83,6 @@ jobs:
echo "CMAKE_C_COMPILER_LAUNCHER=sccache" >> $GITHUB_ENV
echo "CMAKE_CXX_COMPILER_LAUNCHER=sccache" >> $GITHUB_ENV
- name: cache tox environments
uses: actions/cache@v3
with:
path: .tox
key: tox-${{ env.tox_version }}-${{ matrix.os }}-${{ hashFiles('pyproject.toml', 'setup.cfg', 'tox.ini') }}

- name: unit tests
run: cargo test --lib --target ${{ matrix.rust-target }} ${{ matrix.cargo-build-flags }}

Expand All @@ -125,45 +92,29 @@ jobs:
- name: integration tests
env:
RASCALINE_TEST_WITH_STATIC_LIB: ${{ matrix.test-static-lib || 0 }}
run: cargo test --test "*" --target ${{ matrix.rust-target }} ${{ matrix.cargo-build-flags }}
run: |
cargo test --test "*" --package rascaline --target ${{ matrix.rust-target }} ${{ matrix.cargo-build-flags }}
cargo test --test "*" --package rascaline-c-api --target ${{ matrix.rust-target }} ${{ matrix.cargo-build-flags }}
# second set of jobs checking that (non-test) code still compiles/run as expected
prevent-bitrot:
runs-on: ubuntu-20.04
name: check examples / benchmarks / Python build
name: check examples / benchmarks
strategy:
matrix:
python-version: ['3.7', '3.11']
include:
- rust-version: stable
rust-target: x86_64-unknown-linux-gnu
- rust-version:
rust-target:
steps:
- uses: actions/checkout@v3

- name: set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: setup rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust-version }}
toolchain: stable
default: true
target: ${{ matrix.rust-target }}

- name: install python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox
echo "tox_version=$(tox --version | awk '{split($0, s," "); print s[1]}')" >> $GITHUB_ENV
- name: cache tox environments
uses: actions/cache@v3
with:
path: .tox
key: tox-${{ env.tox_version }}-${{ matrix.os }}-${{ hashFiles('pyproject.toml', 'setup.cfg', 'tox.ini') }}
target: x86_64-unknown-linux-gnu

- name: Setup sccache
uses: mozilla-actions/[email protected]
Expand All @@ -181,9 +132,6 @@ jobs:
- name: check that benchmarks compile and run once
run: cargo bench -- --test

- name: python build tests
run: tox -e build-python

# third set of jobs checking containing basic rust linting
lint-rust:
runs-on: ubuntu-20.04
Expand Down

0 comments on commit e310f57

Please sign in to comment.