-
Notifications
You must be signed in to change notification settings - Fork 565
95 lines (95 loc) · 4.37 KB
/
analyze-builds.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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