mirror of
https://github.com/google/blockly.git
synced 2026-01-08 09:30:06 +01:00
Added script and workflow to automatically update build artifact sizes in check_metadata.sh
This commit is contained in:
39
.github/workflows/update_metadata.yml
vendored
Normal file
39
.github/workflows/update_metadata.yml
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
# This workflow updates the check_metadata.sh script, which compares the current
|
||||
# size of build artifacts against their size in the previous version of Blockly.
|
||||
|
||||
name: Update Metadata
|
||||
|
||||
on: [workflow_dispatch]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
node-version: [16.x]
|
||||
|
||||
steps:
|
||||
- name: Check Out Blockly
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: 'develop'
|
||||
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- name: Update Metadata
|
||||
run: source ./tests/scripts/update_metadata.sh
|
||||
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@9825ae65b1cb54b543b938503728b432a0176d29
|
||||
with:
|
||||
commit-message: Updated build artifact sizes in check_metadata.sh
|
||||
delete-branch: true
|
||||
title: Updated build artifact sizes in check_metadata.sh
|
||||
|
||||
- name: View Pull Request
|
||||
run: echo "View Pull Request - ${{ steps.cpr.outputs.pull-request-url }}"
|
||||
31
tests/scripts/update_metadata.sh
Executable file
31
tests/scripts/update_metadata.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Determines the size of generated files and updates check_metadata.sh to
|
||||
# reflect the new values.
|
||||
|
||||
blockly_size=$(wc -c < "blockly_compressed.js")
|
||||
blocks_size=$(wc -c < "blocks_compressed.js")
|
||||
blockly_gz_size=$(wc -c < "blockly_compressed.js.gz")
|
||||
blocks_gz_size=$(wc -c < "blocks_compressed.js.gz")
|
||||
quarter=$(date "+Q%q %Y")
|
||||
version=$(npx -c 'echo "$npm_package_version"')
|
||||
|
||||
replacement="# ${quarter}\t${version}\t${blockly_size}\n"
|
||||
replacement+="readonly BLOCKLY_SIZE_EXPECTED=${blockly_size}"
|
||||
sed -ri "s/readonly BLOCKLY_SIZE_EXPECTED=[0-9]+/${replacement}/g" \
|
||||
tests/scripts/check_metadata.sh
|
||||
|
||||
replacement="# ${quarter}\t${version}\t${blocks_size}\n"
|
||||
replacement+="readonly BLOCKS_SIZE_EXPECTED=${blocks_size}"
|
||||
sed -ri "s/readonly BLOCKS_SIZE_EXPECTED=[0-9]+/${replacement}/g" \
|
||||
tests/scripts/check_metadata.sh
|
||||
|
||||
replacement="# ${quarter}\t${version}\t${blockly_gz_size}\n"
|
||||
replacement+="readonly BLOCKLY_GZ_SIZE_EXPECTED=${blockly_gz_size}"
|
||||
sed -ri "s/readonly BLOCKLY_GZ_SIZE_EXPECTED=[0-9]+/${replacement}/g" \
|
||||
tests/scripts/check_metadata.sh
|
||||
|
||||
replacement="# ${quarter}\t${version}\t${blocks_gz_size}\n"
|
||||
replacement+="readonly BLOCKS_GZ_SIZE_EXPECTED=${blocks_gz_size}"
|
||||
sed -ri "s/readonly BLOCKS_GZ_SIZE_EXPECTED=[0-9]+/${replacement}/g" \
|
||||
tests/scripts/check_metadata.sh
|
||||
Reference in New Issue
Block a user