Skip to content

Commit

Permalink
Use warning message instead of throw
Browse files Browse the repository at this point in the history
  • Loading branch information
wasanx25 committed Mar 12, 2022
1 parent 3192910 commit 393d0a3
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions .github/workflows/check-bundle-diff.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Check Bundle Diff

on: [ push ]
on: [ pull_request ]

jobs:
master-bundle:
Expand Down Expand Up @@ -58,25 +58,32 @@ jobs:
name: stats
- run: wbd diff webpack-stats.json webpack-stats-base.json -o output.json
- name: Check bundle diff
run: |
const fs = require('fs');
fs.readFile('output.json', (err, data) => {
if (err) {
throw err
}

const stats = JSON.parse(data)
for (let key in stats) {
let stat = stats[key]
if (!Array.isArray(stat['added']) || !Array.isArray(stat['removed']) || !Array.isArray(stat['changed'])) {
throw new Error(`Why stats of this key is not Array? added: ${stat['added']}, removed: ${stat['removed']}, changed: ${stat['changed']}`)
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
let bundle_diff = false
fs.readFile('output.json', (err, data) => {
if (err) {
throw err
}
const stats = JSON.parse(data)
for (let key in stats) {
let stat = stats[key]
if (!Array.isArray(stat['added']) || !Array.isArray(stat['removed']) || !Array.isArray(stat['changed'])) {
throw new Error(`Why stats of this key is not Array? added: ${stat['added']}, removed: ${stat['removed']}, changed: ${stat['changed']}`)
}
if (stat['delta'] || stat['added'].length > 0 || stat['removed'].length > 0 || stat['changed'].length > 0) {
throw new Error('this artifact is different from HEAD')
if (stat['delta'] || stat['added'].length > 0 || stat['removed'].length > 0 || stat['changed'].length > 0) {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '⚠️ this artifact is different from HEAD'
})
break
}
}
}
})
shell: node {0}

})

0 comments on commit 393d0a3

Please sign in to comment.