Skip to content

Commit

Permalink
fix: test if that works :/
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra committed Jan 7, 2022
1 parent 30e7762 commit a58a31a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: cache bundle size
uses: actions/cache@v2
with:
path: stats.json
path: stats-${{ github.sha }}.json
key: stats-${{ github.sha }}

# upload to ipfs
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,19 @@ jobs:
- name: download cached bundle size
uses: actions/cache@v2
with:
path: stats_head.json
path: stats-${{ github.event.pull_request.base.sha }}.json
key: stats-${{ github.event.pull_request.base.sha }}

- name: store hash bundle size
uses: actions/cache@v2
with:
path: stats.json
path: stats-${{ github.sha }}.json
key: stats-${{ github.sha }}

- uses: actions/github-script@v5
env:
BASE: ${{ github.event.pull_request.base.sha }}
HEAD: ${{ github.sha }}
with:
script: |
const script = require('./scripts/compare-size')
Expand Down
31 changes: 14 additions & 17 deletions scripts/compare-size.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
const stats = require('../stats.json');
const headStats = require('../stats_head.json');

/**
* Whenever a pr is merged to master the ci will take a snapshot of the sourcemaps generated.
* When a pr is created or a commit is pushed the ci will:
Expand All @@ -14,22 +11,22 @@ const headStats = require('../stats_head.json');
* When the diff is >1kb, the ci will comment the bundle size difference.
*/
module.exports = async ({ github, context }) => {
if (context.eventName === 'pull_request') {
const masterMainChunk = headStats.results.find((chunk) => /js\/main/.test(chunk.bundleName));
const masterMB = masterMainChunk.totalBytes / 1024 / 1024;
const stats = require(`../stats-${process.env.HEAD}.json`);
const headStats = require(`../stats-${process.env.BASE}.json`);
const masterMainChunk = headStats.results.find((chunk) => /js\/main/.test(chunk.bundleName));
const masterMB = masterMainChunk.totalBytes / 1024 / 1024;

const currentMainChunk = stats.results.find((chunk) => /js\/main/.test(chunk.bundleName));
const currentMB = currentMainChunk.totalBytes / 1024 / 1024;
const currentMainChunk = stats.results.find((chunk) => /js\/main/.test(chunk.bundleName));
const currentMB = currentMainChunk.totalBytes / 1024 / 1024;

const diff = currentMB - masterMB;
const diff = currentMB - masterMB;

if (Math.abs(diff) > 0.001) {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Bundle size change: ${diff} MB`,
});
}
if (Math.abs(diff) > 0.001) {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Bundle size change: ${diff} MB`,
});
}
};

0 comments on commit a58a31a

Please sign in to comment.