-
Notifications
You must be signed in to change notification settings - Fork 0
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
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
13dc1bc
ci: add test_data to gitignore
DaniBodor 894f5a0
ci: auto-format cffconvert action
DaniBodor 30ceeb3
ci: read os and python version from matrix in build actions
DaniBodor f974af7
ci: move linting check to separate action
DaniBodor 21b4a24
ci: allow for remotely triggered build action
DaniBodor 95b23b4
ci: use remote branch when triggered remotely
DaniBodor de05e43
ci: create troubleshooting file for remote triggering
DaniBodor c339a07
ci: simplify lint action
DaniBodor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: | ||
|
@@ -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: | ||
|
@@ -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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# Data | ||
test_data | ||
|
||
# Mac | ||
.DS_Store | ||
|
||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 }}
?There was a problem hiding this comment.
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...