From 8899b2cd44a332503310555aaa7bd38366b621d9 Mon Sep 17 00:00:00 2001 From: paugier Date: Mon, 15 Jan 2024 14:29:20 +0100 Subject: [PATCH] CI with Nox --- .github/workflows/ci-linux.yml | 34 ++++++++++++++++++++++++++ .github/workflows/ci-windows.yml | 32 ++++++++++++++++++++++++ .gitlab-ci.yml | 32 ++++++++++++------------ .hgignore | 7 +++--- CHANGES.md | 10 +++++--- README.md | 1 + docker/Dockerfile | 19 ++++++++++++--- noxfile.py | 42 ++++++++++++++++++++++++++++++++ tox.ini | 15 ------------ 9 files changed, 150 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/ci-linux.yml create mode 100644 .github/workflows/ci-windows.yml create mode 100644 noxfile.py diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml new file mode 100644 index 0000000..0d7d99c --- /dev/null +++ b/.github/workflows/ci-linux.yml @@ -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) diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml new file mode 100644 index 0000000..e31cda6 --- /dev/null +++ b/.github/workflows/ci-windows.yml @@ -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 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6f4e6a4..bf30e2a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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: [ "" ] @@ -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 @@ -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 diff --git a/.hgignore b/.hgignore index 34f815b..e777213 100644 --- a/.hgignore +++ b/.hgignore @@ -12,11 +12,12 @@ doc/**.zip *.so -build/* +build dist/*.tar.gz dist* -.tox/* -.coverage/* +.tox +.coverage +.nox **/tmp*.py diff --git a/CHANGES.md b/CHANGES.md index f88e931..592dc1b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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) diff --git a/README.md b/README.md index 200d1c0..706bd6a 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/docker/Dockerfile b/docker/Dockerfile index c15657a..d74c45b 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.10-bullseye +FROM python:3.10 LABEL Pierre Augier COPY docker/hgrc $HOME/.hgrc @@ -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 diff --git a/noxfile.py b/noxfile.py new file mode 100644 index 0000000..28bb426 --- /dev/null +++ b/noxfile.py @@ -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) diff --git a/tox.ini b/tox.ini index a77d900..09a267c 100644 --- a/tox.ini +++ b/tox.ini @@ -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}