test with slack mrkdown

pull/94550/head
Esteban Beltran 9 months ago
parent c872cad879
commit 7dbbcbb495
No known key found for this signature in database
  1. 25
      .github/workflows/detect-breaking-changes-levitate.yml
  2. 11
      packages/grafana-data/src/types/panel.ts
  3. 3
      scripts/check-breaking-changes.sh
  4. 31
      scripts/levitate-parse-json-report-to-mrkdwn.js

@ -234,6 +234,16 @@ jobs:
echo "levitate_markdown=No breaking changes detected" >> "$GITHUB_OUTPUT"
fi
if [ -f "levitate-mrkdwn.md" ]; then
{
echo 'levitate_mrkdwn<<EOF'
cat levitate-mrkdwn.md
echo EOF
} >> "$GITHUB_OUTPUT"
else
echo "levitate_mrkdwn=No breaking changes detected" >> "$GITHUB_OUTPUT"
fi
# Comment on the PR
- name: Comment on PR
@ -279,7 +289,7 @@ jobs:
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*grafana/grafana* repository has possible breaking changes"
"text": ":warning: *grafana/grafana* has possible breaking changes <${{ github.event.pull_request.html_url }}|#${{ github.event.pull_request.number }}> :warning:"
}
},
{
@ -287,11 +297,20 @@ jobs:
"fields": [
{
"type": "mrkdwn",
"text": "*PR:* <${{ github.event.pull_request.html_url }}|#${{ github.event.pull_request.number }}>"
"text": "*Go to PR:* <${{ github.event.pull_request.html_url }}|#${{ github.event.pull_request.number }}>"
},
{
"type": "mrkdwn",
"text": "*Job:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Job>"
"text": "*Go to Job:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Job>"
}
]
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "${{ steps.levitate-run.outputs.levitate_mrkdwn }}"
}
]
}

@ -102,9 +102,6 @@ export interface PanelProps<T = any> {
/** @internal */
renderCounter: number;
/** Panel title */
title: string;
/** Grafana EventBus */
eventBus: EventBus;
@ -154,13 +151,13 @@ export type PanelTypeChangedHandler<TOptions = any> = (
export type PanelOptionEditorsRegistry = Registry<PanelOptionsEditorItem>;
export interface PanelOptionsEditorProps<TValue> extends StandardEditorProps<TValue> {}
export interface PanelOptionsEditorProps<TValue> extends StandardEditorProps<TValue> { }
export interface PanelOptionsEditorItem<TOptions = any, TValue = any, TSettings = any>
extends OptionsEditorItem<TOptions, TSettings, PanelOptionsEditorProps<TValue>, TValue> {}
extends OptionsEditorItem<TOptions, TSettings, PanelOptionsEditorProps<TValue>, TValue> { }
export interface PanelOptionsEditorConfig<TOptions, TSettings = any, TValue = any>
extends OptionEditorConfig<TOptions, TSettings, TValue> {}
extends OptionEditorConfig<TOptions, TSettings, TValue> { }
/**
* @internal
@ -358,7 +355,7 @@ export class VisualizationSuggestionsListAppender<TOptions, TFieldConfig> {
constructor(
private list: VisualizationSuggestion[],
private defaults: VisualizationSuggestion<TOptions, TFieldConfig>
) {}
) { }
append(overrides: Partial<VisualizationSuggestion<TOptions, TFieldConfig>>) {
this.list.push(defaultsDeep(overrides, this.defaults));

@ -51,12 +51,14 @@ while IFS=" " read -r -a package; do
# Record the output, maybe with some additional information
STATUS=$?
CURRENT_REPORT=$(node ./scripts/levitate-parse-json-report.js)
CURRENT_REPORT_MRKDWN=$(node ./scripts/levitate-parse-json-report-to-mrkdwn.js)
# Final exit code
# (non-zero if any of the packages failed the checks)
if [ "$STATUS" -gt 0 ]; then
EXIT_CODE=1
GITHUB_MESSAGE="${GITHUB_MESSAGE}**\\\`${PACKAGE_PATH}\\\`** has possible breaking changes<br />"
GITHUB_LEVITATE_MARKDOWN+="<h3>${PACKAGE_PATH}</h3>${CURRENT_REPORT}<br>"
GITHUB_LEVITATE_MKRDWN+="##${PACKAGE_PATH}\n${CURRENT_REPORT_MRKDWN}\n"
fi
done <<<"$PACKAGES"
@ -66,6 +68,7 @@ echo "is_breaking=$EXIT_CODE" >>"$GITHUB_OUTPUT"
echo "message=$GITHUB_MESSAGE" >>"$GITHUB_OUTPUT"
mkdir -p ./levitate
echo "$GITHUB_LEVITATE_MARKDOWN" >./levitate/levitate.md
echo "$GITHUB_LEVITATE_MKRDWN" >./levitate/levitate-mrkdwn.md
# We will exit the workflow accordingly at another step
exit 0

@ -0,0 +1,31 @@
const fs = require('fs');
const data = JSON.parse(fs.readFileSync('data.json', 'utf8'));
function stripAnsi(str) {
return str.replace(/\x1b\[[0-9;]*m/g, '');
}
const printSection = (title, items) => {
let output = `#### ${title}\n\n`;
items.forEach((item) => {
const language = item.declaration ? 'typescript' : 'diff';
const code = item.declaration ? item.declaration : stripAnsi(item.diff);
output += `**${item.name}**\n\n`;
output += `${item.location}\n\n`;
output += `\`\`\`${language}\n${code}\n\`\`\`\n\n`;
});
return output;
};
let markdown = '';
if (data.removals.length > 0) {
markdown += printSection('Removals', data.removals);
}
if (data.changes.length > 0) {
markdown += printSection('Changes', data.changes);
}
console.log(markdown);
Loading…
Cancel
Save