mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Levitate: fix markdown diff format (#81477)
* Add some fake breaking changes * try to generate another breaking chnage * Keep trying * Update levitate script * Add fake breaking changes * Use latest * Strip ansi * Test * Remove ansi stripping * ClearAnsi again * another regex * Revert some changes used for testing * Rename function * Fix indentation in levitate workflow * Remove test breaking changes * Remove breaking changes * Update actions * Trigger breaking change * restore file
This commit is contained in:
parent
86b16ea62a
commit
ea243b536c
@ -1,5 +1,5 @@
|
||||
# Only runs if anything under the packages/ directory changes.
|
||||
|
||||
---
|
||||
name: Levitate / Detect breaking changes in PR
|
||||
|
||||
on:
|
||||
@ -25,13 +25,12 @@ jobs:
|
||||
with:
|
||||
node-version: 20.9.0
|
||||
|
||||
|
||||
- name: Get yarn cache directory path
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Restore yarn cache
|
||||
uses: actions/cache@v3.3.1
|
||||
uses: actions/cache@v4
|
||||
id: yarn-cache
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
@ -52,7 +51,7 @@ jobs:
|
||||
run: zip -r ./pr_built_packages.zip ./packages/**/*.tgz
|
||||
|
||||
- name: Upload build output as artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: buildPr
|
||||
path: './pr/pr_built_packages.zip'
|
||||
@ -79,7 +78,7 @@ jobs:
|
||||
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Restore yarn cache
|
||||
uses: actions/cache@v3.3.1
|
||||
uses: actions/cache@v4
|
||||
id: yarn-cache
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
@ -100,7 +99,7 @@ jobs:
|
||||
run: zip -r ./base_built_packages.zip ./packages/**/*.tgz
|
||||
|
||||
- name: Upload build output as artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: buildBase
|
||||
path: './base/base_built_packages.zip'
|
||||
@ -114,14 +113,17 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20.9.0
|
||||
|
||||
- name: Get built packages from pr
|
||||
uses: actions/download-artifact@v3
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: buildPr
|
||||
|
||||
- name: Get built packages from base
|
||||
uses: actions/download-artifact@v3
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: buildBase
|
||||
|
||||
@ -153,7 +155,7 @@ jobs:
|
||||
echo "{ \"exit_code\": ${{ steps.breaking-changes.outputs.is_breaking }}, \"message\": \"${{ steps.breaking-changes.outputs.message }}\", \"job_link\": \"${{ steps.job.outputs.link }}#step:${GITHUB_STEP_NUMBER}:1\", \"pr_number\": \"${{ github.event.pull_request.number }}\" }" > ./levitate/result.json
|
||||
|
||||
- name: Upload check output as artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: levitate
|
||||
path: levitate/
|
||||
@ -175,7 +177,7 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: 'Download artifact'
|
||||
uses: actions/download-artifact@v3
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: levitate
|
||||
|
||||
@ -301,7 +303,7 @@ jobs:
|
||||
# This is very weird, the actual request goes through (comes back with a 201), but does not assign the team.
|
||||
# Related issue: https://github.com/renovatebot/renovate/issues/1908
|
||||
- name: Add "grafana/plugins-platform-frontend" as a reviewer
|
||||
if: steps.levitate-run.outputs.exit_code
|
||||
if: steps.levitate-run.outputs.exit_code == 1
|
||||
uses: actions/github-script@v6
|
||||
env:
|
||||
PR_NUMBER: ${{ steps.levitate-run.outputs.pr_number }}
|
||||
|
@ -30,9 +30,9 @@ while IFS=" " read -r -a package; do
|
||||
# Run the comparison and record the exit code
|
||||
echo ""
|
||||
echo ""
|
||||
echo "${PACKAGE_PATH}"
|
||||
echo "$PACKAGE_PATH"
|
||||
echo "================================================="
|
||||
npm exec -- @grafana/levitate compare --prev "$PREV" --current "$CURRENT" --json >data.json
|
||||
npm exec -- @grafana/levitate@latest compare --prev "$PREV" --current "$CURRENT" --json >data.json
|
||||
|
||||
# Check if the comparison returned with a non-zero exit code
|
||||
# Record the output, maybe with some additional information
|
||||
@ -40,7 +40,7 @@ while IFS=" " read -r -a package; do
|
||||
CURRENT_REPORT=$(node ./scripts/levitate-parse-json-report.js)
|
||||
# Final exit code
|
||||
# (non-zero if any of the packages failed the checks)
|
||||
if [ $STATUS -gt 0 ]; then
|
||||
if [ "$STATUS" -gt 0 ]; then
|
||||
EXIT_CODE=1
|
||||
GITHUB_MESSAGE="${GITHUB_MESSAGE}**\\\`${PACKAGE_PATH}\\\`** has possible breaking changes ([more info](${GITHUB_JOB_LINK}#step:${GITHUB_STEP_NUMBER}:1))<br />"
|
||||
GITHUB_LEVITATE_MARKDOWN+="<h3>${PACKAGE_PATH}</h3>${CURRENT_REPORT}<br>"
|
||||
@ -52,7 +52,7 @@ done <<<"$PACKAGES"
|
||||
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_MARKDOWN" >./levitate/levitate.md
|
||||
|
||||
# We will exit the workflow accordingly at another step
|
||||
exit 0
|
||||
|
@ -2,7 +2,9 @@ const fs = require('fs');
|
||||
|
||||
const data = JSON.parse(fs.readFileSync('data.json', 'utf8'));
|
||||
|
||||
const stripAnsi = (string) => string.replace(/\u001b\[.*?m/g, '');
|
||||
function stripAnsi(str) {
|
||||
return str.replace(/\x1b\[[0-9;]*m/g, '');
|
||||
}
|
||||
|
||||
const printSection = (title, items) => {
|
||||
let output = `<h4>${title}</h4>`;
|
||||
@ -10,9 +12,9 @@ const printSection = (title, items) => {
|
||||
const language = item.declaration ? 'typescript' : 'diff';
|
||||
const code = item.declaration ? item.declaration : stripAnsi(item.diff);
|
||||
|
||||
output += `<b>${item.name}</b><br>`;
|
||||
output += `<sub>${item.location}</sub><br>`;
|
||||
output += `<pre lang="${language}">${code}</pre><br>`;
|
||||
output += `<b>${item.name}</b><br>\n`;
|
||||
output += `<sub>${item.location}</sub><br>\n`;
|
||||
output += `<pre lang="${language}">\n${code}\n</pre><br>\n`;
|
||||
});
|
||||
return output;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user