Skip to content

Commit

Permalink
Add github action
Browse files Browse the repository at this point in the history
Add github action

Add github action

Add github action

Add github action

Add github action

Add github action

Add github action

Add github action

Add github action

Add github action
  • Loading branch information
bastgau committed Jun 30, 2023
1 parent 618aa44 commit b3a97a9
Show file tree
Hide file tree
Showing 2 changed files with 258 additions and 0 deletions.
220 changes: 220 additions & 0 deletions .github/workflows/control.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
---
name: Code Quality & Build

on: # yamllint disable-line rule:truthy
workflow_dispatch:
push:
branches:
- development
- main
- master
paths:
- "src/**"
- "tests/**"

env:
PYTHON_VERSION: "3.10"
ARTIFACT_NAME: "mypkg"
PACKAGE_NAME: "mypkg"

jobs:
check:
name: Check Python Code
runs-on: ubuntu-latest
steps:
- name: "Checkout GitHub Action"
uses: actions/checkout@v3

- name: Setup Python ${{ env.PYTHON_VERSION }} Environment
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install dependencies with Pip
run: |
python${{ env.PYTHON_VERSION }} -m venv .venv
source .venv/bin/activate
.venv/bin/pip install --upgrade pip
.venv/bin/pip install -r requirements.txt
.venv/bin/pip install -r requirements-dev.txt
- name: Initialize environment variables
run: |
CURRENT_PWD=$(pwd)
PYTHONPATH="$CURRENT_PWD/src"
echo "PYTHONPATH=$PYTHONPATH" >> $GITHUB_ENV
WORKINGPATH="$CURRENT_PWD"
echo "WORKINGPATH=$WORKINGPATH" >> $GITHUB_ENV
- name: Pyright
id: pyright
run: |
. $WORKINGPATH/.venv/bin/activate
pyright $PYTHONPATH -p $WORKINGPATH/tools/pyrightconfig.json
- name: Pylint
id: pylint
if: ${{ always() }}
run: |
. $WORKINGPATH/.venv/bin/activate
pylint $PYTHONPATH/${{ env.PACKAGE_NAME }} --score=false
- name: Flake8
id: flake8
if: ${{ always() }}
run: |
. $WORKINGPATH/.venv/bin/activate
flake8 $PYTHONPATH/${{ env.PACKAGE_NAME }}
- name: Mypy
id: mypy
if: ${{ always() }}
run: |
. $WORKINGPATH/.venv/bin/activate
mypy $PYTHONPATH/${{ env.PACKAGE_NAME }}
- name: Pylama
id: pylama
if: ${{ always() }}
run: |
. $WORKINGPATH/.venv/bin/activate
pylama $PYTHONPATH/${{ env.PACKAGE_NAME }}
- name: Yapf
id: yapf
if: ${{ always() }}
run: |
. $WORKINGPATH/.venv/bin/activate
yapf --diff $PYTHONPATH/${{ env.PACKAGE_NAME }} --recursive
- name: Linter Results
if: |
(success() || failure())
&& (steps.flake8.outcome == 'failure'
|| steps.mypy.outcome == 'failure'
|| steps.pylama.outcome == 'failure'
|| steps.pylint.outcome == 'failure'
|| steps.pyright.outcome == 'failure'
|| steps.yapf.outcome == 'failure')
run: |
echo "Pyright: ${{ steps.pyright.outcome }}"
echo "Pylint: ${{ steps.pylint.outcome }}"
echo "Pylint: ${{ steps.pylama.outcome }}"
echo "Flake8: ${{ steps.flake8.outcome }}"
echo "Mypy: ${{ steps.mypy.outcome }}"
echo "Yapf: ${{ steps.yapf.outcome }}"
echo "On failure, please check the previous steps to identify the linter issue(s)."
exit 1
unit_test:
name: Unit Tests Python
runs-on: ubuntu-latest
needs: [check]
steps:
- name: "Checkout GitHub Action"
uses: actions/checkout@v3

