Skip to content

Commit

Permalink
Non optimized workflows (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
mephenor authored May 17, 2024
1 parent 9359952 commit a0d2242
Show file tree
Hide file tree
Showing 11 changed files with 283 additions and 58 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/check_config_docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Check if the config schema and the example are up to date

on: push

jobs:
get-changed-services:
uses: ./.github/workflows/get_affected_services.yaml

check-config:
name: Check config schema and example
needs: get-changed-services
if: ${{ needs.get-changed-services.outputs.since-last-commit != '' }}
runs-on: ubuntu-latest

strategy:
matrix:
service: ${{ fromJson(needs.get-changed-services.outputs.since-last-commit) }}
fail-fast: false

env:
IFRS_CONFIG_YAML: ./services/ifrs/dev_config.yaml
IRS_CONFIG_YAML: ./services/irs/dev_config.yaml
PCS_CONFIG_YAML: ./services/pcs/dev_config.yaml

steps:
- name: Checkout repository
id: checkout
uses: actions/checkout@v4

- name: Update pip and pyopenssl
id: pip-update
run: python -m pip install --upgrade pip && pip install --upgrade pyopenssl

- name: Install dependencies
id: install-dependencies
run: pip install --no-deps -r ./lock/requirements-dev.txt && pip install --no-deps ./services/${{matrix.service}}

- name: Check config docs
id: check-config-docs
run: |
python3 ./scripts/update_config_docs.py --check ${{matrix.service}}
38 changes: 38 additions & 0 deletions .github/workflows/check_openapi_specs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This file is only needed if your repository uses FastAPI
name: Check if OpenAPI spec is up to date

on: push

jobs:
get-changed-services:
uses: ./.github/workflows/get_affected_services.yaml

check-openapi-specs:
name: Check config schema and example
needs: get-changed-services
if: ${{ needs.get-changed-services.outputs.since-last-commit != '' }}
runs-on: ubuntu-latest

strategy:
matrix:
service: ${{ fromJson(needs.get-changed-services.outputs.since-last-commit) }}
fail-fast: false

env:
IFRS_CONFIG_YAML: ./services/ifrs/dev_config.yaml
IRS_CONFIG_YAML: ./services/irs/dev_config.yaml
PCS_CONFIG_YAML: ./services/pcs/dev_config.yaml

steps:
- name: Checkout repository
id: checkout
uses: actions/checkout@v4

- name: Update pip and install dependencies
id: install-dependencies
run: python -m pip install --upgrade pip && pip install --no-deps -r ./lock/requirements-dev.txt && pip install --no-deps ./services/${{matrix.service}}

- name: Check openapi.yaml
id: check-openapi-docs
run: |
python3 ./scripts/update_openapi_docs.py --check ${{matrix.service}}
23 changes: 23 additions & 0 deletions .github/workflows/check_pyproject.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Check if pyproject.toml file is up to date

on: push

jobs:
static-code-analysis:
name: Check pyproject file

runs-on: ubuntu-latest

steps:
- name: Checkout repository
id: checkout
uses: actions/checkout@v4

- name: Update pip and install dependencies
id: install-dependencies
run: python -m pip install --upgrade pip && pip install --no-deps -r ./lock/requirements-dev.txt

- name: Check pyproject.toml
id: check-pyproject
run: |
./scripts/update_pyproject.py --check
53 changes: 53 additions & 0 deletions .github/workflows/check_readmes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Check if the README files are up to date

on: push

jobs:
get-changed-services:
uses: ./.github/workflows/get_affected_services.yaml

check-repo-readme:
name: Check repository README file
runs-on: ubuntu-latest

steps:
- name: Checkout repository
id: checkout
uses: actions/checkout@v4

- name: Update pip and install dependencies
id: install-dependencies
run: python -m pip install --upgrade pip && pip install --no-deps -r ./lock/requirements-dev.txt

- name: Check top level README
id: check-main-readme
run: |
python3 scripts/update_readme_monorepo.py --check
check-service-readme:
name: Check README file for ${{matrix.service}}
needs: get-changed-services
if: ${{ needs.get-changed-services.outputs.all-changes != '' }}
runs-on: ubuntu-latest
strategy:
matrix:
service: ${{ fromJson(needs.get-changed-services.outputs.since-last-commit) }}
fail-fast: false
env:
IFRS_CONFIG_YAML: ./services/ifrs/dev_config.yaml
IRS_CONFIG_YAML: ./services/irs/dev_config.yaml
PCS_CONFIG_YAML: ./services/pcs/dev_config.yaml

steps:
- name: Checkout repository
id: checkout
uses: actions/checkout@v4

- name: Update pip and install dependencies
id: install-dependencies
run: python -m pip install --upgrade pip && pip install --no-deps -r ./lock/requirements-dev.txt

- name: Check service level READMEs
id: check-service-readmes
run: |
python3 scripts/update_readme_services.py --check --service ${{matrix.service}}
60 changes: 60 additions & 0 deletions .github/workflows/get_affected_services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Get services affected by changes

on:
workflow_call:
outputs:
all-changes:
description: "Services affected by changes for all commits on branch"
value: ${{ jobs.get_changed_services_pr.outputs.services }}
since-last-commit:
description: "Services affected by changes since last commit"
value: ${{ jobs.get_changed_services_commit.outputs.services }}

jobs:
get_changed_services_commit:
runs-on: ubuntu-latest
outputs:
services: ${{ steps.services-changed.outputs.affected }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Changed Files
id: changed-files
uses: tj-actions/changed-files@v44

- name: Install Typer to check changed services
id: install-typer
run: pip install typer>=0.9.0

- name: Generate list of changed services
id: services-changed
run: |
echo "affected=$(python3 ./scripts/get_affected_services.py ${{ steps.changed-files.outputs.all_changed_files }} )" >> $GITHUB_OUTPUT
get_changed_services_pr:
runs-on: ubuntu-latest
outputs:
services: ${{ steps.services-changed.outputs.affected }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Changed Files
id: changed-files
uses: tj-actions/changed-files@v44

- name: Install Typer to check changed services
id: install-typer
run: pip install typer>=0.9.0

- name: Generate list of changed services
id: services-changed
run: |
echo "affected=$(python3 ./scripts/get_affected_services.py ${{ steps.changed-files.outputs.all_changed_files }} )" >> $GITHUB_OUTPUT
45 changes: 45 additions & 0 deletions .github/workflows/static_code_analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Static Code Analysis

on: push

jobs:
static-code-analysis:
name: Static Code Analysis

runs-on: ubuntu-latest

steps:
- name: Checkout repository
id: checkout
uses: actions/checkout@v4

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

- name: Run pre-commit
uses: pre-commit/action@v3.0.1
env:
SKIP: no-commit-to-branch

- name: Update pip and install dependencies
id: install-dependencies
run: python -m pip install --upgrade pip && pip install --no-deps -r ./lock/requirements-dev.txt

- name: Run ruff
id: ruff
run: |
ruff check --output-format=github .
ruff format --check .
- name: Run mypy
id: mypy
run: |
mypy .
- name: Check license header and file
id: license-checker
run: |
./scripts/check_license.py
29 changes: 5 additions & 24 deletions .github/workflows/tests_on_pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,22 @@ on:

jobs:
get-changed-services:
runs-on: ubuntu-latest
outputs:
services: ${{ steps.services-changed.outputs.affected }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Changed Files
id: changed-files
uses: tj-actions/changed-files@v44

- name: Install Typer to check changed services
id: install-typer
run: pip install typer>=0.9.0

- name: Generate list of changed services
id: services-changed
run: |
echo "affected=$(python3 ./scripts/get_affected_services.py ${{ steps.changed-files.outputs.all_changed_files }} )" >> $GITHUB_OUTPUT
uses: ./.github/workflows/get_affected_services.yaml

test:
needs: get-changed-services
if: ${{ needs.get-changed-services.outputs.services != '' }}
if: ${{ needs.get-changed-services.outputs.all-changes != '' }}
runs-on: ubuntu-latest
strategy:
matrix:
service: ${{ fromJson(needs.get-changed-services.outputs.services) }}
service: ${{ fromJson(needs.get-changed-services.outputs.all-changes) }}
fail-fast: false

env:
IFRS_CONFIG_YAML: ./services/ifrs/dev_config.yaml
IRS_CONFIG_YAML: ./services/irs/dev_config.yaml
PCS_CONFIG_YAML: ./services/pcs/dev_config.yaml

steps:
- name: Checkout ${{matrix.service}}
uses: actions/checkout@v4
Expand Down
29 changes: 5 additions & 24 deletions .github/workflows/tests_on_push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,22 @@ on:

jobs:
get-changed-services:
runs-on: ubuntu-latest
outputs:
services: ${{ steps.services-changed.outputs.affected }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Changed Files
id: changed-files
uses: tj-actions/changed-files@v44

- name: Install Typer to check changed services
id: install-typer
run: pip install typer>=0.9.0

- name: Generate list of changed services
id: services-changed
run: |
echo "affected=$(python3 ./scripts/get_affected_services.py ${{ steps.changed-files.outputs.all_changed_files }} )" >> $GITHUB_OUTPUT
uses: ./.github/workflows/get_affected_services.yaml

test:
needs: get-changed-services
if: ${{ needs.get-changed-services.outputs.services != '' }}
if: ${{ needs.get-changed-services.outputs.since-last-commit != '' }}
runs-on: ubuntu-latest
strategy:
matrix:
service: ${{ fromJson(needs.get-changed-services.outputs.services) }}
service: ${{ fromJson(needs.get-changed-services.outputs.since-last-commit) }}
fail-fast: false

env:
IFRS_CONFIG_YAML: ./services/ifrs/dev_config.yaml
IRS_CONFIG_YAML: ./services/irs/dev_config.yaml
PCS_CONFIG_YAML: ./services/pcs/dev_config.yaml

steps:
- name: Checkout ${{matrix.service}}
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .pyproject_generation/pyproject_template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ max-complexity = 10

[tool.ruff.lint.per-file-ignores]
"scripts/*" = ["PL", "S", "SIM", "D"]
"services/*/tests/*" = ["S", "SIM", "PLR", "B011"]
"services/*/tests_*" = ["S", "SIM", "PLR", "B011"]
".devcontainer/*" = ["S", "SIM", "D"]
"examples/*" = ["S", "D"]
"__init__.py" = ["D"]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ max-complexity = 10
"SIM",
"D",
]
"services/*/tests/*" = [
"services/*/tests_*" = [
"S",
"SIM",
"PLR",
Expand Down
Loading

0 comments on commit a0d2242

Please sign in to comment.