Skip to content

Commit

Permalink
Dark workflow magic
Browse files Browse the repository at this point in the history
  • Loading branch information
mephenor committed May 16, 2024
1 parent 97c0b7b commit 6b7eb8e
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 16 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/check_config_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ name: Check if the config schema and the example are up to date
on: push

env:
PYTHON_VERSION: '3.9'
IFRS_CONFIG_YAML: ./services/ifrs/dev_config.yaml
IRS_CONFIG_YAML: ./services/irs/dev_config.yaml
PCS_CONFIG_YAML: ./services/pcs/dev_config.yaml
Expand All @@ -40,13 +41,21 @@ jobs:
fail-fast: false

steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Restore cache
id: restore-cache
uses: actions/cache@v4
with:
path: ${{ needs.build-cache.outputs.python-location }}
path: |
${{ github.repository }}
${{ env.pythonLocation }}
key: ${{ github.sha }}


- name: Check config docs
id: check-config-docs
run: |
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/check_openapi_specs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ name: Check if OpenAPI spec is up to date
on: push

env:
PYTHON_VERSION: '3.9'
IFRS_CONFIG_YAML: ./services/ifrs/dev_config.yaml
IRS_CONFIG_YAML: ./services/irs/dev_config.yaml
PCS_CONFIG_YAML: ./services/pcs/dev_config.yaml
Expand All @@ -40,11 +41,18 @@ jobs:
fail-fast: false

steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Restore cache
id: restore-cache
uses: actions/cache@v4
with:
path: ${{ needs.build-cache.outputs.python-location }}
path: |
${{ github.repository }}
${{ env.pythonLocation }}
key: ${{ github.sha }}

- name: Check openapi.yaml
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/check_pyproject.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ name: Check if pyproject.toml file is up to date

on: push

env:
PYTHON_VERSION: '3.9'

jobs:
build-cache:
uses: ./.github/workflows/prepare_build_cache.yaml
Expand All @@ -29,11 +32,18 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Restore cache
id: restore-cache
uses: actions/cache@v4
with:
path: ${{ needs.build-cache.outputs.python-location }}
path: |
${{ github.repository }}
${{ env.pythonLocation }}
key: ${{ github.sha }}

- name: Check pyproject.toml
Expand Down
21 changes: 19 additions & 2 deletions .github/workflows/check_readmes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ name: Check if the README files are up to date
on: push

env:
PYTHON_VERSION: '3.9'
IFRS_CONFIG_YAML: ./services/ifrs/dev_config.yaml
IRS_CONFIG_YAML: ./services/irs/dev_config.yaml
PCS_CONFIG_YAML: ./services/pcs/dev_config.yaml
Expand All @@ -33,13 +34,21 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Restore cache
id: restore-cache
uses: actions/cache@v4
with:
path: ${{ needs.build-cache.outputs.python-location }}
path: |
${{ github.repository }}
${{ env.pythonLocation }}
key: ${{ github.sha }}


- name: Check top level README
id: check-main-readme
run: |
Expand All @@ -56,13 +65,21 @@ jobs:
fail-fast: false

steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Restore cache
id: restore-cache
uses: actions/cache@v4
with:
path: ${{ needs.build-cache.outputs.python-location }}
path: |
${{ github.repository }}
${{ env.pythonLocation }}
key: ${{ github.sha }}


- name: Check service level READMEs
id: check-service-readmes
run: |
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/prepare_build_cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Get services affected by changes

concurrency:
group: ${{ github.sha }}-build-cache
cancel-in-progress: false

on:
workflow_call:
Expand Down Expand Up @@ -37,21 +38,21 @@ jobs:
with:
fetch-depth: 2

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}

- name: Restore cache
id: restore-cache
uses: actions/cache/restore@v4
with:
path: |
${{ env.pythonLocation }}
${{ env.python-location }}
${{ github.repository }}
services.txt
key: ${{ inputs.cache-key }}

- name: Set up Python
if: steps.restore-cache.outputs.cache-hit != 'true'
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}

- name: Update pip, pyopenssl and install dependencies
id: pip-update
if: steps.restore-cache.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -94,11 +95,12 @@ jobs:
with:
path: |
${{ env.pythonLocation }}
${{ github.repository }}
services.txt
key: ${{ inputs.cache-key }}

- name: Set output
id: set-output
run: |
echo "python-location=${{env.pythonLocation}}" >> $GITHUB_OUTPUT
echo "services=${{toJson(env.services)}}" >> $GITHUB_OUTPUT
echo "python-location=$(dirname $(dirname $(which python)))" >> $GITHUB_OUTPUT
13 changes: 12 additions & 1 deletion .github/workflows/static_code_analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ name: Static Code Analysis

on: push

env:
PYTHON_VERSION: '3.9'

jobs:
build-cache:
uses: ./.github/workflows/prepare_build_cache.yaml
Expand All @@ -29,13 +32,21 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Restore cache
id: restore-cache
uses: actions/cache@v4
with:
path: ${{ needs.build-cache.outputs.python-location }}
path: |
${{ github.repository }}
${{ env.pythonLocation }}
key: ${{ github.sha }}


- name: Run pre-commit
uses: pre-commit/action@v3.0.1
env:
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/tests_on_pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ on:
types: [opened, reopened]

env:
PYTHON_VERSION: '3.9'
IFRS_CONFIG_YAML: ./services/ifrs/dev_config.yaml
IRS_CONFIG_YAML: ./services/irs/dev_config.yaml
PCS_CONFIG_YAML: ./services/pcs/dev_config.yaml
Expand All @@ -40,11 +41,18 @@ jobs:
fail-fast: false

steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Restore cache
id: restore-cache
uses: actions/cache@v4
with:
path: ${{ needs.build-cache.outputs.python-location }}
path: |
${{ github.repository }}
${{ env.pythonLocation }}
key: ${{ github.sha }}

- name: Run tests for ${{matrix.service}}
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/tests_on_push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:
- main

env:
PYTHON_VERSION: '3.9'
IFRS_CONFIG_YAML: ./services/ifrs/dev_config.yaml
IRS_CONFIG_YAML: ./services/irs/dev_config.yaml
PCS_CONFIG_YAML: ./services/pcs/dev_config.yaml
Expand All @@ -41,11 +42,18 @@ jobs:
fail-fast: false

steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Restore cache
id: restore-cache
uses: actions/cache@v4
with:
path: ${{ needs.build-cache.outputs.python-location }}
path: |
${{ github.repository }}
${{ env.pythonLocation }}
key: ${{ github.sha }}

- name: Run tests for ${{matrix.service}}
Expand Down

0 comments on commit 6b7eb8e

Please sign in to comment.