Skip to content

Commit

Permalink
Switch to GitHub Actions CI pipeline
Browse files Browse the repository at this point in the history
This removes the no longer freely available Travis CI pipeline.

It also switches from coveralls to codecov.
  • Loading branch information
jgosmann committed Aug 7, 2023
1 parent a14e84c commit 0511eff
Show file tree
Hide file tree
Showing 6 changed files with 238 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[report]
omit =
*/python?.?/site-packages/*
goppy/test/*
exclude_lines =
raise NotImplementedError()
14 changes: 14 additions & 0 deletions .github/actions/setup-project/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Setup project
description: Setup project with poetry
runs:
using: composite
steps:
- name: Install poetry
run: pip install poetry
shell: bash

- name: Install dependencies
run: poetry install
shell: bash
env:
POETRY_VIRTUALENVS_IN_PROJECT: true
122 changes: 122 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: CI and release pipeline

on:
pull_request:
push:
branches: ["main", "develop"]
tags: ["*"]

jobs:
static-analysis:
runs-on: ubuntu-latest
strategy:
matrix:
check:
- name: Check code-formatting
run: poetry run black --check .
- name: Check import sorting
run: poetry run isort --check-only .
#- name: pylint
# run: poetry run pylint goppy
steps:
- uses: actions/checkout@v3
- run: git fetch --no-tags --prune --depth=1 origin +refs/heads/main:refs/remotes/origin/main

- name: Set up Python
uses: actions/[email protected]
with:
python-version: '3.11'

- uses: actions/[email protected]
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
- uses: actions/[email protected]
with:
path: .venv
key: ${{ runner.os }}-py3.11-venv-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-py3.11-venv-
- uses: ./.github/actions/setup-project

- name: ${{ matrix.check.name }}
run: ${{ matrix.check.run }}

test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}

- uses: actions/[email protected]
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
- uses: actions/[email protected]
with:
path: .venv
key: ${{ runner.os }}-py${{ matrix.python-version }}-venv-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-py${{ matrix.python-version }}-venv-
- uses: ./.github/actions/setup-project

- name: Test and measure coverage with pytest
run: poetry run pytest --verbose --cov=goppy --cov-report=xml
- uses: codecov/codecov-action@v3

release:
runs-on: ubuntu-latest
needs: [static-analysis, test]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/[email protected]
with:
python-version: '3.11'

- uses: actions/[email protected]
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
- uses: actions/[email protected]
with:
path: .venv
key: ${{ runner.os }}-py3.11-venv-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-py3.11-venv-
- uses: ./.github/actions/setup-project

- name: Publish to PyPI
run: poetry publish --build
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}

- name: Set version
id: version
run: echo "version=${GITHUB_REF#refs/*/v}" >> $GITHUB_OUTPUT

- name: Extract changelog
id: changelog
run: sed -E -n '/^\[${{ steps.version.outputs.version }}\]/,/^\[[0-9\.]+\]/{/^\[[0-9\.]+\]|^-+$/!p;}' CHANGELOG.rst > release-body.rst

- uses: docker://pandoc/core:2.10
with:
args: --standalone --wrap none -f rst -t gfm --output=release-body.md release-body.rst

- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
body_path: release-body.md
tag_name: v${{ steps.version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11 changes: 6 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.. image:: https://travis-ci.org/jgosmann/goppy.svg?branch=master
:target: https://travis-ci.org/jgosmann/goppy
.. image:: https://coveralls.io/repos/jgosmann/goppy/badge.png?branch=master
:target: https://coveralls.io/r/jgosmann/goppy?branch=master
.. image:: https://github.com/jgosmann/goppy/actions/workflows/ci.yml/badge.svg
:target: https://github.com/jgosmann/goppy/actions/workflows/ci.yml
:alt: CI and release pipeline
.. image:: https://codecov.io/gh/jgosmann/goppy/branch/main/graph/badge.svg?token=mkgZs4nds5
:target: https://codecov.io/gh/jgosmann/goppy

Overview
--------
Expand All @@ -18,7 +19,7 @@ The feature list:
* Prediction of first order derivatives.
* Estimation of the log likelihood and its derivative.
* Well documented.
* `Good test coverage. <https://coveralls.io/r/jgosmann/goppy>`_
* `Good test coverage. <https://app.codecov.io/gh/jgosmann/goppy>`_
* Supports Python 2.6, 2.7, 3.3, 3.4, and 3.5. Later versions are likely to work as
well.
* MIT license.
Expand Down
95 changes: 94 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ black = "^23.7.0"
isort = "^5.12.0"
numpydoc = "^1.5.0"
pytest = "^7.4.0"
pytest-cov = "^4.1.0"
sphinx = "^7.1.2"

[build-system]
Expand Down

0 comments on commit 0511eff

Please sign in to comment.