Skip to content

Commit

Permalink
Add option to upload artifacts from GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
JCGoran committed Feb 10, 2025
1 parent 6f28ea8 commit f95b2b5
Showing 1 changed file with 50 additions and 19 deletions.
69 changes: 50 additions & 19 deletions .github/workflows/nrn-modeldb-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ on:
push:
branches: [master]
pull_request:
branches: [ master ]
branches: [master]
schedule:
# Run at 2am every day
- cron: '0 2 * * *'
workflow_call:
inputs:
neuron_v1:
description: Last official release (neuron) / NEURON pinned version / Azure drop (artifacts) url
description: Last official release (neuron) / NEURON pinned version / artifacts URL
default: 'neuron'
required: true
type: string
neuron_v2:
description: Last nightly release (neuron-nightly) / NEURON pinned version / Azure drop (artifacts) url
description: Last nightly release (neuron-nightly) / NEURON pinned version / artifacts URL
default: 'neuron-nightly'
required: true
type: string
Expand All @@ -29,16 +29,15 @@ on:
default: 'neuronsimulator/nrn-modeldb-ci'
type: string
required: false



workflow_dispatch:
inputs:
neuron_v1:
description: Last official release (neuron) / NEURON pinned version / Azure drop (artifacts) url
description: Last official release (neuron) / NEURON pinned version / artifacts URL
default: 'neuron'
required: true
neuron_v2:
description: Last nightly release (neuron-nightly) / NEURON pinned version / Azure drop (artifacts) url
description: Last nightly release (neuron-nightly) / NEURON pinned version / artifacts URL
default: 'neuron-nightly'
required: true
models_to_run:
Expand All @@ -58,27 +57,27 @@ jobs:
MODELS_TO_RUN: ${{ github.event.inputs.models_to_run || inputs.models_to_run || '' }}

steps:

- uses: actions/checkout@v4
with:
repository: ${{ inputs.repo || github.repository }}

- name: check for Azure drop NEURON_V1 -> ${{ env.NEURON_V1 }}
if: startsWith(env.NEURON_V1, 'https://dev.azure.com/neuronsimulator/')
run: |
# check URI
curl -sfSI -X GET '${{ env.NEURON_V1 }}'
# Download Azure drop and unzip
AZURE_DROP_URL="$NEURON_V1"
rm -rf drop
wget --tries=4 -LO DROP_V1.zip ${AZURE_DROP_URL}
unzip DROP_V1.zip
mv drop DROP_V1
# Set drop dir in the env
echo "DROP_DIR_V1=`pwd`/DROP_V1" >> $GITHUB_ENV
- name: check for Azure drop NEURON_V2 -> ${{ env.NEURON_V2 }}
if: startsWith(env.NEURON_V2, 'https://dev.azure.com/neuronsimulator/')
run: |
Expand All @@ -95,6 +94,38 @@ jobs:
# Set drop dir in the env
echo "DROP_DIR_V2=`pwd`/DROP_V2" >> $GITHUB_ENV
- name: check for artifact URL NEURON_V1 -> ${{ env.NEURON_V1 }}
if: startsWith(env.NEURON_V1, 'https://api.github.com/repos/neuronsimulator/')
run: |
# Download artifact and unzip
ARTIFACT_ID=$(echo "${NEURON_V1}" | grep --color=never -oE '[0-9]+$')
echo "Extracted Artifact ID: ${ARTIFACT_ID}"
curl -L -sfS \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.NRN_MODELDB_CI_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/neuronsimulator/nrn/actions/artifacts/${ARTIFACT_ID}/zip" -o DROP_V1.zip
unzip -d DROP_V1 DROP_V1.zip
# Set drop dir in the env
echo "DROP_DIR_V1=$(pwd)/DROP_V1" >> $GITHUB_ENV
- name: check for artifact URL NEURON_V2 -> ${{ env.NEURON_V2 }}
if: startsWith(env.NEURON_V2, 'https://api.github.com/repos/neuronsimulator/')
run: |
# Download artifact and unzip
ARTIFACT_ID=$(echo "${NEURON_V2}" | grep --color=never -oE '[0-9]+$')
echo "Extracted Artifact ID: ${ARTIFACT_ID}"
curl -L -sfS \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.NRN_MODELDB_CI_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/neuronsimulator/nrn/actions/artifacts/${ARTIFACT_ID}/zip" -o DROP_V2.zip
unzip -d DROP_V2 DROP_V2.zip
# Set drop dir in the env
echo "DROP_DIR_V2=$(pwd)/DROP_V2" >> $GITHUB_ENV
- uses: actions/setup-python@v5
with:
python-version: 3.9
Expand All @@ -103,7 +134,7 @@ jobs:
# For PRs we only have a few models for quick sanity checking.
# Once the PR is green you need to manually run the ModelDB CI workflow by simply selecting your branch in the UI.
# The follwing selection aims to target different features (since we haven't worked on unit testing yet -> #38 ).
# The following selection aims to target different features (since we haven't worked on unit testing yet -> #38 ).
# Select a few models to run CI for PRs:
# 64195 -> run: null
# 22203 -> skip: true
Expand All @@ -115,12 +146,12 @@ jobs:
echo 'MODELS_TO_RUN=64195 22203 156120 51781 97868 22203 97756 97917 105507 136803 138379 138382 146030 244679 251881' >> $GITHUB_ENV
# parse PR description for models to run
parse_models=$(gh pr view $PR_URL --json body -q '.body | capture("(MODELS_TO_RUN=)(?<models>\\d+( \\d+)*)")')
if [ ! -z "$parse_models" ]; then
echo "MODELS_TO_RUN=$(echo $parse_models | jq -r .models)" >> $GITHUB_ENV
fi
if: github.event_name == 'pull_request' && inputs.repo == ''
env:
PR_URL: ${{ github.event.pull_request.html_url }}
Expand All @@ -138,7 +169,7 @@ jobs:
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
#Install project in editable mode
python -m pip install -e .
- name: Cache ModelDB models
uses: actions/cache@v4
with:
Expand Down Expand Up @@ -169,7 +200,7 @@ jobs:
else
python -m pip install $NEURON_V1
fi
nrn_ver=`python -c "from neuron import __version__ as nrn_ver; print(nrn_ver)"`
nrn_ver="$(python -c "from neuron import __version__ as nrn_ver; print(nrn_ver)")"
runmodels --gout --workdir=$nrn_ver $MODELS_TO_RUN
# Filter out the gout data before generating HTML reports. The HTML
# diff uses the original gout files on disk anyway. Compress the large
Expand All @@ -183,7 +214,7 @@ jobs:
else
python -m pip uninstall --yes $NEURON_V1
fi
echo "nrn1_ver=$nrn_ver" >> $GITHUB_ENV
- name: Run Models with NEURON V2 -> ${{ env.NEURON_V2 }}
Expand All @@ -206,7 +237,7 @@ jobs:
else
python -m pip install $NEURON_V2
fi
nrn_ver=`python -c "from neuron import __version__ as nrn_ver; print(nrn_ver)"`
nrn_ver="$(python -c "from neuron import __version__ as nrn_ver; print(nrn_ver)")"
runmodels --gout --workdir=$nrn_ver $MODELS_TO_RUN
# Filter out the gout data before generating HTML reports. The HTML
# diff uses the original gout files on disk anyway. Compress the large
Expand Down

0 comments on commit f95b2b5

Please sign in to comment.