Skip to content

Commit

Permalink
CI with Nox
Browse files Browse the repository at this point in the history
  • Loading branch information
paugier committed Jan 15, 2024
1 parent 35bb54f commit 8899b2c
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 42 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI Linux

on:
- push
- pull_request

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- name: apt install
run: |
sudo apt install -y libopenmpi-dev
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pdm nox
- name: Test with nox
run: |
nox -s test_without_pythran test_with_pythran
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false # optional (default = false)
verbose: true # optional (default = false)
32 changes: 32 additions & 0 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI-windows

on:
- push
- pull_request

jobs:
tests:
runs-on: windows-2022
defaults:
run:
shell: bash -l {0}
strategy:
matrix:
python-version: ["3.11"]

steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
with:
environment-file: .github/environment-windows.yml
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: test
use-mamba: true
- name: Install
run: |
python -m pip install --upgrade pip
pip install pdm nox
- name: Tests
run: |
nox -s test_without_pythran test_with_pythran
32 changes: 15 additions & 17 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,23 @@ stages:
- release

variables:
CODECOV_TOKEN: b1c3afe7-4ef3-4c69-9656-78beec52ec16
OMPI_ALLOW_RUN_AS_ROOT: "1"
OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: "1"
PDM_CACHE_DIR: ${CI_PROJECT_DIR}/.pdm-cache

image: registry.heptapod.net:443/fluiddyn/transonic/ci/default:stable

before_script:
- export PATH=/root/.local/bin:$PATH
- pip install -U pdm tox tox-pdm --user
- python -m pip install -U pdm nox --user

# Build an image for the above tasks; this should be a scheduled job, as
# it is quite unnecessary to run on every invocation.
CI image:
image:build:
stage: image
tags:
- container-registry-push
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
- if: '$CI_BUILD_IMAGES == "1"'
# rules:
# - if: '$CI_PIPELINE_SOURCE == "schedule"'
# - if: '$CI_BUILD_IMAGES == "1"'
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [ "" ]
Expand All @@ -49,12 +46,13 @@ CI image:
--dockerfile $CI_PROJECT_DIR/docker/Dockerfile
--single-snapshot
--cleanup
--destination registry.heptapod.net:443/fluiddyn/transonic/ci/$CI_COMMIT_HG_BRANCH:stable
--destination registry.heptapod.net:443/fluiddyn/transonic/ci/default:stable
# --destination registry.heptapod.net:443/fluiddyn/transonic/ci/$CI_COMMIT_HG_BRANCH:stable
validate_code:
stage: lint
needs:
- job: "CI image"
- job: "image:build"
optional: true
script:
- pdm install -G dev
Expand All @@ -63,31 +61,31 @@ validate_code:
step_without_pythran:
stage: test
needs:
- job: "CI image"
- job: "image:build"
optional: true
script:
- tox -e py310,codecov
- nox -s test_without_pythran

step_pythran_then_cython:
stage: test
needs:
- job: "CI image"
- job: "image:build"
optional: true
script:
- tox -e py310-pythran,py310-cython,codecov
- nox -s test_with_pythran test_with_cython

step_pythran_cython:
stage: test
needs:
- job: "CI image"
- job: "image:build"
optional: true
script:
- tox -e py310-pythran-cython
- nox -s test_with_pythran_cython

pages:
stage: publish
needs:
- job: "CI image"
- job: "image:build"
optional: true
script:
- pdm install -G doc
Expand Down
7 changes: 4 additions & 3 deletions .hgignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ doc/**.zip

*.so

build/*
build
dist/*.tar.gz
dist*
.tox/*
.coverage/*
.tox
.coverage
.nox

**/tmp*.py

Expand Down
10 changes: 6 additions & 4 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Release notes

## Future

