mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
CI: Update breaking changes workflow to compare against main (#44097)
* ci(breaking-changes): split into separate builds for pr and main * ci(breaking-changes): add path for npm install steps * ci(breaking-changes): fix up workflow, update bash script
This commit is contained in:
151
.github/workflows/detect-breaking-changes-build.yml
vendored
151
.github/workflows/detect-breaking-changes-build.yml
vendored
@@ -3,27 +3,30 @@ name: Levitate / Detect breaking changes
|
|||||||
on: pull_request
|
on: pull_request
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
buildPR:
|
||||||
name: Detect
|
name: Build PR
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
defaults:
|
||||||
GITHUB_STEP_NUMBER: 7
|
run:
|
||||||
|
working-directory: './pr'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
path: './pr'
|
||||||
|
|
||||||
- name: Setup environment
|
- name: Get yarn cache directory path
|
||||||
uses: actions/setup-node@v2.5.1
|
id: yarn-cache-dir-path
|
||||||
|
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
|
||||||
|
|
||||||
|
- name: Restore yarn cache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
id: yarn-cache
|
||||||
with:
|
with:
|
||||||
node-version: '16'
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||||
|
key: yarn-cache-folder-${{ hashFiles('**/yarn.lock', '.yarnrc.yml') }}
|
||||||
- name: Get link for the Github Action job
|
restore-keys: |
|
||||||
id: job
|
yarn-cache-folder-
|
||||||
uses: actions/github-script@v5
|
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
const script = require('./.github/workflows/scripts/pr-get-job-link.js')
|
|
||||||
await script({github, context, core})
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn install --immutable
|
run: yarn install --immutable
|
||||||
@@ -31,24 +34,108 @@ jobs:
|
|||||||
- name: Build packages
|
- name: Build packages
|
||||||
run: yarn packages:build
|
run: yarn packages:build
|
||||||
|
|
||||||
- name: Detect breaking changes
|
- name: Zip built packages
|
||||||
id: breaking-changes
|
run: zip -r ./pr_built_packages.zip ./packages/**/dist
|
||||||
run: ./scripts/check-breaking-changes.sh
|
|
||||||
env:
|
|
||||||
FORCE_COLOR: 3
|
|
||||||
GITHUB_JOB_LINK: ${{ steps.job.outputs.link }}
|
|
||||||
|
|
||||||
- name: Persisting the check output
|
- name: Upload build output as artifact
|
||||||
run: |
|
|
||||||
mkdir -p ./levitate
|
|
||||||
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\" }" > ./levitate/result.json
|
|
||||||
|
|
||||||
- name: Upload check output as artifact
|
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: levitate
|
name: buildPr
|
||||||
path: levitate/
|
path: './pr/pr_built_packages.zip'
|
||||||
|
|
||||||
|
buildMain:
|
||||||
|
name: Build Main
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: './main'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
path: './main'
|
||||||
|
ref: 'main'
|
||||||
|
|
||||||
|
- name: Get yarn cache directory path
|
||||||
|
id: yarn-cache-dir-path
|
||||||
|
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
|
||||||
|
|
||||||
|
- name: Restore yarn cache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
id: yarn-cache
|
||||||
|
with:
|
||||||
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||||
|
key: yarn-cache-folder-${{ hashFiles('**/yarn.lock', '.yarnrc.yml') }}
|
||||||
|
restore-keys: |
|
||||||
|
yarn-cache-folder-
|
||||||
|
|
||||||
- name: Exit
|
- name: Install dependencies
|
||||||
run: exit ${{ steps.breaking-changes.outputs.is_breaking }}
|
run: yarn install --immutable
|
||||||
shell: bash
|
|
||||||
|
- name: Build packages
|
||||||
|
run: yarn packages:build
|
||||||
|
|
||||||
|
- name: Zip built packages
|
||||||
|
run: zip -r ./main_built_packages.zip ./packages/**/dist
|
||||||
|
|
||||||
|
- name: Upload build output as artifact
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: buildMain
|
||||||
|
path: './main/main_built_packages.zip'
|
||||||
|
|
||||||
|
Detect:
|
||||||
|
name: Detect breaking changes
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: ['buildPR', 'buildMain']
|
||||||
|
env:
|
||||||
|
GITHUB_STEP_NUMBER: 7
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Get built packages from pr
|
||||||
|
uses: actions/download-artifact@v2
|
||||||
|
with:
|
||||||
|
name: buildPr
|
||||||
|
|
||||||
|
- name: Get built packages from main
|
||||||
|
uses: actions/download-artifact@v2
|
||||||
|
with:
|
||||||
|
name: buildMain
|
||||||
|
|
||||||
|
- name: Unzip artifact from pr
|
||||||
|
run: unzip pr_built_packages.zip -d ./pr && rm pr_built_packages.zip
|
||||||
|
|
||||||
|
- name: Unzip artifact from main
|
||||||
|
run: unzip main_built_packages.zip -d ./main && rm main_built_packages.zip
|
||||||
|
|
||||||
|
- name: Get link for the Github Action job
|
||||||
|
id: job
|
||||||
|
uses: actions/github-script@v5
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const script = require('./.github/workflows/scripts/pr-get-job-link.js')
|
||||||
|
await script({github, context, core})
|
||||||
|
|
||||||
|
- name: Detect breaking changes
|
||||||
|
id: breaking-changes
|
||||||
|
run: ./scripts/check-breaking-changes.sh
|
||||||
|
env:
|
||||||
|
FORCE_COLOR: 3
|
||||||
|
GITHUB_JOB_LINK: ${{ steps.job.outputs.link }}
|
||||||
|
|
||||||
|
- name: Persisting the check output
|
||||||
|
run: |
|
||||||
|
mkdir -p ./levitate
|
||||||
|
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\" }" > ./levitate/result.json
|
||||||
|
|
||||||
|
- name: Upload check output as artifact
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: levitate
|
||||||
|
path: levitate/
|
||||||
|
|
||||||
|
- name: Exit
|
||||||
|
run: exit ${{ steps.breaking-changes.outputs.is_breaking }}
|
||||||
|
shell: bash
|
||||||
|
|||||||
@@ -1,32 +1,29 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Find existing packages using Lerna
|
# Find package directories
|
||||||
PACKAGES=$(lerna list -p -l)
|
PACKAGES=$(ls -d ./packages/*/)
|
||||||
EXIT_CODE=0
|
EXIT_CODE=0
|
||||||
GITHUB_MESSAGE=""
|
GITHUB_MESSAGE=""
|
||||||
|
|
||||||
# Loop through the packages
|
# Loop through the packages
|
||||||
while IFS= read -r line; do
|
while IFS=" " read -r -a package; do
|
||||||
|
|
||||||
# Read package info
|
# shellcheck disable=SC2128
|
||||||
IFS=':' read -ra ADDR <<< "$line"
|
PACKAGE_PATH=$(basename "$package")
|
||||||
PACKAGE_PATH="${ADDR[0]}"
|
|
||||||
PACKAGE_NAME="${ADDR[1]}"
|
|
||||||
|
|
||||||
# Calculate current and previous package paths / names
|
# Calculate current and previous package paths / names
|
||||||
PREV="$PACKAGE_NAME@canary"
|
PREV="./main/packages/$PACKAGE_PATH/dist/"
|
||||||
CURRENT="$PACKAGE_PATH/dist/"
|
CURRENT="./pr/packages/$PACKAGE_PATH/dist/"
|
||||||
|
|
||||||
# Temporarily skipping @grafana/toolkit, as it doesn't have any exposed static typing
|
# Temporarily skipping these packages as they don't have any exposed static typing
|
||||||
if [[ "$PACKAGE_NAME" == '@grafana/toolkit' ]]; then
|
if [[ "$PACKAGE_PATH" == 'grafana-toolkit' || "$PACKAGE_PATH" == 'jaeger-ui-components' ]]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Run the comparison and record the exit code
|
# Run the comparison and record the exit code
|
||||||
echo ""
|
echo ""
|
||||||
echo ""
|
echo ""
|
||||||
echo "${PACKAGE_NAME}"
|
echo "${PACKAGE_PATH}"
|
||||||
echo "================================================="
|
echo "================================================="
|
||||||
npm exec -- @grafana/levitate compare --prev "$PREV" --current "$CURRENT"
|
npm exec -- @grafana/levitate compare --prev "$PREV" --current "$CURRENT"
|
||||||
|
|
||||||
@@ -39,8 +36,8 @@ while IFS= read -r line; do
|
|||||||
if [ $STATUS -gt 0 ]
|
if [ $STATUS -gt 0 ]
|
||||||
then
|
then
|
||||||
EXIT_CODE=1
|
EXIT_CODE=1
|
||||||
GITHUB_MESSAGE="${GITHUB_MESSAGE}**\\\`${PACKAGE_NAME}\\\`** has possible breaking changes ([more info](${GITHUB_JOB_LINK}#step:${GITHUB_STEP_NUMBER}:1))<br />"
|
GITHUB_MESSAGE="${GITHUB_MESSAGE}**\\\`${PACKAGE_PATH}\\\`** has possible breaking changes ([more info](${GITHUB_JOB_LINK}#step:${GITHUB_STEP_NUMBER}:1))<br />"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done <<< "$PACKAGES"
|
done <<< "$PACKAGES"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user