From 758d346078e41bc238438116c022b1217e50c87b Mon Sep 17 00:00:00 2001 From: Kurdistan Tech Ministry Date: Sat, 3 Oct 2026 04:56:37 +0400 Subject: [PATCH] Make the Firefox source build reproducible, and let its check fail The diff step rebuilds the extension from master-ff-src.zip (the source archive AMO reviews) and compares the result with our build. It had never worked, which the removed continue-on-error was hiding: - The source zip left out .yarn/releases (yarnPath points there, so yarn could not start in the unpacked source) and scripts/ (build:ff runs scripts/postbuild-cleanup.cjs). Both are now included. - diff.sh used `[ a || b ]`, which is not valid test syntax, and piped `diff -qr` into `sort`, so the check exited 0 whatever diff found. It now goes by diff's own exit status; with a file altered it fails. - With those fixed, the builds still differed: webpack inlined import.meta.url from @pezkuwi/* packageInfo.js as the absolute file:// path of the build machine, which also put our build directory into the published extension. DefinePlugin now gives it a fixed value; it is only shown in duplicate-version warnings. Also fail-fast: false on the matrix. Without continue-on-error, the first red step cancelled the others, so their results were lost. Checked locally with node_modules as locked: "Builds are identical". --- .github/workflows/pr-any.yml | 2 ++ package.json | 4 ++-- packages/extension/webpack.shared.cjs | 6 ++++++ scripts/diff.sh | 26 +++++++------------------- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/.github/workflows/pr-any.yml b/.github/workflows/pr-any.yml index bd0c5e8..19444d2 100644 --- a/.github/workflows/pr-any.yml +++ b/.github/workflows/pr-any.yml @@ -4,6 +4,8 @@ on: [pull_request] jobs: pr: strategy: + # Each step reports on its own; one red step must not cancel the others. + fail-fast: false matrix: step: ['lint', 'test', 'build', diff] runs-on: ubuntu-latest diff --git a/package.json b/package.json index 0680b86..b8688be 100644 --- a/package.json +++ b/package.json @@ -35,8 +35,8 @@ "build:zip:dst:chrome": "rm -rf ./master-chrome-build.zip && cd packages/extension/build && zip -r -FS ../../../master-chrome-build.zip .", "build:zip:dst:ff": "rm -rf ./master-ff-build.zip && cd packages/extension/build && zip -r -FS ../../../master-ff-build.zip .", "build:zip:ff": "cp ./packages/extension/manifest_firefox.json ./packages/extension/manifest.json && cp ./packages/extension/manifest_firefox.json ./packages/extension/build/manifest.json && yarn build:zip:dst:ff && yarn build:zip:src:ff", - "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: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 .yarn/releases scripts", + "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 .yarn/releases scripts", "clean": "pezkuwi-dev-clean-build", "diff": "rm -rf ff-diff && sh ./scripts/diff.sh", "lint": "pezkuwi-dev-run-lint", diff --git a/packages/extension/webpack.shared.cjs b/packages/extension/webpack.shared.cjs index 4a04e37..636b29d 100644 --- a/packages/extension/webpack.shared.cjs +++ b/packages/extension/webpack.shared.cjs @@ -120,6 +120,12 @@ module.exports = (entry, alias = {}) => ({ resourceRegExp: /^\.\/locale$/ }), new webpack.DefinePlugin({ + // @pezkuwi/* packageInfo.js reads import.meta.url, which webpack would bake in as + // the absolute file:// path of the machine that built it. That leaks the build + // directory into the published extension and makes the Firefox source build + // (scripts/diff.sh, and AMO's own review) differ from ours. The value is only + // shown in duplicate-version warnings. + 'import.meta.url': JSON.stringify('file:///pezkuwi-extension/node_modules/'), 'process.env': { EXTENSION_PREFIX: JSON.stringify(process.env.EXTENSION_PREFIX || EXT_NAME), NODE_ENV: JSON.stringify('production'), diff --git a/scripts/diff.sh b/scripts/diff.sh index 29bd590..9474280 100644 --- a/scripts/diff.sh +++ b/scripts/diff.sh @@ -1,4 +1,4 @@ -# Copyright 2019-2025 @polkadot/extension-compat-metamask authors & contributors +# Copyright 2019-2026 @pezkuwi/extension authors & contributors # SPDX-License-Identifier: Apache-2.0 #!/bin/bash @@ -9,14 +9,15 @@ 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 + # diff's own exit status decides; piped into sort it was always 0, so builds + # that differed were reported as identical. + if diff -qr "$dir1" "$dir2"; then echo "Builds are identical" exit 0 else @@ -33,21 +34,8 @@ unzip_ff() { 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" - mv ./master-ff-src.zip ./master-ff-build.zip $FILE_PATH && cd $FILE_PATH +unzip_ff - 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 +compare_directories ./master-ff-build ./master-ff-src/packages/extension/build