Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/update_metadata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# 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:
update-metadata:
runs-on: ubuntu-latest

steps:
- name: Check Out Blockly
uses: actions/checkout@v2
with:
ref: 'develop'

- name: Use Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: 16.x

- name: Build Blockly
run: npm run build:compressed

- name: Build Blockly blocks
run: npm run build:blocks

- name: Update Metadata
run: source ./tests/scripts/update_metadata.sh

- name: Create Pull Request
uses: peter-evans/create-pull-request@9825ae65b1cb54b543b938503728b432a0176d29
with:
commit-message: Update build artifact sizes in check_metadata.sh
delete-branch: true
title: Update build artifact sizes in check_metadata.sh

- name: View Pull Request
run: echo "View Pull Request - ${{ steps.cpr.outputs.pull-request-url }}"
34 changes: 34 additions & 0 deletions tests/scripts/update_metadata.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# Determines the size of generated files and updates check_metadata.sh to
# reflect the new values.

gzip -k build/blockly_compressed.js
gzip -k build/blocks_compressed.js

blockly_size=$(wc -c < "build/blockly_compressed.js")
blocks_size=$(wc -c < "build/blocks_compressed.js")
blockly_gz_size=$(wc -c < "build/blockly_compressed.js.gz")
blocks_gz_size=$(wc -c < "build/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