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: Make an issue when ops are missing, instead of messaging slack #92

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
54 changes: 30 additions & 24 deletions .github/workflows/missing-ops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,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 @@ -42,31 +43,36 @@ jobs:
run: poetry -C tests update
- name: Run the missing op types test
id: check_missing_optypes
run: poetry -C tests 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
poetry -C tests 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."
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be nice (though not essential) to include the names of the missing optypes in the issue title.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That requires a bit of piping and filtering the output of the test executable.
I'll make an issue so we can change it later.

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 }}
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 @@ -47,7 +47,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 @@ -74,7 +75,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
Loading