From 1e2e58e8ee8d40e77cb2cdc8bcfd0abb31ffe46f Mon Sep 17 00:00:00 2001 From: Claas Date: Thu, 23 Nov 2023 14:33:33 +0100 Subject: [PATCH] GitHub workflows: Added workflows push.yml and pull_request_to_main.yml incl. sub-workflows _test.yml and _code_quality.yml --- .github/workflows/_code_quality.yml | 51 ++++++++++++++++++++++ .github/workflows/_test.yml | 33 ++++++++++++++ .github/workflows/pull_request_to_main.yml | 28 ++++++++++++ .github/workflows/push.yml | 18 ++++++++ 4 files changed, 130 insertions(+) create mode 100644 .github/workflows/_code_quality.yml create mode 100644 .github/workflows/_test.yml create mode 100644 .github/workflows/pull_request_to_main.yml create mode 100644 .github/workflows/push.yml diff --git a/.github/workflows/_code_quality.yml b/.github/workflows/_code_quality.yml new file mode 100644 index 0000000..3a639e0 --- /dev/null +++ b/.github/workflows/_code_quality.yml @@ -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 . diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yml new file mode 100644 index 0000000..b78e2ad --- /dev/null +++ b/.github/workflows/_test.yml @@ -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}} diff --git a/.github/workflows/pull_request_to_main.yml b/.github/workflows/pull_request_to_main.yml new file mode 100644 index 0000000..2bff438 --- /dev/null +++ b/.github/workflows/pull_request_to_main.yml @@ -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 diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 0000000..08debf2 --- /dev/null +++ b/.github/workflows/push.yml @@ -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