Skip to content

Commit

Permalink
Upgrade GitHub Actions and software
Browse files Browse the repository at this point in the history
Use latest GitHub actions:
---
- https://github.com/marketplace/actions/checkout
- https://github.com/marketplace/actions/setup-python
- https://github.com/marketplace/actions/setup-graphviz
- ...

Upgrade tests to Python 3.12
No compatibility issues found.
See also https://docs.python.org/3/whatsnew/changelog.html#python-3-12-0-beta-1

Use `build` instead of `setup.py`:
https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html

Update Author e-mail to `author_email: [email protected]`

Simplify the installation on Windows:
---
Install graphviz using:

`choco install graphviz --version=12.2.1`

Update `environment.yml`

Add GitHub Action PostgreSQL to **PATH**
https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-environment-variable

Solves #48
  • Loading branch information
VaeterchenFrost committed Dec 18, 2024
1 parent d57db2c commit dd7f80b
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 131 deletions.
2 changes: 1 addition & 1 deletion .github/gh-disabled-workflows/python-publish-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/directory_writer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.12

- name: Write DIRECTORY.md
run: |
Expand All @@ -27,7 +27,7 @@ jobs:
uses: EndBug/add-and-commit@v4
with:
author_name: Martin Röbke
author_email: martin.roebke@tu-dresden.de
author_email: martin.roebke@web.de
message: "Automatic Update: DIRECTORY.md"
add: "DIRECTORY.md"
env:
Expand Down
234 changes: 127 additions & 107 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,93 @@ name: Tests

on:
push:
branches: [ master ]
branches: [master]
paths-ignore:
- 'doc/**'
- 'gh-disabled-workflows/**'
- '*.md'
- "doc/**"
- "gh-disabled-workflows/**"
- "*.md"
pull_request:
branches: [ master ]
branches: [master]
paths-ignore:
- 'doc/**'
- 'gh-disabled-workflows/**'
- '*.md'
- "doc/**"
- "gh-disabled-workflows/**"
- "*.md"

env:
graphviz-version: "12.2.1"
pg-version: "16"

jobs:
linux_and_coverage:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.12"]

steps:
- uses: actions/checkout@v4

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install Workflow dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install flake8 flake8-import-order pytest coverage
- name: Install project dependencies
run: |
pip install .[test]
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: graphviz for visualization test
run: |
sudo apt-get update && sudo apt-get install -yq graphviz
- name: Test with coverage & pytest
run: |
coverage run --source=tdvisu -m pytest .
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: unittests

- uses: actions/checkout@v4

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

- name: Get Graphviz
working-directory: ..
run: |
wget -nv "https://gitlab.com/api/v4/projects/4207231/packages/generic/graphviz-releases/${{ env.graphviz-version }}/graphviz-${{ env.graphviz-version }}.tar.gz"
graphviz_12_sha256="242bc18942eebda6db4039f108f387ec97856fc91ba47f21e89341c34b554df8 graphviz-${{ env.graphviz-version }}.tar.gz"
if [[ "$(sha256sum graphviz-${{ env.graphviz-version }}.tar.gz)" != "$graphviz_12_sha256" ]]; then
echo "The file is corrupted, calculated_hash: $calculated_hash"
exit 1
fi
# extract
tar -xzf graphviz-${{ env.graphviz-version }}.tar.gz
# dev dependencies
sudo apt-get install -y build-essential pkg-config libgraphviz-dev libperl-dev libsodium-dev libargon2-dev libgts-dev
- name: Install Graphviz
working-directory: ..
run: |
cd graphviz-${{ env.graphviz-version }}
./configure --prefix=$PWD/out --with-gts
make --quiet
make install --quiet
echo "$PWD/out/bin" >> "$GITHUB_PATH"
echo "LD_LIBRARY_PATH=$PWD/out/lib" >> "$GITHUB_ENV"
- name: Install Workflow dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install flake8 flake8-import-order pytest coverage
- name: Install project dependencies
run: |
pip install .[test]
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with coverage & pytest
run: |
dot -V
which coverage
which dot
which pytest
coverage run --source=tdvisu -m pytest .
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: unittests

other_os_tests:
strategy:
Expand All @@ -73,61 +102,52 @@ jobs:
continue-on-error: true

steps:
- uses: actions/checkout@v4

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install Workflow dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
- name: Install graphviz for visualization test
if: ${{ runner.os == 'macOS' }}
uses: ts-graphviz/setup-graphviz@v2
with:
macos-skip-brew-update: 'true' # default false

- name: Setup Conda
if: ${{ runner.os == 'Windows' }}
uses: s-weigand/setup-conda@v1
with:
# Whether to activate the conda base env (Default: 'true')
activate-conda: true
# Python version which should be installed with conda (default: 'Default')
python-version: 3.8

- name: Install graphviz via conda
if: ${{ runner.os == 'Windows' }}
run: |
conda install -c anaconda graphviz
- name: add graphviz PATH
if: ${{ runner.os == 'Windows' }}
run: |
# should give base conda python
$python=Get-Command python
$pypath=Split-Path $python.Source -Parent
# Add to PATH, we know pypath is on it
$dot=[IO.Path]::Combine($pypath, 'Library', 'bin', 'graphviz')
echo $dot | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
shell: powershell

- name: register plugins for graphviz
if: ${{ runner.os == 'Windows' }}
run: |
# execute dot
dot -V
dot -c
- name: Install project dependencies
run: |
pip install .[test]
- name: Test with pytest
run: |
# Tests reside in folder 'test'
pytest ./test
- uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install workflow dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
- name: Brew install PostgreSQL ${{ env.pg-version }}
if: runner.os == 'MacOS'
run: |
brew install libpq postgresql@${{ env.pg-version }}
# make available on PATH
pgpath="/opt/homebrew/opt/postgresql@${{ env.pg-version }}/bin"
echo $pgpath >> "$GITHUB_PATH"
ls "$pgpath"
$pgpath/pg_config --version
- name: Add PostgreSQL to PATH
if: runner.os == 'Windows'
shell: pwsh
run: |
echo "$env:PGBIN" >> "$env:GITHUB_PATH"
pg_config --version
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v2
with:
macos-skip-brew-update: "true" # default false
windows-graphviz-version: ${{ env.graphviz-version }}

- name: Register plugins for Graphviz
if: runner.os == 'Windows'
run: |
dot -V
dot -c
- name: Install project dependencies
run: |
pip install .[test]
- name: Test with pytest
run: |
# Tests reside in folder 'test'
pytest ./test
33 changes: 16 additions & 17 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,22 @@ on:

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install 'build[virtualenv]'
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python -m build
twine upload dist/*
2 changes: 0 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: tdvisu
channels:
- alubbock
- defaults
dependencies:
- python>=3.8
- graphviz
- setuptools

0 comments on commit dd7f80b

Please sign in to comment.