From baf65ee36b2f8cdc4d1239e41b0917a3c48336e5 Mon Sep 17 00:00:00 2001 From: Krzysztof Wisniewski Date: Sun, 3 Sep 2023 13:58:55 +0200 Subject: [PATCH] Add Github Actions CI configuration --- .github/workflows/build_n_deploy_docs.yaml | 42 ++++++++++++++ .github/workflows/code_quality.yaml | 64 ++++++++++++++++++++++ .github/workflows/type_checks.yaml | 64 ++++++++++++++++++++++ .github/workflows/unit_tests.yaml | 64 ++++++++++++++++++++++ pyproject.toml | 12 ++-- scripts/__init__.py | 0 scripts/ruff.toml | 4 ++ 7 files changed, 246 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/build_n_deploy_docs.yaml create mode 100644 .github/workflows/code_quality.yaml create mode 100644 .github/workflows/type_checks.yaml create mode 100644 .github/workflows/unit_tests.yaml delete mode 100644 scripts/__init__.py create mode 100644 scripts/ruff.toml diff --git a/.github/workflows/build_n_deploy_docs.yaml b/.github/workflows/build_n_deploy_docs.yaml new file mode 100644 index 00000000..f3e25983 --- /dev/null +++ b/.github/workflows/build_n_deploy_docs.yaml @@ -0,0 +1,42 @@ +--- +name: Build & Deploy Docs + +on: + push: + branches: + - main + + workflow_dispatch: + +concurrency: + group: ${{ github.action_path }}-${{ github.ref }}-build-n-deploy-docs + cancel-in-progress: false + +jobs: + run-build-n-deploy-docs: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + python-version: ["3.8"] + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v3.6.0 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4.7.0 + with: + python-version: ${{ matrix.python-version }} + architecture: "x64" + + - name: Install Poetry + run: pip install poetry==1.5.1 + + - name: Install dependencies + run: poetry install --with=docs --no-cache --sync + + - name: Run build & deploy documentation + run: poetry run poe run-build-n-deploy-docs diff --git a/.github/workflows/code_quality.yaml b/.github/workflows/code_quality.yaml new file mode 100644 index 00000000..bea93ff5 --- /dev/null +++ b/.github/workflows/code_quality.yaml @@ -0,0 +1,64 @@ +--- +name: Code Quality + +on: + push: + branches: + - main + - dev + - fix/** + - hotfix/** + - feature/** + - release/** + - dependabot/** + + pull_request: + branches: + - main + - dev + - fix/** + - hotfix/** + - feature/** + - release/** + - dependabot/** + types: + - opened + - reopened + + schedule: + - cron: 0 12 * * 6 + + workflow_dispatch: + +concurrency: + group: ${{ github.action_path }}-${{ github.ref }}-code-quality + cancel-in-progress: false + +jobs: + run-code-quality-checks: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + python-version: ["3.8", "3.11"] + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v3.6.0 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4.7.0 + with: + python-version: ${{ matrix.python-version }} + architecture: "x64" + + - name: Install Poetry + run: pip install poetry==1.5.1 + + - name: Install dependencies + run: poetry install --no-cache --sync + + - name: Run code quality checks with pre-commit + run: poetry run poe run-code-quality-checks diff --git a/.github/workflows/type_checks.yaml b/.github/workflows/type_checks.yaml new file mode 100644 index 00000000..4c66fb26 --- /dev/null +++ b/.github/workflows/type_checks.yaml @@ -0,0 +1,64 @@ +--- +name: Type Checks + +on: + push: + branches: + - main + - dev + - fix/** + - hotfix/** + - feature/** + - release/** + - dependabot/** + + pull_request: + branches: + - main + - dev + - fix/** + - hotfix/** + - feature/** + - release/** + - dependabot/** + types: + - opened + - reopened + + schedule: + - cron: 0 12 * * 6 + + workflow_dispatch: + +concurrency: + group: ${{ github.action_path }}-${{ github.ref }}-type-checks + cancel-in-progress: false + +jobs: + run-type-checks: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + python-version: ["3.8", "3.11"] + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v3.6.0 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4.7.0 + with: + python-version: ${{ matrix.python-version }} + architecture: "x64" + + - name: Install Poetry + run: pip install poetry==1.5.1 + + - name: Install dependencies + run: poetry install --no-cache --sync + + - name: Run type checks with mypy + run: poetry run poe run-type-checks diff --git a/.github/workflows/unit_tests.yaml b/.github/workflows/unit_tests.yaml new file mode 100644 index 00000000..43a86a91 --- /dev/null +++ b/.github/workflows/unit_tests.yaml @@ -0,0 +1,64 @@ +--- +name: Unit Tests + +on: + push: + branches: + - main + - dev + - fix/** + - hotfix/** + - feature/** + - release/** + - dependabot/** + + pull_request: + branches: + - main + - dev + - fix/** + - hotfix/** + - feature/** + - release/** + - dependabot/** + types: + - opened + - reopened + + schedule: + - cron: 0 12 * * 6 + + workflow_dispatch: + +concurrency: + group: ${{ github.action_path }}-${{ github.ref }}-unit-tests + cancel-in-progress: false + +jobs: + run-unit-tests: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macOS-latest] + python-version: ["3.8", "3.9", "3.10", "3.11"] + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v3.6.0 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4.7.0 + with: + python-version: ${{ matrix.python-version }} + architecture: "x64" + + - name: Install Poetry + run: pip install poetry==1.5.1 + + - name: Install dependencies + run: poetry install --no-cache --sync + + - name: Run unit tests + run: poetry run poe run-unit-tests diff --git a/pyproject.toml b/pyproject.toml index 42d129d1..3149de0f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,14 +59,19 @@ install-hooks = [ ] # ------------- # hook triggers -pre-commit = [ - { cmd = "poetry install --sync --no-ansi" }, +run-code-quality-checks = [ { cmd = "pre-commit run --all-files -v" }, ] # ------------------------------------------------------------------------------------- -test = [ +run-unit-tests = [ { cmd = "pytest --log-level=DEBUG -s -n auto --cov=pygerber --cov-report=term-missing:skip-covered" }, ] +run-type-checks = [ + { cmd = "mypy src/pygerber test/ scripts/" } +] +run-build-n-deploy-docs = [ + { cmd = "mkdocs gh-deploy" } +] [tool.isort] profile = "black" @@ -122,7 +127,6 @@ runtime-evaluated-base-classes = [ # https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html # # ---------------------------------------------------------------------------- # python_version = "3.8" -packages = "pygerber" # A regular expression that matches file names, directory names and paths which # mypy should ignore while recursively discovering files to check. Use forward #slashes (/) as directory separators on all platforms. diff --git a/scripts/__init__.py b/scripts/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/scripts/ruff.toml b/scripts/ruff.toml new file mode 100644 index 00000000..e401c1e9 --- /dev/null +++ b/scripts/ruff.toml @@ -0,0 +1,4 @@ +extend = "../pyproject.toml" +ignore = [ + "D", # Only limited docstrings are required. +]