Skip to content

Commit

Permalink
Add CI pipeline file
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi committed Sep 6, 2024
1 parent ecc13ef commit ba7888a
Show file tree
Hide file tree
Showing 2 changed files with 192 additions and 0 deletions.
192 changes: 192 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
name: Github Action

on:
push:
branches: [main, develop]
paths-ignore: # prevents workflow execution when only these types of files are modified
- "**.md" # wildcards prevent file in any repo dir from trigering workflow
- "**.bib"
- "**.ya?ml" # captures both .yml and .yaml
- "LICENSE"
- ".gitignore"
pull_request:
branches: [main, develop]
types: [opened, reopened] # excludes syncronize to avoid redundant trigger from commits on PRs
paths-ignore:
- "**.md"
- "**.bib"
- "**.ya?ml"
- "LICENSE"
- ".gitignore"
workflow_dispatch: # also allow manual trigger, for testing purposes

jobs:
clean:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Black formatting
uses: lgeiger/[email protected]
with:
args: "./"

- name: Run isort
uses: jamescurtin/isort-action@master
with:
configuration: --profile black

- name: Check for modified files
id: git-check
run: echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)

- name: Push changes
if: steps.git-check.outputs.modified == 'true'
run: |
git checkout $GITHUB_HEAD_REF
git commit -am "Black reformating"
git push
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-13, ubuntu-20.04, macos-latest, windows-2019 ]
py-version: [ "3.9", "3.10", "3.11", "3.12" ]

steps:
- uses: actions/checkout@v4

# general Python setup
- name: Set up Python ${{ matrix.py-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.py-version }}

- name: Update pip & install testing pkgs
run: |
python -VV
python -m pip install --upgrade pip setuptools wheel
# install testing
- name: Install package and test deps
run: |
pip install .[testing] # install the package and the testing deps
- name: Test with pytest
run: |
pytest
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4

Pypi:
runs-on: ubuntu-latest
needs: build

strategy:
fail-fast: false
matrix:
os: [ "ubuntu-latest" ]
python-version: ["3.11" ]

steps:
- uses: actions/checkout@v2

- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
- name: Publish distribution 📦 to PyPI if Release
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
skip-existing: true

- name: Publish distribution 📦 to Test PyPI if Push
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
skip-existing: true

conda:
name: (${{ matrix.python-version }}, ubuntu-latest)
runs-on: ubuntu-latest
needs: build

strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.11"]
steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
channels: conda-forge,cmutel,konstantinstadler,haasad,pascallesage,romainsacchi
allow-softlinks: true
channel-priority: strict
auto-update-conda: true
activate-environment: test

- name: Conda info
shell: bash -l {0}
run: conda info

- name: Publish distribution 📦 to Anaconda if Push and if master branch
if: startsWith(github.ref, 'refs/heads/master')
shell: bash -l {0}

run: |
PKG_NAME=dopo
USER=romainsacchi
conda install anaconda-client
conda install conda-build
mkdir ~/conda-bld
conda config --set anaconda_upload no
export CONDA_BLD_PATH=~/conda-bld
export VERSION=`date +%Y.%m.%d`
conda build "conda/" --old-build-string
ls $CONDA_BLD_PATH/noarch/
anaconda -t ${{ secrets.ANACONDA_CLOUD }} upload -u $USER $CONDA_BLD_PATH/noarch/$PKG_NAME-$VERSION-py_0.tar.bz2 --force
testconda:
name: (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: conda

strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.11",]
solver: ["classic"]
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
channels: conda-forge,romainsacchi
allow-softlinks: true
auto-update-conda: true
activate-environment: test
conda-solver: ${{ matrix.solver }}

- name: Pull distribution 📦 from Anaconda and test it if master branch

run: |
conda install romainsacchi::dopo
Binary file removed examples/~$0509_v1.xlsx
Binary file not shown.

0 comments on commit ba7888a

Please sign in to comment.