Skip to content

Commit

Permalink
Run tests for all Python versions in a single nox session
Browse files Browse the repository at this point in the history
Internal-tag: [#53659]
Signed-off-by: Robert Szczepanski <[email protected]>
  • Loading branch information
robertszczepanski committed Feb 26, 2024
1 parent fb2be84 commit 8a5da79
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 86 deletions.
92 changes: 44 additions & 48 deletions .ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,78 +9,74 @@ stages:

lint:
stage: test
image: ubuntu:latest
image: debian:bookworm
before_script:
- apt-get update -qq
- apt-get install -y --no-install-recommends python3-pip python3-venv
- apt-get install -y --no-install-recommends
python3-pip
python3-venv
- python3 -m venv venv
- source venv/bin/activate
- python3 -m pip install -U pip wheel setuptools
script:
- python3 -m pip install -r requirements.txt
- nox -s isort_check black_check flake8

.run_tests:
stage: test
image: ubuntu:latest
.generate_example:
stage: examples
image: debian:bookworm
variables:
GIT_SUBMODULE_STRATEGY: normal
DEBIAN_FRONTEND: noninteractive
PYTHON_VERSION: "3.12"
before_script:
- apt-get update -qq
- apt-get install -y --no-install-recommends
python3-venv
python3-pip
- source .github/scripts/setup_env.sh $PYTHON_VERSION
- install_deps
- configure_python_env
- activate_python_env
- python3 -m venv venv
- source venv/bin/activate
- python3 -m pip install git+https://github.com/antmicro/tuttest
- tuttest README.md | bash -
script:
- nox -s tests_with_report
artifacts:
paths:
- cov_html
- cd examples/$EXAMPLE
- tuttest README.md generate | bash -

.generate_example:
stage: examples
image: ubuntu:latest
run_tests:
stage: test
image: debian:bookworm
variables:
GIT_SUBMODULE_STRATEGY: normal
DEBIAN_FRONTEND: noninteractive
PYTHON_VERSION: "3.12"
before_script:
- source .github/scripts/setup_env.sh $PYTHON_VERSION
- install_deps
- configure_python_env
- activate_python_env
- apt-get update -qq
- apt-get install -y --no-install-recommends
curl
wget
git
python3-dev
python3-venv
python3-pip
make
ninja-build
gcc-riscv64-unknown-elf
bsdextrautils
verilator
libssl-dev
libreadline-dev
libffi-dev
libbz2-dev
libncurses-dev
libsqlite3-dev
liblzma-dev
- python3 -m venv venv
- source venv/bin/activate
- python3 -m pip install nox
- python3 -m pip install git+https://github.com/antmicro/tuttest
- tuttest README.md | bash -
script:
- cd examples/$EXAMPLE
- tuttest README.md generate | bash -

tests_py38:
extends: .run_tests
variables:
PYTHON_VERSION: "3.8"

tests_py39:
extends: .run_tests
variables:
PYTHON_VERSION: "3.9"

tests_py310:
extends: .run_tests
variables:
PYTHON_VERSION: "3.10"

tests_py311:
extends: .run_tests
variables:
PYTHON_VERSION: "3.11"

tests_py312:
extends: .run_tests
variables:
PYTHON_VERSION: "3.12"
- nox -s test_all_in_env

generate_hdmi:
extends: .generate_example
Expand All @@ -98,7 +94,7 @@ generate_pwm:
EXAMPLE: pwm

include:
- project: 'repositories/fpga-topwrap'
- project: 'repositories/topwrap'
ref: internal_ci_yaml
file: '/internal.yml'

Expand Down
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ exclude =
__pycache__,
docs/source/conf.py,
venv,
build,
builds,
kenning-pipeline-manager,
miniconda3,
Expand Down
102 changes: 68 additions & 34 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,72 +5,104 @@ name: Pipeline

on: [pull_request, push, workflow_dispatch]

defaults:
run:
shell: bash

jobs:
Lint:
runs-on: ubuntu-latest
name: "Run Lint checks on Python sources"
container:
image: debian:bookworm
name: "Run lint checks"

env:
DEBIAN_FRONTEND: noninteractive

steps:
- name: Install system packages
run: |
apt-get update -qq
apt-get install -y --no-install-recommends \
git \
python3-pip \
python3-venv
- uses: actions/checkout@v3
with:
submodules: true

- name: Install dev requirements
- name: Install Python dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends python3-pip python3-venv
python3 -m venv venv
source venv/bin/activate
python3 -m pip install -U pip wheel setuptools
python3 -m pip install -r requirements.txt
- name: Run lint checks
run: |
python3 -m pip install -r requirements.txt
source venv/bin/activate
nox -s isort_check black_check flake8
Tests:
runs-on: ubuntu-latest
name: "Test Python ${{ matrix.python-version }}"

strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
container:
image: debian:bookworm
name: "Run tests"

env:
DEBIAN_FRONTEND: noninteractive

steps:
- name: Install system packages
run: |
apt-get update -qq
apt-get install -y --no-install-recommends \
curl \
wget \
git \
python3-dev \
python3-venv \
python3-pip \
make \
ninja-build \
gcc-riscv64-unknown-elf \
bsdextrautils \
verilator \
libssl-dev \
libreadline-dev \
libffi-dev \
libbz2-dev \
libncurses-dev \
libsqlite3-dev \
liblzma-dev
- uses: actions/checkout@v3
with:
submodules: true

- name: Install dev requirements
- name: Install Python dependencies
run: |
source .github/scripts/setup_env.sh ${{ matrix.python-version }}
install_deps
configure_python_env
activate_python_env
python3 -m venv venv
source venv/bin/activate
python3 -m pip install nox
python3 -m pip install git+https://github.com/antmicro/tuttest
- name: Build
run: |
source .github/scripts/setup_env.sh ${{ matrix.python-version }}
activate_python_env
source venv/bin/activate
tuttest README.md | bash -
- name: Run pytest with nox
run: |
source .github/scripts/setup_env.sh ${{ matrix.python-version }}
activate_python_env
nox -s tests
source venv/bin/activate
nox -s test_all_in_env
Examples:
runs-on: ubuntu-latest
name: 'Example ${{ matrix.example }}'
container:
image: debian:bookworm
name: 'Generate example ${{ matrix.example }}'

strategy:
fail-fast: false
Expand All @@ -80,29 +112,31 @@ jobs:
- inout
- pwm

env:
PYTHON_VERSION: "3.12"

steps:
- name: Install system packages
run: |
apt-get update -qq
apt-get install -y --no-install-recommends \
git \
python3-dev \
python3-venv \
python3-pip
- uses: actions/checkout@v3

- name: Install dev requirements
- name: Install Python dependencies
run: |
source .github/scripts/setup_env.sh $PYTHON_VERSION
install_deps
configure_python_env
activate_python_env
python3 -m venv venv
source venv/bin/activate
python3 -m pip install git+https://github.com/antmicro/tuttest
- name: Install fpga-topwrap
run: |
source .github/scripts/setup_env.sh $PYTHON_VERSION
activate_python_env
source venv/bin/activate
tuttest README.md | bash -
- name: Generate sources for example ${{ matrix.example }} setup
run: |
source .github/scripts/setup_env.sh $PYTHON_VERSION
activate_python_env
source venv/bin/activate
cd examples/${{ matrix.example }}
tuttest README.md generate | bash -
Loading

0 comments on commit 8a5da79

Please sign in to comment.