Skip to content

Commit

Permalink
python workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
MLopez-Ibanez committed Nov 12, 2023
1 parent c0918e8 commit d98f100
Show file tree
Hide file tree
Showing 3 changed files with 219 additions and 3 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/C.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ on:
- '.github/workflows/C.yml'
- 'src/**'


jobs:
build:
if: "! contains(github.event.head_commit.message, '[skip ci]')"
Expand Down Expand Up @@ -40,6 +39,11 @@ jobs:
echo "GSL_LIBS=-L$(RUNNER_TEMP)/gsl-2.7/lib/x64" >> $GITHUB_ENV
shell: bash

- name: Add Msys64 to PATH (https://github.com/actions/runner-images/issues/1613)
if: runner.os == 'Windows'
run: echo "::add-path::/c/msys64/mingw64/bin:/c/msys64/usr/bin"
shell: bash

- run: cd src && ./configure
- run: make -C src all DEBUG=1 WARN_FLAGS='-Werror'
- run: make -C src all DEBUG=0 WARN_FLAGS='-Werror'
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/R.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ jobs:
runs-on: ${{ matrix.config.os }}
name: Check ${{ matrix.config.os }} (${{ matrix.config.r }})
strategy:
fail-fast: false
# When set to true, GitHub cancels all in-progress jobs if any matrix job fails.
fail-fast: true
matrix:
config:
- {os: windows-latest, r: 'release'}
Expand All @@ -43,6 +44,10 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- name: Disable autocrlf
if: runner.os == 'Windows'
run: git config --global core.autocrlf false

- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2
Expand Down Expand Up @@ -210,6 +215,6 @@ jobs:
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
setwd("R/")
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE, run_dont_run = TRUE)'
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE, run_dont_run = TRUE, subdir = "r")'
shell: bash {0}

207 changes: 207 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
name: Python

on:
push:
branches-ignore: [gh-pages]
paths:
- ".github/workflows/python.yml"
- "src/**"
- "python/**"
pull_request:
branches-ignore: [gh-pages]
paths:
- ".github/workflows/python.yml"
- "src/**"
- "python/**"

concurrency:
group: ${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true

jobs:
lint-black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: psf/black@stable
src: "./python"

run-tests:
timeout-minutes: 15
needs: lint-black
if: "! contains(github.event.head_commit.message, '[skip ci]')"
name: Test ${{ matrix.c.os }} (${{ matrix.c.python-version }})
runs-on: ${{ matrix.c.os }}
strategy:
# When set to true, GitHub cancels all in-progress jobs if any matrix job fails.
fail-fast: true
# The maximum number of jobs that can run simultaneously
max-parallel: 1
matrix:
c:
- {os: ubuntu-latest, python-version: '3.9'}
- {os: ubuntu-latest, python-version: '3.10'}
- {os: ubuntu-latest, python-version: '3.11'}
- {os: windows-latest, python-version: '3.11'}
- {os: macos-latest, python-version: '3.11'}

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.c.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.c.python-version }}
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- name: Run tox
run: cd python && tox

build-package:
timeout-minutes: 10
needs: run-tests
if: "! contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.10"]
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout sources
uses: actions/checkout@v4

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

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade build
- name: Build the packages
run: |
cd python
python3 -m build
- name: Publish artifacts
uses: actions/upload-artifact@v2
with:
name: distributions
path: python/dist/

build-doc:
timeout-minutes: 10
needs: build-package
if: "! contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Ensure Pip and Build
run:
pip install --upgrade pip
pip install --upgrade build

- name: build the package
run: |
cd python
python3 -m build
- name: install the package
run: |
cd python
pip install .
- name: install the doc build requirements
run: |
cd python
pip install -r requirements_dev.txt
- name: Build the docs
run: |
cd python
make -C doc clean
tox -e docs
make -C doc html
- name: Upload docs as github pages artifact
uses: actions/upload-pages-artifact@main
with:
path: python/doc/_build/html/

deploy-doc:
needs: build-doc
if: "! contains(github.event.head_commit.message, '[skip ci]')"
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
steps:
- name: Get the built docs
uses: actions/download-artifact@v3
with:
name: github-pages

- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: . # The folder the action should deploy.
target-folder: python

coverage:
timeout-minutes: 15
needs: build-doc
if: "! contains(github.event.head_commit.message, '[skip ci]')"
name: Coverage ${{ matrix.c.os }} (${{ matrix.c.python-version }})
runs-on: ${{ matrix.c.os }}
strategy:
# When set to true, GitHub cancels all in-progress jobs if any matrix job fails.
fail-fast: true
# The maximum number of jobs that can run simultaneously
max-parallel: 1
matrix:
c:
- {os: ubuntu-latest, python-version: '3.11'}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.c.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.c.python-version }}
cache: 'pip'

- name: Install dependencies
run: |
cd python
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- name: Run coverage using tox
run: |
cd python
tox -e coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true

0 comments on commit d98f100

Please sign in to comment.