.github: bump slack notify to v3; enhance linter notifications#22196
.github: bump slack notify to v3; enhance linter notifications#22196
Conversation
| xmllint --xpath "//error/@severity" checkstyle-result.xml | \ | ||
| tr ' ' '\n' | \ | ||
| sed 's/severity="//;s/"//' | \ | ||
| sort | uniq -c | sort -nr | \ |
There was a problem hiding this comment.
This was AI generated - maybe there is a cleaner way with pure xmllint?
4a0fdfd to
29d30f7
Compare
|
✅ No conflicts with other open PRs targeting |
| payload: | | ||
| channel: ${{ secrets.SLACK_TEAM_CORE_CHANNEL_ID}} | ||
| text: "golangci-lint failed (${{ matrix.modules }}): <${{ format('https://github.com/{0}/actions/runs/{1}', github.repository, github.run_id) }}|Run> - <${{ steps.golang-lint.outputs.golang-report-artifact-url }}|Report>" | ||
| text: "golangci-lint failed (${{ matrix.modules }}): <${{ format('https://github.com/{0}/actions/runs/{1}', github.repository, github.run_id) }}|Run> - <${{ steps.golang-lint.outputs.golang-report-artifact-url }}|Report>\n${{ steps.golang-lint.outputs.golang-report-file-count }} files with ${{ steps.golang-lint.outputs.golang-report-issue-count }} issues.\nBy severity: $${{ steps.golang-lint.outputs.golang-report-per-severity-count }}\nBy linter: ${{ steps.golang-lint.outputs.golang-report-per-source-count }}" |
There was a problem hiding this comment.
There is probably a more elegant way to format this message via structured json or whatever.
There was a problem hiding this comment.
What we've done before is to build the message in its own step and then include the body as a payload like: https://github.com/smartcontractkit/.github/blob/main/actions/slack-notify-git-ref/action.yml#L152
|
| cat ./${{ steps.set-working-directory.outputs.golangci-lint-working-directory }}golangci-lint-report.xml | ||
| echo "file-count=$( xmllint --xpath "count(//file)" checkstyle-result.xml )" >> $GITHUB_OUTPUT |
There was a problem hiding this comment.
| cat ./${{ steps.set-working-directory.outputs.golangci-lint-working-directory }}golangci-lint-report.xml | |
| echo "file-count=$( xmllint --xpath "count(//file)" checkstyle-result.xml )" >> $GITHUB_OUTPUT | |
| cat "./${GOLANG_CI_LINT_DIR}golangci-lint-report.xml" | |
| echo "file-count=$( xmllint --xpath "count(//file)" checkstyle-result.xml )" | tee -a "$GITHUB_OUTPUT" |
Would always avoid the template inclusion in bash. Instead you can add it to an env within the step like:
env:
GOLANG_CI_LINT_DIR: ${{ steps.set-working-directory.outputs.golangci-lint-working-directory }}This mitigates template injection. Even for values that we control, it's probably worth doing by default.
Also, this is a nit but would suggest redirecting outputs to tee so we can see them in the GHA logs.
| cat ./${{ steps.set-working-directory.outputs.golangci-lint-working-directory }}golangci-lint-report.xml | ||
| echo "file-count=$( xmllint --xpath "count(//file)" checkstyle-result.xml )" >> $GITHUB_OUTPUT |
There was a problem hiding this comment.
Is xmllint installed on these runners by default?
I don't see it here: https://github.com/search?q=repo%3Aactions%2Frunner-images%20xmllint&type=code
There was a problem hiding this comment.
Oh did gemini lie to me? 🤦
There was a problem hiding this comment.
Should we just output a different format, like JSON? I think we can do multiple, right? So it wouldn't have to be disruptive
There was a problem hiding this comment.
I like using JSON output since we have the native tools on the runner 👍
| payload: | | ||
| channel: ${{ secrets.SLACK_TEAM_CORE_CHANNEL_ID}} | ||
| text: "golangci-lint failed (${{ matrix.modules }}): <${{ format('https://github.com/{0}/actions/runs/{1}', github.repository, github.run_id) }}|Run> - <${{ steps.golang-lint.outputs.golang-report-artifact-url }}|Report>" | ||
| text: "golangci-lint failed (${{ matrix.modules }}): <${{ format('https://github.com/{0}/actions/runs/{1}', github.repository, github.run_id) }}|Run> - <${{ steps.golang-lint.outputs.golang-report-artifact-url }}|Report>\n${{ steps.golang-lint.outputs.golang-report-file-count }} files with ${{ steps.golang-lint.outputs.golang-report-issue-count }} issues.\nBy severity: $${{ steps.golang-lint.outputs.golang-report-per-severity-count }}\nBy linter: ${{ steps.golang-lint.outputs.golang-report-per-source-count }}" |
There was a problem hiding this comment.
What we've done before is to build the message in its own step and then include the body as a payload like: https://github.com/smartcontractkit/.github/blob/main/actions/slack-notify-git-ref/action.yml#L152





No description provided.