Skip to content

Commit

Permalink
More nox + release in CI + Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
paugier committed Jan 20, 2024
1 parent f069232 commit c519893
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 6 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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 openfoam
- 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
run: |
nox -s test
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false # optional (default = false)
verbose: true # optional (default = false)
files: coverage.xml
45 changes: 40 additions & 5 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ variables:
WM_PROJECT_DIR: "/usr/share/openfoam"
OMPI_ALLOW_RUN_AS_ROOT: "1"
OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: "1"
PDM_CACHE_DIR: ${CI_PROJECT_DIR}/.pdm-cache

stages:
- image
- test
- publish
- build
- release

cache:
# Required to keep artifacts from old builds, e.g. from default
paths:
- public

before_script:
- pdm install


# Build an image for the above tasks; this should be a scheduled job, as
# it is quite unnecessary to run on every invocation.
Expand All @@ -32,8 +32,6 @@ CI image:
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [ "" ]
before_script:
- ""
script:
- |
cat > /kaniko/.docker/config.json <<EOF
Expand All @@ -57,6 +55,7 @@ CI image:
pytest:
stage: test
script:
- pdm sync --clean -G test -G pyvista
- pdm run pytest tests doc/examples --cov --cov-report term --cov-report xml
coverage: /(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/
artifacts:
Expand All @@ -69,6 +68,7 @@ pytest:
pages:
stage: publish
script:
- pdm sync --clean -G pyvista -G doc
- pdm run xvfb-run --auto-servernum sphinx-build -W -b html -d doc/_build/doctrees doc doc/_build/html
- mkdir -p public/$CI_COMMIT_REF_NAME
- rsync -rvc --delete doc/_build/html/* public/$CI_COMMIT_REF_NAME/
Expand All @@ -85,3 +85,38 @@ pages:
- public
expire_in: 5 days
when: always


build:package:
stage: build
before_script:
- pdm config cache_dir ${PDM_CACHE_DIR}
script:
- pdm build || pdm lock --group :all --refresh
needs: []
artifacts:
when: always
paths:
- pdm.lock
- dist
expire_in: 24 hrs
cache:
when: always
key: pdmcache-$CI_COMMIT_BRANCH
paths:
- ${PDM_CACHE_DIR}


# manually set PDM_PUBLISH_PASSWORD in web interface to your pypi API token
release:package:
stage: release
rules:
- if: '$CI_MERGE_REQUEST_ID'
when: never
- if: '$CI_COMMIT_TAG'
when: on_success
variables:
PDM_PUBLISH_USERNAME: __token__
script:
- pdm publish --no-build
needs: [ "build:package" ]
13 changes: 12 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,20 @@
nox.options.reuse_existing_virtualenvs = 1


@nox.session
def test(session):
session.run_always(
"pdm", "sync", "-G", "test", "-G", "pyvista", "--clean", external=True
)
command = (
"pdm run pytest tests doc/examples --cov --cov-report term --cov-report xml"
)
session.run(*command.split(), external=True)


@nox.session
def doc(session):
session.run_always("pdm", "sync", "-G", "doc", external=True)
session.run_always("pdm", "sync", "-G", "doc", "--clean", external=True)
session.chdir("doc")
session.run("make", "cleanall", external=True)
session.run("make", external=True)

0 comments on commit c519893

Please sign in to comment.