Skip to content

[GEOS] Define operational and HPC metrics #64

[GEOS] Define operational and HPC metrics

[GEOS] Define operational and HPC metrics #64

# Discover on demand
name: Discover CI On PR Comment
on:
issue_comment:
types: [created]
defaults:
run:
shell: bash
jobs:
bot:
runs-on: ubuntu-latest
if: ${{ github.event.issue.pull_request }}
outputs:
experiment-name: ${{ steps.experience.outputs.name }}
experiment-action: ${{ steps.experience.outputs.action }}
branch: ${{ steps.get-branch.outputs.branch }}
steps:
- name: Cancel job if needed
id: conditional-cancel
if: "!contains(github.event.comment.body, '/bot')"
shell: bash
run: |
gh run --repo $REPO cancel ${{ github.run_id }}
gh run --repo $REPO watch ${{ github.run_id }}
env:
REPO: ${{ github.repository }}
PR_NO: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Bot help
id: check
if: contains(github.event.comment.body, '/bot help')
shell: bash
run: |
gh pr comment $PR_NO --repo $REPO --body 'Bot commands:
/bot help
: Print this message
/bot experience --name=[per experiment.yaml] --action=[All, Validation, Benchmark]
: Triggers a geosongpu_dispatch command with given parameters'
gh run --repo $REPO cancel ${{ github.run_id }}
gh run --repo $REPO watch ${{ github.run_id }}
env:
REPO: ${{ github.repository }}
PR_NO: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Bot experience
id: experience
if: contains(github.event.comment.body, '/bot experience')
shell: bash
run: |
echo Launching Discover CI: ${{github.event.comment.body}}
BODY="${{github.event.comment.body}}"
EXP_NAME_DIRTY=${BODY#*--name=}
EXP_NAME=${EXP_NAME_DIRTY%% *}
echo "name=$EXP_NAME" >> "$GITHUB_OUTPUT"
EXP_ACTION_DIRTY=${BODY#*--action=}
EXP_ACTION=${EXP_ACTION_DIRTY%% *}
echo "action=$EXP_ACTION" >> "$GITHUB_OUTPUT"
gh pr comment $PR_NO --repo $REPO --body 'Discover experiment started 🚀:
Parameters: '"$EXP_NAME"' '"$EXP_ACTION"'
Url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
env:
REPO: ${{ github.repository }}
PR_NO: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Extract branch
id: 'get-branch'
run: |
BRANCH=$(gh pr view $PR_NO --repo $REPO --json headRefName --jq '.headRefName')
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
env:
REPO: ${{ github.repository }}
PR_NO: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run-discover-ondemand:
needs: bot
uses: GEOS-ESM/CI-workflows/.github/workflows/geosongpu-ondemand.yml@project/geosongpu
with:
experiment_name: ${{ needs.bot.outputs.experiment-name }}
experiment_action: ${{ needs.bot.outputs.experiment-action }}
geosongpu_ci_ref: ${{ needs.bot.outputs.branch }}
comment-results:
#Run the job everytime _but_ when upstream has been cancelled
if: success() || failure()
needs: [run-discover-ondemand, bot]
runs-on: ubuntu-latest
steps:
- name: Message success
if: ${{ needs.run-discover-ondemand.result == 'success' }}
shell: bash
run: |
gh pr comment $PR_NO --repo $REPO --body '✅ Successful discover experiment ${{ needs.bot.outputs.experiment-name }} @ ${{ needs.bot.outputs.experiment-action }}'
env:
REPO: ${{ github.repository }}
PR_NO: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Message failure
if: ${{ needs.run-discover-ondemand.result != 'success' }}
shell: bash
run: |
gh pr comment $PR_NO --repo $REPO --body '✅ Successful discover experiment ${{ needs.bot.outputs.experiment-name }} @ ${{ needs.bot.outputs.experiment-action }}'
env:
REPO: ${{ github.repository }}
PR_NO: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}