Validate Web Console #30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Validate Web Console | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| validate: | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 45 | |
| steps: | |
| - name: Check out immutable Web Console source | |
| env: | |
| SOURCE_SHA: ${{ github.sha }} | |
| run: | | |
| set -euo pipefail | |
| git init . | |
| git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" | |
| git fetch --depth=1 origin "$SOURCE_SHA" | |
| git -c advice.detachedHead=false checkout --detach FETCH_HEAD | |
| test "$(git rev-parse HEAD)" = "$SOURCE_SHA" | |
| test -z "$(git status --short)" | |
| - name: Install pinned Node.js | |
| env: | |
| NODE_VERSION: 24.18.0 | |
| NODE_ARCHIVE_SHA256: 55aa7153f9d88f28d765fcdad5ae6945b5c0f98a36881703817e4c450fa76742 | |
| run: | | |
| set -euo pipefail | |
| archive="$RUNNER_TEMP/node.tar.xz" | |
| curl \ | |
| --proto '=https' \ | |
| --tlsv1.2 \ | |
| --fail \ | |
| --silent \ | |
| --show-error \ | |
| --location \ | |
| --retry 5 \ | |
| --retry-all-errors \ | |
| --retry-delay 2 \ | |
| -o "$archive" \ | |
| "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz" | |
| printf '%s %s\n' "$NODE_ARCHIVE_SHA256" "$archive" | | |
| sha256sum --check | |
| mkdir -p "$RUNNER_TEMP/node" | |
| tar -xJf "$archive" --strip-components=1 -C "$RUNNER_TEMP/node" | |
| echo "$RUNNER_TEMP/node/bin" >>"$GITHUB_PATH" | |
| - name: Test and build twice | |
| id: build | |
| env: | |
| PASTURESTACK_NODE24_IMAGE: node:24.18.0-bookworm@sha256:5711a0d445a1af54af9589066c646df387d1831a608226f4cd694fc59e745059 | |
| UI_COMPATIBILITY_VERSION: 1.6.56 | |
| run: | | |
| set -euo pipefail | |
| test "$(node --version)" = v24.18.0 | |
| npm ci --ignore-scripts --no-audit --no-fund | |
| bash scripts/ci | |
| source_date_epoch=$(git show -s --format=%ct "$GITHUB_SHA") | |
| export SOURCE_DATE_EPOCH="$source_date_epoch" | |
| work_root=$(mktemp -d) | |
| cleanup() { | |
| rm -rf "$work_root" | |
| } | |
| trap cleanup EXIT | |
| build_candidate() { | |
| output=$1 | |
| rm -rf dist | |
| ./node_modules/.bin/ember build --environment production | |
| bash scripts/package-static-candidate \ | |
| "$UI_COMPATIBILITY_VERSION" \ | |
| dist \ | |
| "$output" | |
| } | |
| build_candidate "$work_root/web-console-a.tar.gz" | |
| build_candidate "$work_root/web-console-b.tar.gz" | |
| cmp "$work_root/web-console-a.tar.gz" "$work_root/web-console-b.tar.gz" | |
| artifact_sha=$(sha256sum "$work_root/web-console-a.tar.gz" | awk '{print $1}') | |
| test "$(tar -tzf "$work_root/web-console-a.tar.gz" | | |
| grep -Ec "^${UI_COMPATIBILITY_VERSION}/translations/zh-tw\\.json$")" -eq 1 | |
| if tar -tzf "$work_root/web-console-a.tar.gz" | grep -Eq '\.map$'; then | |
| echo WEB_CONSOLE_SOURCE_MAP_PRESENT >&2 | |
| exit 1 | |
| fi | |
| printf 'WEB_CONSOLE_VALIDATION_OK source=%s package=%s compatibility=%s sha256=%s\n' \ | |
| "$GITHUB_SHA" \ | |
| "$(node -p 'require("./package.json").version')" \ | |
| "$UI_COMPATIBILITY_VERSION" \ | |
| "$artifact_sha" | |
| package_version=$(node -p 'require("./package.json").version') | |
| release_asset="$RUNNER_TEMP/web-console-${package_version}.tar.gz" | |
| cp "$work_root/web-console-a.tar.gz" "$release_asset" | |
| sha256sum "$release_asset" >"${release_asset}.sha256" | |
| printf 'package_version=%s\nrelease_asset=%s\n' \ | |
| "$package_version" "$release_asset" >>"$GITHUB_OUTPUT" | |
| - name: Retain reviewed candidate for release | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: web-console-${{ steps.build.outputs.package_version }} | |
| path: | | |
| ${{ steps.build.outputs.release_asset }} | |
| ${{ steps.build.outputs.release_asset }}.sha256 | |
| if-no-files-found: error | |
| retention-days: 30 | |
| compression-level: 0 |