Skip to content

Commit

Permalink
Reusable build-cache workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mephenor committed May 16, 2024
1 parent d1e9ddf commit 07a5b3d
Show file tree
Hide file tree
Showing 10 changed files with 326 additions and 178 deletions.
50 changes: 33 additions & 17 deletions .github/workflows/check_config_docs.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,51 @@
# Copyright 2022-2024 Universität Tübingen, DKFZ and EMBL
# for the German Human Genome-Phenome Archive (GHGA)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Check if the config schema and the example are up to date

on: push

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

jobs:
get-changed-services:
uses: ./.github/workflows/get_affected_services.yaml
build-cache:
uses: ./.github/workflows/prepare_build_cache.yaml
with:
cache-key: ${{ github.sha }}

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

strategy:
matrix:
service: ${{ fromJson(needs.get-changed-services.outputs.since-last-commit) }}
service: ${{ fromJson(needs.build-cache.outputs.services) }}
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: Restore cache
id: restore-cache
uses: actions/cache@v4
with:
path: ${{ needs.build-cache.outputs.python-location }}
key: ${{ github.sha }}

- name: Check config docs
id: check-config-docs
Expand Down
51 changes: 33 additions & 18 deletions .github/workflows/check_openapi_specs.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,51 @@
# This file is only needed if your repository uses FastAPI
# Copyright 2022-2024 Universität Tübingen, DKFZ and EMBL
# for the German Human Genome-Phenome Archive (GHGA)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Check if OpenAPI spec is up to date

on: push

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

jobs:
get-changed-services:
uses: ./.github/workflows/get_affected_services.yaml
build-cache:
uses: ./.github/workflows/prepare_build_cache.yaml
with:
cache-key: ${{ github.sha }}

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

strategy:
matrix:
service: ${{ fromJson(needs.get-changed-services.outputs.since-last-commit) }}
service: ${{ fromJson(needs.build-cache.outputs.services) }}
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: Restore cache
id: restore-cache
uses: actions/cache@v4
with:
path: ${{ needs.build-cache.outputs.python-location }}
key: ${{ github.sha }}

- name: Check openapi.yaml
id: check-openapi-docs
Expand Down
35 changes: 27 additions & 8 deletions .github/workflows/check_pyproject.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,40 @@
# Copyright 2022-2024 Universität Tübingen, DKFZ and EMBL
# for the German Human Genome-Phenome Archive (GHGA)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Check if pyproject.toml file is up to date

on: push

jobs:
build-cache:
uses: ./.github/workflows/prepare_build_cache.yaml
with:
cache-key: ${{ github.sha }}

static-code-analysis:
name: Check pyproject file

needs: build-cache
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: Restore cache
id: restore-cache
uses: actions/cache@v4
with:
path: ${{ needs.build-cache.outputs.python-location }}
key: ${{ github.sha }}

- name: Check pyproject.toml
id: check-pyproject
Expand Down
62 changes: 39 additions & 23 deletions .github/workflows/check_readmes.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,44 @@
# Copyright 2022-2024 Universität Tübingen, DKFZ and EMBL
# for the German Human Genome-Phenome Archive (GHGA)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Check if the README files are up to date

on: push

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

jobs:
get-changed-services:
uses: ./.github/workflows/get_affected_services.yaml
build-cache:
uses: ./.github/workflows/prepare_build_cache.yaml
with:
cache-key: ${{ github.sha }}

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: Restore cache
id: restore-cache
uses: actions/cache@v4
with:
path: ${{ needs.build-cache.outputs.python-location }}
key: ${{ github.sha }}

- name: Check top level README
id: check-main-readme
Expand All @@ -26,26 +47,21 @@ jobs:
check-service-readme:
name: Check README file for ${{matrix.service}}
needs: get-changed-services
if: ${{ needs.get-changed-services.outputs.all-changes != '' }}
needs: build-cache
if: ${{ needs.build-cache.outputs.services != '' }}
runs-on: ubuntu-latest
strategy:
matrix:
service: ${{ fromJson(needs.get-changed-services.outputs.since-last-commit) }}
service: ${{ fromJson(needs.build-cache.outputs.services) }}
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: Restore cache
id: restore-cache
uses: actions/cache@v4
with:
path: ${{ needs.build-cache.outputs.python-location }}
key: ${{ github.sha }}

- name: Check service level READMEs
id: check-service-readmes
Expand Down
60 changes: 0 additions & 60 deletions .github/workflows/get_affected_services.yaml

This file was deleted.

Loading

0 comments on commit 07a5b3d

Please sign in to comment.