Skip to content

Commit

Permalink
GitHub workflows: Added workflows push.yml and pull_request_to_main.yml
Browse files Browse the repository at this point in the history
incl. sub-workflows _test.yml and _code_quality.yml
  • Loading branch information
ClaasRostock committed Nov 23, 2023
1 parent 5571a4d commit 1e2e58e
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/_code_quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Code Quality

on: workflow_call

jobs:
black:
name: black
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: psf/black@stable
with:
options: '--check --diff'
src: '.'
jupyter: true
version: '==23.11'

ruff:
runs-on: ubuntu-latest
name: ruff
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip' # cache pip dependencies
- name: Install dependencies
run: pip install -r requirements.txt
- name: Install ruff
run: pip install ruff==0.1.6
- name: Run ruff
run: ruff .

pyright:
runs-on: ubuntu-latest
name: pyright
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip' # cache pip dependencies
- name: Install dependencies
run: |
pip install poetry
poetry install
pip install pytest
- name: Install pyright
run: pip install pyright==1.1.336
- name: Run pyright
run: pyright .
33 changes: 33 additions & 0 deletions .github/workflows/_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Unit Tests

on: workflow_call

jobs:
test:
name: Test on ${{matrix.python.toxenv}}-${{matrix.platform.toxenv}}
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: ubuntu-latest
toxenv: linux
- runner: windows-latest
toxenv: windows
python:
- version: '3.9'
toxenv: 'py39'
- version: '3.10'
toxenv: 'py310'
- version: '3.11'
toxenv: 'py311'
steps:
- uses: actions/checkout@v4
- name: Install Python ${{ matrix.python.version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python.version }}
cache: 'pip' # cache pip dependencies
- name: Install tox
run: python -m pip install tox
- name: Run pytest
run: tox -e ${{matrix.python.toxenv}}-${{matrix.platform.toxenv}}
28 changes: 28 additions & 0 deletions .github/workflows/pull_request_to_main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Pull Request to main
run-name: Pull Request to main from ${{ github.event.pull_request.head.ref }} by @${{ github.actor }}

on:
pull_request:
types:
- opened
# - synchronize
- reopened
- ready_for_review
- converted_to_draft
branches:
- main

concurrency:
group: pr-${{ github.ref }}-1
cancel-in-progress: true

jobs:
code_quality:
uses: ./.github/workflows/_code_quality.yml
test:
uses: ./.github/workflows/_test.yml
# build_package:
# needs:
# - code_quality
# - test
# uses: ./.github/workflows/_build_package.yml
18 changes: 18 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Push to custom branches
run-name: Push to ${{ github.ref }} by @${{ github.actor }}

on:
push:
branches-ignore:
- main
- release

concurrency:
group: push-${{ github.ref }}-1
cancel-in-progress: true

jobs:
code_quality:
uses: ./.github/workflows/_code_quality.yml
test:
uses: ./.github/workflows/_test.yml

0 comments on commit 1e2e58e

Please sign in to comment.