See the [ROADMAP.md file](https://transonic.readthedocs.io/en/latest/roadmap.html).

% Unreleased_
% -----------

## [0.6.0] (unpublished)

- Support for [Meson build](https://transonic.readthedocs.io/en/latest/packaging.html)
through `transonic --meson`
- Support for Python 3.12

## [0.5.3] (2023-08-21)

- [!110](https://foss.heptapod.net/fluiddyn/transonic/-/merge_requests/110)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[![Documentation status](https://readthedocs.org/projects/transonic/badge/?version=latest)](http://transonic.readthedocs.org)
![Supported Python versions](https://img.shields.io/pypi/pyversions/transonic.svg)
[![Heptapod CI](https://foss.heptapod.net/fluiddyn/transonic/badges/branch/default/pipeline.svg)](https://foss.heptapod.net/fluiddyn/transonic/-/pipelines)
[![Github Actions](https://github.com/fluiddyn/transonic/actions/workflows/ci.yml/badge.svg?branch=branch/default)](https://github.com/fluiddyn/transonic/actions)
[![mybinder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/fluiddyn/transonic/branch/default?urlpath=lab/tree/doc/ipynb/executed)
[![sonarcloud](https://sonarcloud.io/api/project_badges/measure?project=fluiddyn_transonic&metric=alert_status)](https://sonarcloud.io/dashboard?id=fluiddyn_transonic)

Expand Down
19 changes: 16 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.10-bullseye
FROM python:3.10
LABEL Pierre Augier <[email protected]>

COPY docker/hgrc $HOME/.hgrc
Expand All @@ -12,10 +12,23 @@ RUN apt-get install -y --no-install-recommends rsync libgl1 xvfb xauth libgl1-me

RUN rm -rf /var/lib/apt/lists/*

RUN groupadd -g 1000 appuser && useradd -m -r -u 1000 -g appuser -s /bin/bash appuser -s /bin/bash && usermod -a -G sudo appuser
RUN echo appuser:appuser | chpasswd
USER appuser
ARG HOME=/home/appuser
RUN mkdir -p $HOME/opt
WORKDIR $HOME/opt
RUN echo $USER $HOME $PWD && whoami

ENV PIP_BREAK_SYSTEM_PACKAGES=1

RUN $(hg debuginstall -T '{pythonexe}') -m pip install hg-evolve hg-git --no-cache-dir --user

COPY --chown=appuser:appuser docker/hgrc $HOME/.hgrc

RUN mkdir -p $HOME/.config/matplotlib
RUN echo 'backend : agg' > $HOME/.config/matplotlib/matplotlibrc

RUN /usr/bin/python3 -m pip install hg-git hg-evolve
RUN git config --global pull.rebase false

RUN /usr/bin/python3 -m pip install pdm
RUN python -m pip install pdm nox
42 changes: 42 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import os

import nox

os.environ.update({"PDM_IGNORE_SAVED_PYTHON": "1"})


def _test(session):
session.run("make", "tests_ipynb", external=True)
session.run("make", "tests_coverage", external=True)


def _install_base(session):
command = "pdm install -G base_test"
session.run_always(*command.split(), external=True)


@nox.session
def test_without_pythran(session):
_install_base(session)
_test(session)


@nox.session
def test_with_pythran(session):
_install_base(session)
session.install("pythran")
_test(session)


@nox.session
def test_with_cython(session):
_install_base(session)
session.install("cython")
_test(session)


@nox.session
def test_with_pythran_cython(session):
_install_base(session)
session.install("pythran", "cython")
_test(session)
15 changes: 0 additions & 15 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,3 @@ commands =
pip install -e _transonic_testing/.
make tests_ipynb
make tests_coverage

[testenv:codecov]
passenv = CODECOV_TOKEN
setenv =
CI_COMMIT_BRANCH = {env:CI_COMMIT_BRANCH:env:CI_COMMIT_HG_BRANCH}
sitepackages = True
deps =
codecov
coverage[toml]
allowlist_externals = make
skip_install = true
commands =
make report_coverage
codecov --file .coverage/coverage.xml --commit {env:CI_COMMIT_SHA} \
--branch {env:CI_COMMIT_BRANCH} --name Heptapod{env:CI_JOB_ID}

0 comments on commit 8899b2c

Please sign in to comment.