- name: Setup Python ${{ env.PYTHON_VERSION }} Environment
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install dependencies with Pip
run: |
python${{ env.PYTHON_VERSION }} -m venv .venv
source .venv/bin/activate
.venv/bin/pip install --upgrade pip
.venv/bin/pip install -r requirements.txt
.venv/bin/pip install -r requirements-test.txt
- name: Initialize environment variables
run: |
CURRENT_PWD=$(pwd)
PYTHONPATH="$CURRENT_PWD/src"
echo "PYTHONPATH=$PYTHONPATH" >> $GITHUB_ENV
WORKINGPATH="$CURRENT_PWD"
echo "WORKINGPATH=$WORKINGPATH" >> $GITHUB_ENV
- name: Pytest
id: pytest
run: |
. $WORKINGPATH/.venv/bin/activate
cd $WORKINGPATH
pytest tests -vv -s -n auto
- name: Coverage Analysis
id: coverage
run: |
. $WORKINGPATH/.venv/bin/activate
cd $WORKINGPATH
coverage run -m pytest tests -q --disable-warnings
- name: Coverage Report
id: coverage_report
run: |
. $WORKINGPATH/.venv/bin/activate
cd $WORKINGPATH
coverage report -m
configuration:
name: Check User Configuration
runs-on: ubuntu-latest
steps:
- name: "Checkout GitHub Action"
uses: actions/checkout@v3

- name: Setup Python ${{ env.PYTHON_VERSION }} Environment
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Initialize environment variables
run: |
CURRENT_PWD=$(pwd)
PYTHONPATH="$CURRENT_PWD/src"
echo "PYTHONPATH=$PYTHONPATH" >> $GITHUB_ENV
WORKINGPATH="$CURRENT_PWD"
echo "WORKINGPATH=$WORKINGPATH" >> $GITHUB_ENV
- name: Install dependencies with Pip
run: |
pip install yamllint
- name: "YAML Lint"
id: yaml_lint
run: |
yamllint $PYTHONPATH/${{ env.PACKAGE_NAME }}
- name: Configuration Results
if: (success() || failure()) && (steps.yaml_lint.outcome == 'failure')
run: |
echo "YAML Lint: ${{ steps.yaml_lint.outcome }}"
echo "On failure, please check the previous steps to identify the linter issue(s)."
exit 1
build:
name: Build
needs: [check, configuration, unit_test]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: "Checkout GitHub Action"
uses: actions/checkout@v3

- name: Initialize environment variables
run: |
CURRENT_PWD=$(pwd)
WORKINGPATH="$CURRENT_PWD"
echo "WORKINGPATH=$WORKINGPATH" >> $GITHUB_ENV
- uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME }}
path: |
${{ env.WORKINGPATH }}
!${{ env.WORKINGPATH }}/.devcontainer
!${{ env.WORKINGPATH }}/.git
!${{ env.WORKINGPATH }}/.github
!${{ env.WORKINGPATH }}/.vscode
!${{ env.WORKINGPATH }}/tests
!${{ env.WORKINGPATH }}/tools
38 changes: 38 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
yaml-files:
- "*.yaml"
- "*.yml"
- ".yamllint"

rules:
anchors: enable
braces: enable
brackets: enable
colons: enable
commas: enable
comments-indentation:
level: warning
document-end: disable
document-start:
level: warning
empty-lines: enable
empty-values: disable
float-values: disable
hyphens: enable
indentation: enable
key-duplicates: enable
key-ordering: disable
new-line-at-end-of-file: enable
new-lines: enable
octal-values: disable
quoted-strings: disable
trailing-spaces: enable
truthy:
level: warning
line-length:
max: 150
allow-non-breakable-words: true
allow-non-breakable-inline-mappings: false
comments:
level: warning
min-spaces-from-content: 1

0 comments on commit b3a97a9

Please sign in to comment.