Skip to content

Commit

Permalink
Create composite action for installing eitprocessing
Browse files Browse the repository at this point in the history
  • Loading branch information
psomhorst committed Nov 8, 2024
1 parent 269b9a9 commit 6e4f095
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 60 deletions.
47 changes: 47 additions & 0 deletions .github/actions/install_eitprocessing/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Install eitprocessing
description: Install eitprocessing on the given Python version.
inputs:
python-version:
description: "The Python version to use"
required: false
default: "3.10"
dependencies:
description: "The optional dependencies of eitprocessing to install"
required: false
extract-data:
description: "Whether to extract testing data"
required: false
default: "false"
token:
description: "GitHub TOKEN"
required: true
data-directory:
description: "Directory where to store eitprocessing data"
required: false
default: ${{ github.workspace }}/../eitprocessing_data/

runs:
using: 'composite'
steps:
- uses: actions/setup-python@v2
with:
python-version: ${{ inputs.python-version }}
- uses: docker/[email protected]
if: ${{ inputs.extract-data == "true" }}
with:
registry: ghcr.io
username: psomhorst
password: ${{ inputs.token }}
- uses: shrink/actions-docker-extract@v3
if: ${{ inputs.extract-data == "true" }}
with:
image: ghcr.io/eit-alive/eittestdata:latest
destination: ${{ inputs.data-directory }}
path: /eitprocessing/.
- name: Install eitprocessing with ${{ inputs.dependencies }} dependencies
run: python3 -m pip install ".[${{ inputs.dependencies }}]"
shell: bash




22 changes: 6 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,13 @@ jobs:
EIT_PROCESSING_TEST_DATA: ${{ github.workspace }}/../eitprocessing_data/
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- uses: ./.github/actions/install_eitprocessing
with:
dependencies: testing
extract-data: true
python-version: ${{ matrix.python-version }}
- name: Connect to Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: psomhorst
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract data from image
uses: shrink/actions-docker-extract@v3
with:
image: ghcr.io/eit-alive/eittestdata:latest
destination: $EIT_PROCESSING_TEST_DATA
path: /eitprocessing/.
- name: Install eitprocessing with testing dependencies
run: python3 -m pip install ".[testing]"
os: ${{ matrix.os }}
token: ${{ secrets.GITHUB_TOKEN }}
data-directory: ${{ env.EIT_PROCESSING_TEST_DATA }}
- name: Run pytest
run: pytest -v
21 changes: 5 additions & 16 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,13 @@ jobs:
COVERALLS_FLAG_NAME: python-${{ matrix.python-version }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- uses: ./.github/actions/install_eitprocessing
with:
dependencies: testing
extract-data: true
python-version: ${{ matrix.python-version }}
- name: Connect to Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: psomhorst
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract data from image
uses: shrink/actions-docker-extract@v3
with:
image: ghcr.io/eit-alive/eittestdata:latest
destination: $EIT_PROCESSING_TEST_DATA
path: /eitprocessing/.
- name: Install eitprocessing
run: python3 -m pip install ".[testing]"
token: ${{ secrets.GITHUB_TOKEN }}
data-directory: ${{ env.EIT_PROCESSING_TEST_DATA }}
- name: Run coveralls
run: |
pytest --cov --cov-report xml --cov-report term --cov-report html
Expand Down
28 changes: 9 additions & 19 deletions .github/workflows/release_github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,18 @@ jobs:
os: ["ubunt-latest"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
name: Build for ${{ matrix.python-version }}, ${{ matrix.os }}
env:
EIT_PROCESSING_TEST_DATA: ${{ github.workspace }}/../eitprocessing_data/
steps:
- uses: actions/checkout@v4
- name: Connect to container registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: psomhorst
password: ${{ secrets.GITHUB_TOKEN }}
- name: Connect to Container Registry
uses: docker/[email protected]
- uses: ./.github/actions/install_eitprocessing
with:
registry: ghcr.io
username: psomhorst
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract data from image
uses: shrink/actions-docker-extract@v3
with:
image: ghcr.io/eit-alive/eittestdata:latest
destination: $EIT_PROCESSING_TEST_DATA
path: /eitprocessing/.
- name: Install eitprocessing with testing dependecies
run: python3 -m pip install ".[testing]"
dependencies: testing
extract-data: true
python-version: ${{ matrix.python-version }}
os: ${{ matrix.os }}
token: ${{ secrets.GITHUB_TOKEN }}
data-directory: ${{ env.EIT_PROCESSING_TEST_DATA }}
- name: Run pytest
run: pytest -v
- name: Install eitprocessing with dev dependencies
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/release_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
- uses: ./.github/actions/install_eitprocessing
with:
dependencies: publishing
extract-data: false
python-version: "3.10"
- name: Install package
run: pip install ."[publishing]"
- name: Build wheel and source distribution
run: python -m build
- uses: actions/upload-artifact@v4
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/test_build_documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
- uses: ./.github/actions/install_eitprocessing
with:
dependencies: docs
extract-data: false
python-version: "3.10"
- name: Install eitprocessing with docs dependencies
run: python3 -m pip install .[docs]
- name: Build documentation
run: mkdocs build
- name: Deploy documentation
Expand Down

0 comments on commit 6e4f095

Please sign in to comment.