chore: updates for 4.31 #459
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Sample Metrics | |
on: | |
pull_request: | |
types: [opened, reopened, synchronize, labeled, unlabeled] | |
branches: [main] | |
workflow_dispatch: | |
jobs: | |
analyze: | |
if: "!contains(github.event.pull_request.labels.*.name, 'draft') && github.actor!='dependabot-preview[bot]'" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.event.pull_request.head.ref }} | |
token: ${{ secrets.ESM_BUILD }} | |
- name: should create zip files | |
id: verify | |
run: | | |
# This step involves analyzing if any files changed in the branch, if so we'll create zip files | |
current_branch=$(git rev-parse --abbrev-ref HEAD) | |
# did any files change in component or core samples | |
# compare against version before the last commit in the branch | |
samples_changed=$(git diff --name-only "$current_branch" $(git merge-base "$current_branch" HEAD^) -- "./core-samples" "./component-samples") | |
if [ -z "$samples_changed" ]; then | |
echo "no samples changed, skipping creation of zip files" | |
echo "zipskip=true" >> $GITHUB_OUTPUT | |
else | |
echo "samples changed: $samples_changed" | |
echo "zipskip=false" >> $GITHUB_OUTPUT | |
fi | |
- name: should build samples | |
id: build | |
run: | | |
# This step involves analyzing the package.json files changed in the branch, if so we'll build the samples | |
current_branch=$(git rev-parse --abbrev-ref HEAD) | |
# package.json files changed in the branch | |
packages_changed=$(git diff --name-only "$current_branch" $(git merge-base "$current_branch" origin/main) -- "./core-samples/**/package.json") | |
# metric files changed in the previous commit | |
metrics_changed=$(git diff --name-only HEAD^ HEAD -- "./core-samples/.metrics/*.csv") | |
if [ -z "$packages_changed" ]; then | |
echo "no package.json files changed, skipping build analysis" | |
echo "skip=true" >> $GITHUB_OUTPUT | |
elif [ -n "$metrics_changed" ]; then | |
echo "metric files changed: $metrics_changed" | |
echo "the previous commit contained build metrics, skipping build analysis" | |
echo "skip=true" >> $GITHUB_OUTPUT | |
else | |
echo "package.json files changed: $packages_changed" | |
echo "analyzing builds" | |
echo "skip=false" >> $GITHUB_OUTPUT | |
fi | |
- name: setup node | |
if: steps.build.outputs.skip == 'false' || steps.verify.outputs.zipskip == 'false' | |
uses: actions/setup-node@v4 | |
with: | |
check-latest: true | |
- name: install dependencies for sample metrics script | |
if: steps.build.outputs.skip == 'false' || steps.verify.outputs.zipskip == 'false' | |
working-directory: .github/scripts | |
run: | | |
npm i | |
- name: Setup up git config | |
if: steps.build.outputs.skip == 'false' || steps.verify.outputs.zipskip == 'false' | |
run: | | |
git branch | |
git status | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
- name: create zip files | |
if: steps.verify.outputs.zipskip == 'false' | |
working-directory: .github/scripts | |
run: | | |
node create-zips.js | |
- name: commit zip files | |
if: steps.verify.outputs.zipskip == 'false' | |
working-directory: .github/scripts | |
run: | | |
git add ../../zips/ | |
git commit -m "ci: add zip files" || true | |
git push origin ${{ github.event.pull_request.head.ref }} | |
- name: run sample metrics script | |
if: steps.build.outputs.skip == 'false' | |
working-directory: .github/scripts | |
run: | | |
node analyze-builds.js | |
- name: push sample metrics analysis | |
if: steps.build.outputs.skip == 'false' | |
working-directory: .github/scripts | |
run: | | |
git add ../../core-samples/.metrics/*.csv | |
git status | |
git commit -m "ci: analyze core esm sample builds" || true | |
git push origin ${{ github.event.pull_request.head.ref }} | |
git status |