Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Allow build action to be triggered remotely #47

Merged
merged 8 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference with {{ github.workspace }}?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think nothing (it came up when I was checking things with chatgpt), but found this slightly more readable. Wouldn't have made a separate PR for it, but while I was at it...

-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
Comment on lines +38 to +42
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no... it was already in there. I guess for troubleshooting reasons.

- 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
Loading