-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (80 loc) · 3.64 KB
/
pr-build.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
name: Build and deploy PR
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20]
steps:
- uses: FranzDiebold/github-env-vars-action@v2
- uses: actions/checkout@v3
- name: Use Node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://npm.pkg.github.com'
scope: '@chili-publish'
- name: install dependencies
run: |
yarn install
env:
NODE_AUTH_TOKEN: ${{ secrets.PACKAGE_SECRET }}
- name: run license check
run: yarn validate-licenses
- name: run linting
run: yarn ci-lint
- name: run tests
run: yarn cover
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: coverage/**/*.xml
- name: build code
run: yarn build
- name: 'Comment on PR'
uses: actions/[email protected]
if: github.event_name == 'pull_request'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const formatBytes=(a, b = 2, k = 1024)=>{
with (Math) {
let d = floor(log(a) / log(k));
return 0 == a
? '0 Bytes'
: parseFloat((a / pow(k, d)).toFixed(max(0, b))) +
' ' +
['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'][d];
}
}
const fs = require("fs");
const stats = fs.statSync("./dist/bundle.js")
const fileSizeInBytes = stats.size;
const limit=1000000;
const getSizeDif = () => {
let sizeDif = 0;
if (limit > fileSizeInBytes) {
sizeDif = limit - fileSizeInBytes;
return `${formatBytes(sizeDif, 3)} less than limit`;
}
sizeDif = fileSizeInBytes - limit;
return `${formatBytes(sizeDif, 3)} more than limit`;
};
const formattedSize = formatBytes(stats.size,3);
const { issue: { number: issue_number }, repo: { owner, repo } } = context;
github.issues.createComment({ issue_number, owner, repo, body: 'PR bundle size is ' + formattedSize+ ' and ' +getSizeDif()+'.' });
- name: copy file branch
run: |
coveragePath=upload/coverage_reports/$CI_REF_NAME
buildPath=upload/pr_builds/$CI_REF_NAME
mkdir -p ${coveragePath%"/merge"}
mkdir -p ${buildPath%"/merge"}
cp -R coverage ${coveragePath%"/merge"}
cp -R dist/* ${buildPath%"/merge"}
- name: Copy to Azure Blob Storage
uses: azure/CLI@v1
with:
inlineScript: |
az storage blob upload-batch -d studio-ui -s upload/ --connection-string "${{ secrets.AZURE_CDN_STUDIO_DEV_CONNECTION_STRING }}" --overwrite true