Skip to content

Commit

Permalink
Merge pull request #47 from EIT-ALIVE/remote_workflow_dbodor
Browse files Browse the repository at this point in the history
ci: Allow build action to be triggered remotely
  • Loading branch information
DaniBodor authored Jun 18, 2024
2 parents 3a21ca6 + c339a07 commit 92fcf9e
Show file tree
Hide file tree
Showing 7 changed files with 2,068 additions and 1,970 deletions.
47 changes: 17 additions & 30 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ on:
- "**.cff"
branches:
- main
workflow_call: # allows for remote triggering of action
inputs:
caller_branch:
required: true
type: string

jobs:
build:
Expand All @@ -30,7 +35,10 @@ jobs:
os: ["ubuntu-latest"]
python-version: ["3.10"]
steps:
- uses: actions/checkout@v3
- name: Checkout Repository
uses: actions/checkout@v3
with:
repository: EIT-ALIVE/eit_dash # needs to be made explicit for the remote trigger
- name: Connect to Container Registry
uses: docker/[email protected]
with:
Expand All @@ -39,40 +47,19 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run Tests in Container
run: >
echo "action triggered by: ${{github.event_name}}";
docker run
--rm
-v ${{ github.workspace }}:/ci
-v $GITHUB_WORKSPACE:/ci
-e TEST_DATA=/eitprocessing
ghcr.io/eit-alive/eittestdata:latest
sh -c 'set -xe ;
cd /ci ;
python3 -m pip install --upgrade pip poetry ;
python${{ matrix.python-version }} -m pip install --upgrade pip poetry ;
echo "--- conditionally install remote branch of eitprocessing"
if [ -n "${{ inputs.caller_branch }}" ]; then
poetry add git+https://github.com/EIT-ALIVE/eitprocessing.git#${{ inputs.caller_branch }} ;
fi
poetry install --with test ;
poetry run pytest -v tests/unit_tests ;
python -m build'
lint:
if: github.event.pull_request.draft == false
name: Linting build
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Python info
shell: bash -e {0}
run: |
which python3
python3 --version
- name: Upgrade pip and install dependencies
run: |
python3 -m pip install --upgrade pip poetry
poetry install --with test
- name: Check linting and formatting using ruff
run: |
poetry run ruff check
poetry run ruff format --check
python${{ matrix.python-version }} -m build'
4 changes: 1 addition & 3 deletions .github/workflows/cffconvert.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: cffconvert
name: Citation file

on:
push:
Expand All @@ -14,14 +14,12 @@ on:
- main

jobs:

verify:
if: github.event.pull_request.draft == false
name: "cffconvert"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
name: Check out a copy of the repository

- uses: citation-file-format/cffconvert-github-action@main
name: Check whether the citation metadata from CITATION.cff is equivalent to that in .zenodo.json
47 changes: 47 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Linting

on:
push:
paths-ignore:
- "**.md"
- "**.rst"
- "**.ipynb"
- "**.cff"
branches:
- main
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths-ignore:
- "**.md"
- "**.rst"
- "**.ipynb"
- "**.cff"
branches:
- main

jobs:
lint:
if: github.event.pull_request.draft == false
name: Linting build for (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Python info
shell: bash -e {0}
run: |
which python3
python3 --version
- name: Check linting and formatting using ruff
run: |
python3 -m pip install ruff
ruff check || echo "Please ensure you have the latest version of ruff (`ruff -V`) installed locally."
ruff format --check || echo "Please ensure you have the latest version of ruff (`ruff -V`) installed locally."
61 changes: 61 additions & 0 deletions .github/workflows/remote_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# This file exists just for troubleshooting purposes
name: Remote Build Trigger

on:
workflow_call:
inputs:
caller_branch:
required: true
type: string
remote:
required: true
type: boolean

jobs:
build:
name: Remote build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.10"]
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
repository: EIT-ALIVE/eit_dash # needs to be made explicit to avoid the remote repo being used
- name: Verify Repository Structure # echo debugging info in case things go haywire
run: |
echo "action triggered by: ${{github.event_name}}";
echo "Current directory: $(pwd)"
ls -al
echo "Contents of $GITHUB_WORKSPACE:"
ls -al $GITHUB_WORKSPACE
if [ -f $GITHUB_WORKSPACE/pyproject.toml ]; then
echo "Contents of pyproject.toml:"
cat $GITHUB_WORKSPACE/pyproject.toml
else
echo "pyproject.toml not found."
exit 1
fi
- name: Connect to Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: wbaccinelli
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run Tests in Container
run: >
docker run
--rm
-v $GITHUB_WORKSPACE:/ci
-e TEST_DATA=/eitprocessing
ghcr.io/eit-alive/eittestdata:latest
sh -c 'set -xe ;
cd /ci ;
python${{ matrix.python-version }} -m pip install --upgrade pip poetry ;
poetry add git+https://github.com/EIT-ALIVE/eitprocessing.git#${{ inputs.caller_branch }}
poetry install --with test ;
poetry run pytest -v tests/unit_tests ;
python${{ matrix.python-version }} -m build'
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Data
test_data

# Mac
.DS_Store

Expand Down
Loading

0 comments on commit 92fcf9e

Please sign in to comment.