-
Notifications
You must be signed in to change notification settings - Fork 11
143 lines (122 loc) · 5.44 KB
/
Copy pathweekly-report.yml
File metadata and controls
143 lines (122 loc) · 5.44 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: Report
on:
schedule:
- cron: "0 9 * * 1" # Run every Monday at 9:00 AM UTC
workflow_dispatch: # Allow manual triggering
pull_request:
paths:
[
".github/workflows/weekly-report.yml",
"scripts/generate-binary-size-report.sh",
]
jobs:
current-main-size:
name: Current main branch binary size
runs-on: ubuntu-latest
container:
image: ghcr.io/dojoengine/katana-dev:latest
outputs:
size: ${{ steps.binary-size.outputs.size }}
commit: ${{ steps.binary-size.outputs.commit }}
branch: ${{ steps.binary-size.outputs.branch }}
steps:
- uses: actions/checkout@v4
with:
ref: main
submodules: recursive
# Workaround for https://github.com/actions/runner-images/issues/6775
- run: git config --global --add safe.directory "*"
- uses: Swatinem/rust-cache@v2
with:
key: weekly-binary-size-main
- name: Build contract artifacts
run: make contracts
- name: Get binary size (main)
id: binary-size
run: |
cargo build --bin katana --profile performance
BINARY_SIZE=$(stat --format %s ./target/performance/katana)
COMMIT_SHA=$(git rev-parse HEAD)
echo "size=$BINARY_SIZE" >> $GITHUB_OUTPUT
echo "commit=$COMMIT_SHA" >> $GITHUB_OUTPUT
echo "branch=main" >> $GITHUB_OUTPUT
latest-release-size:
name: Latest release binary size
runs-on: ubuntu-latest
container:
image: ghcr.io/dojoengine/katana-dev:latest
outputs:
size: ${{ steps.binary-size.outputs.size }}
tag: ${{ steps.binary-size.outputs.tag }}
branch: ${{ steps.binary-size.outputs.branch }}
env:
LATEST_RELEASE: ""
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
fetch-tags: true
# Workaround for https://github.com/actions/runner-images/issues/6775
- run: git config --global --add safe.directory "*"
- uses: Swatinem/rust-cache@v2
with:
key: weekly-binary-size-release
- name: Get latest release tag
run: |
LATEST_TAG=$(git tag --sort=-version:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' | head -1)
if [ -z "$LATEST_TAG" ]; then
echo "No release tags found"
exit 1
fi
echo "Latest release tag: $LATEST_TAG"
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
- name: Get binary size (latest release)
id: binary-size
run: |
echo "Latest release tag: $LATEST_TAG"
git checkout "$LATEST_TAG"
git submodule update --init --recursive
make contracts
cargo build --bin katana --profile performance
BINARY_SIZE=$(stat --format %s ./target/performance/katana)
echo "size=$BINARY_SIZE" >> $GITHUB_OUTPUT
echo "tag=$LATEST_TAG" >> $GITHUB_OUTPUT
echo "branch=$LATEST_TAG" >> $GITHUB_OUTPUT
generate-report:
name: Generate binary size report
needs: [current-main-size, latest-release-size]
runs-on: ubuntu-latest
container:
image: ghcr.io/dojoengine/katana-dev:latest
steps:
- uses: actions/checkout@v4
- run: git config --global --add safe.directory "*"
- name: Generate weekly binary size report
id: size-report
shell: bash
run: |
REPORT=$(./scripts/generate-binary-size-report.sh "${{ needs.latest-release-size.outputs.branch }}" ${{ needs.latest-release-size.outputs.size }} ${{ needs.current-main-size.outputs.size }} "${{ needs.current-main-size.outputs.commit }}")
echo "report<<EOF" >> $GITHUB_OUTPUT
echo "$REPORT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create issue with weekly report
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const title = `Weekly Binary Size Report - ${new Date().toISOString().split('T')[0]}`;
const body = `${{ steps.size-report.outputs.report }}`;
try {
const { data: issue } = await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: body,
labels: ['weekly-report', 'binary-size']
});
console.log(`Created weekly binary size report issue: ${issue.html_url}`);
} catch (error) {
console.error('Error creating weekly report issue:', error);
core.setFailed(`Failed to create weekly report issue: ${error.message}`);
}