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 Notify on failure #453

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

CI Notify on failure #453

wants to merge 12 commits into from

Conversation

csgui
Copy link
Collaborator

@csgui csgui commented Jul 29, 2024

Add a job to notify @stacks-network/clarity-wasm team when property testing has failed.

We can also have a Slack integration as a compliment to the automated issue. To be handled in other PR, if the case.

Issue generated as a test: #455

wileyj
wileyj previously approved these changes Jul 29, 2024
Copy link

@wileyj wileyj left a comment

Choose a reason for hiding this comment

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

lgtm

@csgui csgui requested a review from obycode July 30, 2024 16:13
obycode
obycode previously approved these changes Jul 30, 2024
Copy link
Collaborator

@obycode obycode left a comment

Choose a reason for hiding this comment

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

Looks good to me, with a little uncertainty on official policy on third party actions -- @wileyj?

@obycode
Copy link
Collaborator

obycode commented Jul 30, 2024

Looks good to me, with a little uncertainty on official policy on third party actions -- @wileyj?

I reviewed the source of that action and it doesn't look like it tries to do anything fishy. Can we lock in that specific version to ensure it remains safe? I remember @wileyj looked at this situation before.

@wileyj
Copy link

wileyj commented Jul 30, 2024

Looks good to me, with a little uncertainty on official policy on third party actions -- @wileyj?

I reviewed the source of that action and it doesn't look like it tries to do anything fishy. Can we lock in that specific version to ensure it remains safe? I remember @wileyj looked at this situation before.

it all depends really - for the stacks-core repo, we lock any external actions to a specific hash vs a version.
there's no official policy/process - but in general we consider the potential blast radius if an external workflow may behave badly in the future.

on occasion, we've forked actions (usually in the case of unclear maintainer) or simply re-implemented ourselves.
if you think there could be security concerns, we do have a repo: stacks-network/actions we could add anything as a composite action - but again, it's really subjective based on what we think the possible issues may be with a malicious workflow.
example of where we use a hash for an external action: https://github.com/stacks-network/actions/blob/main/stacks-core/cache/build-cache/action.yml#L47

and another where we emulated what an external workflow was doing: https://github.com/stacks-network/actions/blob/main/cleanup/workflows/action.yml

tl;dr: it depends.

@obycode
Copy link
Collaborator

obycode commented Jul 30, 2024

I think the main concern would be that a rogue action has access to the secrets and then can do bad things with the Github token, so it's better to be safe.

@obycode
Copy link
Collaborator

obycode commented Jul 30, 2024

I like the idea of adding the hash to ensure this version does not change.

@wileyj
Copy link

wileyj commented Jul 30, 2024

I think the main concern would be that a rogue action has access to the secrets and then can do bad things with the Github token, so it's better to be safe.

indeed - let me look into this a little bit. right now, the workflow is using the org secret, but we can set a new repo secret that is better scoped (i.e. only allow an workflow to create an issue).

however, a lot of the ACL's we'd really like to use are only available for gh enterprise

@wileyj
Copy link

wileyj commented Jul 30, 2024

i think adding something like this to the workflow would be best: https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs

you may also try using the secrets.GITHUB_TOKEN which is created for the duration of the worklfow (presumably on behalf of the calling actor), and destroyed after the workflow is complete.

if using an external workflow makes you nervous here, there are options to roll your own to create an issue (curl or the gh tool would both work here):
https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow

In order to get the message to Slack feature working there needs to be created two secrets, one with the respective SlackBot token with chat:write permission and the other one with the channel_id where the message is going to be sent.
@csgui csgui marked this pull request as ready for review November 5, 2024 18:23
Comment on lines 48 to 59
- name: Create GitHub Issue on Failure
uses: jayqi/failed-build-issue-action@v1
if: ${{ failure() }}
with:
github-token: ${{ secrets.GH_TOKEN }}
label-name: "property-testing-failure"
title-template: "Property testing failure"
body-template: |
GitHub Actions workflow [{{workflow}} #{{runNumber}}](https://github.com/{{repo.owner}}/{{repo.repo}}/actions/runs/{{runId}}) Clarity::V${{ matrix.clarity_version }} failed.
```log
${{ env.failure_section }}
```
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@BowTiedWoo Can we use ${{ secrets.GITHUB_TOKEN }} instead of ${{ secrets.GH_TOKEN }}? GITHUB_TOKEN seems more secure and is automatically created for workflow use, with permissions configured directly in the workflow settings.

Can we simplify this by using the GitHub CLI command gh issue create instead of a third-party action for that purpose?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I removed the third party action and it's now using gh issue create for creating the issue.

@aldur aldur requested review from BowTiedWoo and removed request for BowTiedWoo November 14, 2024 14:33
Copy link
Collaborator

@obycode obycode left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants