Skip to content

Commit

Permalink
ci: Make an issue when ops are missing, instead of messaging slack (#92)
Browse files Browse the repository at this point in the history
The test now prints the diagnostics to `stdout`, so we can put it on the
issue body.

Requires the new `create-issue` workflow to be merged
(CQCL/hugrverse-actions#24).
  • Loading branch information
aborgna-q authored Nov 20, 2024
1 parent cbe79cf commit 2ce43f5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 25 deletions.
52 changes: 29 additions & 23 deletions .github/workflows/missing-ops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ jobs:
runs-on: ubuntu-latest
continue-on-error: true
outputs:
should_notify: ${{ steps.check_status.outputs.result }}
should_notify: ${{ steps.check_missing_optypes.outputs.fail }}
diagnostic: ${{ steps.check_missing_optypes.outputs.diagnostic }}
steps:
- uses: actions/checkout@v4
- uses: mozilla-actions/[email protected]
Expand All @@ -41,31 +42,36 @@ jobs:
enable-cache: true
- name: Run the missing op types test
id: check_missing_optypes
run: uv run -- cargo test --test integration -- --ignored missing_optypes
- name: Set output flags
id: check_status
if: always()
uses: actions/github-script@v7
with:
script: |
const outcome = ${{ steps.check_missing_optypes.outcome != 'success' }};
console.log(`The outcome is: ${outcome}`);
return outcome
result-encoding: string
run: |
set +e
uv run -- cargo test --test integration -- --ignored missing_optypes --nocapture --test-threads=1 > missing_optypes.txt
if [ $? -eq 0 ]; then
echo "The test passed."
echo "fail=false" >> $GITHUB_OUTPUT
else
echo "The test failed with error code $?."
echo
cat missing_optypes.txt
echo "fail=true" >> $GITHUB_OUTPUT
fi
echo "diagnostic=$(cat missing_optypes.txt)" >> $GITHUB_OUTPUT
notify-slack:
uses: CQCL/hugrverse-actions/.github/workflows/slack-notifier.yml@main
create-issue:
uses: CQCL/hugrverse-actions/.github/workflows/create-issue.yml@main
needs: missing-optypes
if: ${{ needs.missing-optypes.outputs.should_notify == 'true' && ( github.event_name == 'schedule' || github.event_name == 'push' ) }}
with:
channel-id: 'C040CRWH9FF'
slack-message: |
⚠️ `tket-json-rs` is missing OpType definitions.
See <https://github.com/CQCL/tket-json-rs/actions/runs/${{ github.run_id }}|the failing check> for more info.
# Rate-limit the message to once per week
timeout-minutes: 10080
# A repository variable used to store the last message timestamp.
timeout-variable: "MISSING_OPS_MSG_SENT"
title: "`tket-json-rs` is missing OpType definitions."
body: |
⚠️ `tket-json-rs` is missing OpType definitions.
```
$DIAGNOSTIC
```
See [https://github.com/CQCL/tket-json-rs/actions/runs/${{ github.run_id }}](the failing check) for more info.
unique-label: "missing-ops"
other-labels: "bug"
secrets:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
GITHUB_PAT: ${{ secrets.HUGRBOT_PAT }}
DIAGNOSTIC: ${{ needs.missing-optypes.outputs.diagnostic }}
6 changes: 4 additions & 2 deletions tests/missing_optypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ fn missing_optypes() -> PyResult<()> {
.fold(msg, |msg, s| msg + " - " + &s + "\n");
let msg =
msg + "Please add them to the `OpType` enum in `tket_json_rs/src/optype.rs`.\n";
panic!("{msg}");
println!("{msg}");
panic!("Found missing ops in `tket_json_rs`.");
}

Ok(())
Expand All @@ -79,7 +80,8 @@ fn missing_classical_optypes() -> PyResult<()> {
.fold(msg, |msg, s| msg + " - " + &s + "\n");
let msg =
msg + "Please add them to the `ClOp` enum in `tket_json_rs/src/clexpr/op.rs`.\n";
panic!("{msg}");
println!("{msg}");
panic!("Found missing classical ops in `tket_json_rs`.");
}

Ok(())
Expand Down

0 comments on commit 2ce43f5

Please sign in to comment.