Add CI script to check for diffs in src vs build for store release (#1429)

* Add CI script for diffs

* Cleanup

* Update github actions

* simplify

* echo

* cleanup

* fix

* "$RUNNER_OS" == "Linux"

* hack
This commit is contained in:
Tarik Gul 2024-07-31 10:16:24 -07:00 committed by GitHub
parent a62db1fe12
commit 1fab0828a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 58 additions and 1 deletions

View File

@ -6,7 +6,7 @@ jobs:
continue-on-error: true continue-on-error: true
strategy: strategy:
matrix: matrix:
step: ['lint', 'test', 'build'] step: ['lint', 'test', 'build', diff]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4

3
.gitignore vendored
View File

@ -30,3 +30,6 @@ docs/html
.idea .idea
.vscode .vscode
packages/extension/manifest.json packages/extension/manifest.json
# Diff script generates ff-diff
ff-diff

View File

@ -38,6 +38,7 @@
"build:zip:src:chrome": "rm -rf ./master-chrome-src.zip && zip -r -x '*build/*' -x '*node_modules*' -FS ./master-chrome-src.zip packages .editorconfig eslint.config.js rollup.config.js CHANGELOG.md CONTRIBUTING.md i18next-scanner.config.cjs LICENSE package.json README.md tsconfig.json yarn.lock .yarnrc.yml tsconfig.base.json tsconfig.build.json tsconfig.eslint.json tsconfig.webpack.json", "build:zip:src:chrome": "rm -rf ./master-chrome-src.zip && zip -r -x '*build/*' -x '*node_modules*' -FS ./master-chrome-src.zip packages .editorconfig eslint.config.js rollup.config.js CHANGELOG.md CONTRIBUTING.md i18next-scanner.config.cjs LICENSE package.json README.md tsconfig.json yarn.lock .yarnrc.yml tsconfig.base.json tsconfig.build.json tsconfig.eslint.json tsconfig.webpack.json",
"build:zip:src:ff": "rm -rf ./master-ff-src.zip && zip -r -x '*build/*' -x '*node_modules*' -FS ./master-ff-src.zip packages .editorconfig eslint.config.js rollup.config.js CHANGELOG.md CONTRIBUTING.md i18next-scanner.config.cjs LICENSE package.json README.md tsconfig.json yarn.lock .yarnrc.yml tsconfig.base.json tsconfig.build.json tsconfig.eslint.json tsconfig.webpack.json", "build:zip:src:ff": "rm -rf ./master-ff-src.zip && zip -r -x '*build/*' -x '*node_modules*' -FS ./master-ff-src.zip packages .editorconfig eslint.config.js rollup.config.js CHANGELOG.md CONTRIBUTING.md i18next-scanner.config.cjs LICENSE package.json README.md tsconfig.json yarn.lock .yarnrc.yml tsconfig.base.json tsconfig.build.json tsconfig.eslint.json tsconfig.webpack.json",
"clean": "polkadot-dev-clean-build", "clean": "polkadot-dev-clean-build",
"diff": "rm -rf ff-diff && sh ./scripts/diff.sh",
"lint": "polkadot-dev-run-lint", "lint": "polkadot-dev-run-lint",
"postinstall": "polkadot-dev-yarn-only", "postinstall": "polkadot-dev-yarn-only",
"test": "EXTENSION_PREFIX='test' polkadot-dev-run-test --loader ./packages/extension-mocks/src/loader-empty.js --env browser ^:.spec.tsx", "test": "EXTENSION_PREFIX='test' polkadot-dev-run-test --loader ./packages/extension-mocks/src/loader-empty.js --env browser ^:.spec.tsx",

53
scripts/diff.sh Normal file
View File

@ -0,0 +1,53 @@
# Copyright 2019-2024 @polkadot/extension-compat-metamask authors & contributors
# SPDX-License-Identifier: Apache-2.0
#!/bin/bash
# build firefox target
yarn build:ff
# Reorg the builds to
mkdir ff-diff
OS=$(uname)
FILE_PATH="./ff-diff"
compare_directories() {
local dir1=$1
local dir2=$2
if diff -qr "$dir1" "$dir2" | sort; then
echo "Builds are identical"
exit 0
else
echo "Builds are not identical"
exit 1
fi
}
unzip_ff() {
unzip -o master-ff-src.zip -d master-ff-src
unzip -o master-ff-build.zip -d master-ff-build
cd ./master-ff-src && yarn install && yarn build:ff && cd ..
}
if [ "$OS" == "Darwin" || "$RUNNER_OS" == "Linux" ]; then
echo "Running on macOS"
# macOS-specific commands go here
mv ./master-ff-src.zip ./master-ff-build.zip $FILE_PATH && cd $FILE_PATH
unzip_ff
compare_directories ./master-ff-build ./master-ff-src/packages/extension/build
else # Assuming it will be Linux
echo "Running on Linux"
# Linux-specific commands go here
mv -t $FILE_PATH ./master-ff-src.zip ./master-ff-build.zip && cd $FILE_PATH
unzip_ff
compare_directories ./master-ff-build ./master-ff-src/packages/extension/build
fi