Skip to content

Commit

Permalink
Update github actions
Browse files Browse the repository at this point in the history
.github: separate building docs;
.github: add linting;
.github: add autotagging;
.github: add pypi release;
.github: add testing of dist.
  • Loading branch information
tfiedor committed Nov 3, 2023
1 parent 5ca7be7 commit 7d4a031
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 15 deletions.
99 changes: 99 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Release

on:
pull_requests:
types:
- closed
branches:
- devel

jobs:
release:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout latest version
uses: actions/checkout@v3
with:
ref: devel

- name: Tag the new version
uses: phish108/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
release-branch: devel
bump: minor

build-and-deploy-doc:
needs: release
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
step:
- name: Checkout latest version
uses: actions/checkout@v3
with:
ref: devel

- name: Setup Python, Ubuntu and Python environment
uses: ./.github/workflows/actions/setup
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Compile the documentation
run: |
make -C doc html
- name: Deploy to GH pages
uses: JamesIves/github-pages-deploy-action@v4
with:
# TODO: CHECK THIS IS CORRECT PATH
folder: doc/_build/html

build-and-deploy-to-pypi:
needs: release
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]

steps:
- name: Checkout latest version
uses: actions/checkout@v3
with:
ref: devel

- name: Setup Python, Ubuntu and Python environment
uses: ./.github/workflows/actions/setup
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Ensure that dependencies are installed
run: |
# Install and upgrade pip
python3 -m pip install --upgrade pip
# Install dependencies for build and deplo
python3 -m pip install setuptools wheel twine
- name: Build python release distrubution package
run: |
pip3 install -q build
make pypi-release
- name: Upload to TestPypi
run: |
python3 -m twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TESTPYPI_SECRET_TOKEN }}
TWINE_REPOSITORY: testpypi

- name: Upload to Pypi
run: |
python3 -m twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TESTPYPI_SECRET_TOKEN }}
67 changes: 67 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- devel

jobs:
# Tests classic build using Tox for selected Python versions
build:
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -37,6 +38,52 @@ jobs:
flags: coverage-${{ matrix.python-version }}
verbose: true

# Tests that perun is buildable from distribution packages (this is precursor for pypi install).
# We limit the test to version 3.11 in order to have less clutter in Actions
build-from-dist:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
steps:
- uses: actions/checkout@v3

- name: Setup Python, Ubuntu and Python environment
uses: ./.github/workflows/actions/setup
with:
python-version: ${{ matrix.python-version }}

- name: Create tarball or wheel
run: |
pip3 install -q build
make pypi-release
- name: Install from dist
run: |
pip3 install dist/*
# Tests that documentation is buildable. We limit the test to version 3.11 in order to have less clutter in Actions
build-docs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11"]

steps:
- uses: actions/checkout@v3

- name: Setup Python, Ubuntu and Python environment
uses: ./.github/workflows/actions/setup
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Generate docs for Python ${{ matrix.python-version }} using Tox
run: |
tox -e docs
# Tests correctes of typing for all versions
typing:
runs-on: ubuntu-latest
strategy:
Expand All @@ -55,3 +102,23 @@ jobs:
- name: Check type correctness for Python ${{ matrix.python-version }} using Tox
run: |
tox -e typing
# Test linting only for the latest version of python
linting:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]

steps:
- uses: actions/checkout@v3

- name: Setup Python, Ubuntu and Python environment
uses: ./.github/workflows/actions/setup
with:
python-version: ${{ matrix.python-version }}

- name: Check type correctness for Python ${{ matrix.python-version }} using Tox
run: |
tox -e lint
17 changes: 2 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,7 @@ docs-all:
docs-release: docs-latex docs
cp ./docs/_build/latex/Perun.pdf ./docs/pdf/perun.pdf

# Releases the latest documentation to the gh-pages
# Warn: This should only be executed in isolate clone of the Perun!
gh-pages:
git checkout master
git pull
git checkout gh-pages
rm -rf build _sources _static
git checkout master docs figs examples Makefile CHANGELOG.rst
git reset HEAD
cp CHANGELOG.rst docs/changelog.rst
make docs
mv -fv docs/_build/html/* ./
rm -rf docs examples figs CHANGELOG.rst
git add -A
git commit -m "Generated gh-pages for version `git describe --tags `git rev-list --tags --max-count=1``"
pypi-release:
python3 -m build

.PHONY: init test docs install dev run-gui gh-pages docs-latex docs-release docs-all

0 comments on commit 7d4a031

Please sign in to comment.