From d3d358c879c0bc0513a2e1d8f04eca153e4f9fff Mon Sep 17 00:00:00 2001 From: "Joshua J. Berry" Date: Mon, 2 Sep 2024 12:08:18 -0400 Subject: [PATCH] Test the release-build process; install the correct Node version - Add a GitHub action to test the release-build process and make sure we don't introduce any reproducibility issues in a new change. - Show what's different in console output if the release build fails for reproducibility reasons (to make troubleshooting easier in GHA). - Fail install-deps.sh if the already-installed Node version is too old. --- .github/workflows/ci.yml | 4 +-- .github/workflows/test-release-build.yml | 32 ++++++++++++++++++++++++ Makefile | 13 +++++++--- install-deps.sh | 3 +++ 4 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/test-release-build.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce1e0f5d..f320b310 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,12 +12,12 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Install Dependencies - run: sh ./install-deps.sh - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 with: node-version: 20.x + - name: Install Dependencies + run: sh ./install-deps.sh - name: Install Node Modules run: make node_modules - name: Check Types diff --git a/.github/workflows/test-release-build.yml b/.github/workflows/test-release-build.yml new file mode 100644 index 00000000..403905d1 --- /dev/null +++ b/.github/workflows/test-release-build.yml @@ -0,0 +1,32 @@ +name: test-release-build + +on: + push: + branches: + - master + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: 20.x + - name: Install Dependencies + run: sh ./install-deps.sh + - name: Make a Temporary Version Number (if needed) + run: | + if [ -z "$(git tag --points-at=HEAD)" ]; then + node -e "x=`cat assets/manifest.json`; x.version='9999.99.9999'; console.log(JSON.stringify(x))" >assets/manifest.json.new + mv assets/manifest.json.new assets/manifest.json + make fix-style + git config --global user.name "GitHub Actions" + git config --global user.email "nobody@example.com" + git commit -m 'Make a temporary version number' assets/manifest.json + fi + - name: Try Building Release Artifacts + run: make rel diff --git a/Makefile b/Makefile index b0ac7b54..e6745958 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,13 @@ rel: rel-inner: $(MAKE) pkg-webext pkg-source $(MAKE) -C $(RELEASE_DIR)/$(SRCPKG_DIR) release-tag pkg-webext pkg-source - [ -z "$$(diff -Nru dist $(RELEASE_DIR)/$(SRCPKG_DIR)/dist)" ] + @if [ ! -z "$$(diff -Nru dist $(RELEASE_DIR)/$(SRCPKG_DIR)/dist)" ]; then \ + diff -Nru dist $(RELEASE_DIR)/$(SRCPKG_DIR)/dist; \ + echo "!!!" >&2; \ + echo "!!! Build did not reproduce correctly; check diff output above" >&2; \ + echo "!!!" >&2; \ + exit 1; \ + fi rm -rf $(RELEASE_DIR)/$(SRCPKG_DIR) @echo "" @echo "Ready for release $(VERSION)!" @@ -198,8 +204,9 @@ site: ## Cleanup distclean: clean - rm -rf node_modules $(RELEASE_DIR)/$(SRCPKG_DIR) $(SRC_PKG) $(DIST_PKG) - rm -rf docs/vendor + rm -rf node_modules docs/vendor \ + $(RELEASE_DIR)/$(SRCPKG_DIR) $(SRC_PKG) $(DIST_PKG) \ + releases/*-dirty* releases/*-dev* .PHONY: distclean clean: diff --git a/install-deps.sh b/install-deps.sh index 6069430a..a0c3836e 100755 --- a/install-deps.sh +++ b/install-deps.sh @@ -44,6 +44,9 @@ deps_apt() { sudo apt-get update sudo apt-get install -y nodejs + + elif [ "$(node --version |cut -c2-3)" -lt $NODE_VERSION ]; then + die "Please upgrade Node.js to v$NODE_VERSION or later (you have $(node --version))." fi }