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

[mimir-rules-action] fix multiline output expression #9051

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

rasta-rocket
Copy link
Contributor

Signed-off-by: rasta-rocket [email protected]

What this PR does

Hey folks 👋

Small PR that fix/simplify the way the multiline is rendered in the output of the action mimir-rules-action

With the following pipeline:

name: mimir_rules_ci
on:
  workflow_dispatch:
  pull_request:
jobs:
  mimir_rules:
    name: Check Mimir Rules
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Check Mimir rules
        uses: rasta-rocket/mimir/operations/mimir-rules-action@action_mimirtool_fix_multiline
        env:
          MIMIR_ADDRESS: "XXXXX"
          MIMIR_TENANT_ID: XXXXX
          ACTION: check
          RULES_DIR: "./mimir/alert,./mimir/record"
      - name: Diff Mimir rules
        id: diff_rules
        uses: rasta-rocket/mimir/operations/mimir-rules-action@action_mimirtool_fix_multiline
        env:
          MIMIR_ADDRESS: "XXXXX"
          MIMIR_TENANT_ID: XXXXX
          ACTION: diff
          RULES_DIR: "./mimir/alert,./mimir/record"
      - name: Put diff in summary
        run: |
           echo "${{ steps.diff_rules.outputs.detailed }}"

           echo '# Diff summary' >> $GITHUB_STEP_SUMMARY
           echo '```diff' >> $GITHUB_STEP_SUMMARY
           echo "${{ steps.diff_rules.outputs.detailed }}" >> $GITHUB_STEP_SUMMARY
           echo '```' >> $GITHUB_STEP_SUMMARY

This has been done following : https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-of-a-multiline-string

Don't hesitate to ping me if any remarks/questions 😉 ?

Cheers ☀️

Which issue(s) this PR fixes or relates to

Fixes #

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • about-versioning.md updated with experimental features.

@rasta-rocket rasta-rocket requested a review from a team as a code owner August 19, 2024 17:29
@CLAassistant
Copy link

CLAassistant commented Aug 19, 2024

CLA assistant check
All committers have signed the CLA.

@rasta-rocket rasta-rocket force-pushed the action_mimirtool_fix_multiline branch from 8e16c06 to 3ceb051 Compare November 20, 2024 17:11
@rasta-rocket
Copy link
Contributor Author

@56quarters 👋

I'm trying my luck with you to get a review on this 😅

@armandgrillet armandgrillet requested a review from colega December 18, 2024 14:19
Copy link
Contributor

@colega colega left a comment

Choose a reason for hiding this comment

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

Thank you! Sorry for such a long delay for the review.

@@ -106,8 +106,7 @@ case "${ACTION}" in
;;
esac

SINGLE_LINE_OUTPUT=$(echo "${OUTPUT}" | awk 'BEGIN { RS="%0A" } { gsub(/%/, "%25"); gsub(/\r/, "%0D"); gsub(/\n/, "%0A") } { print }')
echo "detailed=${SINGLE_LINE_OUTPUT}" >> "${GITHUB_OUTPUT}"
{ echo "detailed<<EOF"; echo "$OUTPUT"; echo "EOF"; } >> "$GITHUB_OUTPUT"
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand that there can't be any collision between "$OUTPUT" and "EOF", as "$OUTPUT" would need to be exactly "EOF" and I can't see that being an option for the $OUTPUT.

@colega colega enabled auto-merge (squash) December 18, 2024 15:23
@colega colega disabled auto-merge December 18, 2024 15:23
@colega
Copy link
Contributor

colega commented Dec 19, 2024

I'm trying to merge this but for some reason the CI won't run, can I ask you to rebase this on latest main and force-push? (Edit: figured out, I didn't see the CI approval button because I was trying "the new merge experience" feature in Github)

@colega colega merged commit 7fa48db into grafana:main Dec 19, 2024
29 checks passed
@rasta-rocket
Copy link
Contributor Author

@colega sorry for the late answer and thanks a lot for the review 🚀

Any chance you can do a review on a similar PR: grafana/cortex-rules-action#27 ?

@colega
Copy link
Contributor

colega commented Dec 24, 2024

Reviewed, thanks!

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.

3 participants