diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 00000000..639821e1 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,240 @@ +--- +name: Deploy + +# Builds here and deploys the result to Vercel. The Git integration is off for this project +# (`git.deploymentEnabled: false` in vercel.json), so this workflow is what deploys it. +# +# chore/all-my-stuffs goes to production. Every pull request gets a preview, linked from the +# PR's "View deployment" button through the GitHub environment set on the job. +# +# Setup: VERCEL_TOKEN, VERCEL_ORG_ID and VERCEL_PROJECT_ID as secrets, on the repository or on +# the Production and Preview environments. Optionally the VERCEL_PRODUCTION_URL repository +# variable (e.g. https://it-tools.example.com/): production builds generate sitemap.xml and +# robots.txt for it, and without it they are left out. +# +# Replaces sharevb-vercel-preview.yml and sharevb-vercel-prod.yml, which deployed the same two +# targets without a concurrency group or a GitHub environment. One deployment per burst of +# pushes keeps Vercel's daily deployment and upload caps, and Deployment Storage, in check. +permissions: + contents: read + +on: + push: + branches: + - chore/all-my-stuffs + pull_request: + workflow_dispatch: + +concurrency: + # Per ref, cancelling in progress: pushing three times in a minute should cost one + # deployment, not three. Production is grouped per ref too, so a rapid merge sequence + # collapses the same way. + group: deploy-${{ github.ref }} + cancel-in-progress: true + +jobs: + deploy: + # Same-repository events only. GitHub withholds secrets from `pull_request` runs on forks, + # so a fork would fail the credentials check on every push — and more to the point, this + # job runs the checked-out branch's build scripts with VERCEL_TOKEN in the environment. + # That is fine for branches in this repository, whose authors already have the secrets, and + # is not something to offer an arbitrary fork. + if: >- + github.event_name != 'pull_request' || + github.event.pull_request.head.repo.full_name == github.repository + runs-on: ubuntu-26.04-arm + timeout-minutes: 15 + # Records a GitHub Deployment per run, which is what puts the Environments sidebar, the + # "deployed to Preview" PR timeline entry and its "View deployment" button back — the parts + # of the Vercel Git integration lost when building moved here. The names match the + # environments that integration created, so their history carries on. The condition has to + # be restated rather than read from the `target` step: the environment is fixed before any + # step runs. `url` is evaluated at the end, so it can use the deploy step's output. + environment: + name: >- + ${{ github.ref == 'refs/heads/chore/all-my-stuffs' && github.event_name != 'pull_request' + && 'Production' || 'Preview' }} + url: ${{ steps.deploy.outputs.url }} + permissions: + contents: read + steps: + - name: Fail early if the Vercel credentials are missing + env: + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + run: | + set -euo pipefail + missing="" + for name in VERCEL_TOKEN VERCEL_ORG_ID VERCEL_PROJECT_ID; do + [ -z "${!name}" ] && missing="$missing $name" + done + if [ -n "$missing" ]; then + # Either place works, so name both rather than send anyone to the wrong settings + # page. + echo "::error::Missing secrets:$missing — set them on the repository (Settings > Secrets and variables > Actions) or on the Production and Preview environments (Settings > Environments). See .github/workflows/deploy.yaml" + exit 1 + fi + + - name: Checkout repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + # On pull requests, the exact commit that triggered the run, not GitHub's detached + # merge commit: this builds the PR's own head, as Vercel's Git integration did. + # Pinned to the event's SHA rather than the branch name, so a push that lands while + # this run is queued, or a re-run of an old run, can't deploy a different commit + # under this run's deployment. Empty on push and workflow_dispatch, which keeps the + # default ref. + ref: ${{ github.event.pull_request.head.sha }} + + # The Vercel CLI reads the deployment's branch and commit message from git. A detached + # checkout shows up in Vercel as branch "HEAD", so name the commit after the PR branch. + - name: Name the checked-out commit after the PR branch + if: github.event_name == 'pull_request' + env: + # From the environment, not interpolated: branch names can contain shell + # metacharacters. + HEAD_REF: ${{ github.head_ref }} + run: git checkout -B "$HEAD_REF" + + - uses: pnpm/setup@fbda4c85fc2e1e08721cd8763afea8f48d60f024 # v3.0.0 + with: + cache: true + + - name: Install Vercel CLI + # Into a scratch directory outside the repository, not globally: `pnpm add --global` + # needs a global bin directory that `pnpm/setup` does not configure, and it failed + # immediately on the first run with the secrets in place. Installing here also keeps + # package.json and the lockfile untouched, so the tree the build sees is the tree that + # was committed. + # + # Pinned: an unpinned CLI changes how this workflow builds and deploys with no commit + # here to explain it. + run: | + set -euo pipefail + mkdir -p "$RUNNER_TEMP/vercel-cli" + cd "$RUNNER_TEMP/vercel-cli" + pnpm init >/dev/null + # Build approvals as config rather than --allow-build flags, matching how the + # repository declares its own. This directory is outside the repository so it + # inherits nothing; both packages that run install scripts are named here. esbuild + # is the one that actually needs it — a transitive dependency of the CLI whose + # postinstall links its native binary. + # + # minimumReleaseAge is deliberately not set: pnpm's built-in default is already + # 1440 minutes, so restating it would only create a second place to keep in sync. + printf 'allowBuilds:\n vercel: true\n esbuild: true\n' > pnpm-workspace.yaml + pnpm add vercel@60.1.3 + echo "$RUNNER_TEMP/vercel-cli/node_modules/.bin" >> "$GITHUB_PATH" + + # Environment is decided once and reused, so the pull, the build and the deploy cannot + # disagree about which one they are targeting. + - name: Resolve target environment + id: target + env: + # Read from the environment, not interpolated into the script. workflow_dispatch can + # run on any branch, and a branch name containing shell metacharacters would + # otherwise be pasted straight into this `if` as source. + REF: ${{ github.ref }} + EVENT: ${{ github.event_name }} + PRODUCTION_URL: ${{ vars.VERCEL_PRODUCTION_URL }} + run: | + set -euo pipefail + if [ "$REF" = "refs/heads/chore/all-my-stuffs" ] && [ "$EVENT" != "pull_request" ]; then + { + echo "environment=production" + echo "prod_flag=--prod" + echo "hostname=$PRODUCTION_URL" + } >> "$GITHUB_OUTPUT" + else + { + echo "environment=preview" + echo "prod_flag=" + # No sitemap or robots.txt for previews: they would advertise the preview URL. + echo "hostname=" + } >> "$GITHUB_OUTPUT" + fi + + - name: Pull Vercel project settings + env: + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + run: | + set -euo pipefail + # The link is written out rather than left to the CLI to infer from environment + # variables. Relying on VERCEL_ORG_ID/VERCEL_PROJECT_ID alone failed here with + # "Could not retrieve Project Settings", and which variables a given CLI version + # honours is not something to guess at from a workflow. This file is exactly what + # `vercel link` produces, so the CLI has nothing left to work out. + mkdir -p .vercel + # printf rather than a heredoc: a heredoc's terminator has to sit at column zero, + # which it cannot inside an indented YAML block, and %s keeps the ids out of the + # shell's word splitting. + printf '{"projectId":"%s","orgId":"%s"}\n' "$VERCEL_PROJECT_ID" "$VERCEL_ORG_ID" \ + > .vercel/project.json + # Shape only — the ids are secrets and are not printed. + python3 -c "import json;d=json.load(open('.vercel/project.json'));print('link written, keys:', sorted(d))" + vercel pull --yes \ + --environment="${{ steps.target.outputs.environment }}" \ + --token="$VERCEL_TOKEN" + + - name: Build + env: + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + # What sharevb-vercel-*.yml set, kept so the build is the same: + # VITE_VERCEL_ENV is the env label the app reports (src/config.ts), and + # VITE_VERCEL_DEPLOY turns off full PWA precaching (vite.config.ts). + VITE_VERCEL_ENV: ${{ steps.target.outputs.environment }} + VITE_VERCEL_DEPLOY: true + # HOSTNAME is what vite.config.ts generates sitemap.xml and robots.txt from, so it is + # set for production only, from the VERCEL_PRODUCTION_URL repository variable. + HOSTNAME: ${{ steps.target.outputs.hostname }} + run: | + set -euo pipefail + vercel build ${{ steps.target.outputs.prod_flag }} --token="$VERCEL_TOKEN" + # A build that produces nothing would otherwise deploy an empty site over a working + # one. Checked before anything is uploaded. + test -s .vercel/output/static/index.html || { + echo "::error::Build produced no .vercel/output/static/index.html — refusing to deploy" + exit 1 + } + + - name: Deploy + id: deploy + env: + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + run: | + set -euo pipefail + # --archive=tgz uploads the output as one archive instead of file by file. The Hobby + # plan caps CLI uploads at 5000 files a day across the whole account + # ("api-upload-free"), and per-file uploads hit that after a busy + # day of deploys. + url=$(vercel deploy --prebuilt --archive=tgz ${{ steps.target.outputs.prod_flag }} --token="$VERCEL_TOKEN") + # `vercel deploy` prints the URL on stdout and progress on stderr, so this is the URL + # and nothing else. Empty means the deploy did not produce one, which is a failure + # even if the CLI exited 0. + [ -n "$url" ] || { echo "::error::Deploy returned no URL"; exit 1; } + echo "url=$url" >> "$GITHUB_OUTPUT" + echo "Deployed to $url" + + - name: Summary + if: always() + env: + ENVIRONMENT: ${{ steps.target.outputs.environment }} + URL: ${{ steps.deploy.outputs.url }} + STATUS: ${{ job.status }} + run: | + { + echo "### Deploy" + echo "" + if [ "$STATUS" = "success" ]; then + echo "Deployed to **$ENVIRONMENT**: $URL" + else + echo "**Deploy failed.** See the failing step above." + fi + } >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/sharevb-ci.yml b/.github/workflows/sharevb-ci.yml index ca2ff0e4..d2c9e87c 100644 --- a/.github/workflows/sharevb-ci.yml +++ b/.github/workflows/sharevb-ci.yml @@ -6,28 +6,37 @@ on: branches: - chore/all-my-stuffs +concurrency: + # A new push supersedes the previous run on the same ref, so a burst of pushes + # costs one run instead of one per push. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: ci: - runs-on: ubuntu-latest + runs-on: ubuntu-26.04-arm steps: - - uses: actions/checkout@v7.0.0 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Setup pnpm and install dependencies - uses: pnpm/setup@v2.0.2 + uses: pnpm/setup@fbda4c85fc2e1e08721cd8763afea8f48d60f024 # v3.0.0 with: cache: true - - name: Check formatting - run: pnpm fmt:check + # The checks are independent of each other, so they share the runner + # instead of queueing behind one another. The build is the long pole. + - parallel: + - name: Check formatting + run: pnpm fmt:check - - name: Run linters - run: pnpm lint + - name: Run linters + run: pnpm lint - - name: Run unit test - run: pnpm test:unit + - name: Run unit test + run: pnpm test:unit - - name: Type check - run: pnpm typecheck + - name: Type check + run: pnpm typecheck - - name: Build the app - run: pnpm build + - name: Build the app + run: pnpm build diff --git a/.github/workflows/sharevb-codeql-analysis.yml b/.github/workflows/sharevb-codeql-analysis.yml index fbd16877..e34ca9ff 100644 --- a/.github/workflows/sharevb-codeql-analysis.yml +++ b/.github/workflows/sharevb-codeql-analysis.yml @@ -21,7 +21,9 @@ on: jobs: analyze: name: Analyze - runs-on: ubuntu-latest + # x64 on purpose: the x64 runner image ships the CodeQL bundle in its tool + # cache, the arm64 image does not, so arm would download it on every run. + runs-on: ubuntu-26.04 permissions: actions: read contents: read @@ -37,11 +39,9 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v7.0.0 - - # Initializes the CodeQL tools for scanning. + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Initialize CodeQL - uses: github/codeql-action/init@v4.36.3 + uses: github/codeql-action/init@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -55,9 +55,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v4.36.3 - - # ℹ️ Command-line programs to run using the OS shell. + uses: github/codeql-action/autobuild@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2 # 📚 https://git.io/JvXDl # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines @@ -69,4 +67,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v4.36.3 + uses: github/codeql-action/analyze@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2 diff --git a/.github/workflows/sharevb-docker-nightly-release.yml b/.github/workflows/sharevb-docker-nightly-release.yml index c84ca79d..a0d162ee 100644 --- a/.github/workflows/sharevb-docker-nightly-release.yml +++ b/.github/workflows/sharevb-docker-nightly-release.yml @@ -10,12 +10,12 @@ on: jobs: check_date: - runs-on: ubuntu-latest + runs-on: ubuntu-26.04-arm name: Check latest commit outputs: should_run: ${{ steps.should_run.outputs.should_run }} steps: - - uses: actions/checkout@v7.0.0 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: print latest_commit run: echo ${{ github.sha }} @@ -26,14 +26,14 @@ jobs: run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "::set-output name=should_run::false" ci: - runs-on: ubuntu-latest + runs-on: ubuntu-26.04-arm needs: check_date if: ${{ needs.check_date.outputs.should_run != 'false' }} steps: - - uses: actions/checkout@v7.0.0 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Setup pnpm and install dependencies - uses: pnpm/setup@v2.0.2 + uses: pnpm/setup@fbda4c85fc2e1e08721cd8763afea8f48d60f024 # v3.0.0 with: cache: true @@ -50,14 +50,14 @@ jobs: run: pnpm build build: - runs-on: ubuntu-latest + runs-on: ubuntu-26.04-arm needs: - ci steps: - name: Docker meta id: meta - uses: docker/metadata-action@v6.2.0 + uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 with: images: sharevb/it-tools labels: | @@ -65,29 +65,29 @@ jobs: # Checkout the repository - name: Checkout repository - uses: actions/checkout@v7.0.0 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Login to Docker Hub - uses: docker/login-action@v4.4.0 + uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to GitHub Container Registry - uses: docker/login-action@v4.4.0 + uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Set up QEMU - uses: docker/setup-qemu-action@v4.2.0 + uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v4.2.0 + uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 - name: Build and push - uses: docker/build-push-action@v7.3.0 + uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 with: context: . file: ./Dockerfile @@ -103,17 +103,17 @@ jobs: run: docker logout ghcr.io github-release: - runs-on: ubuntu-latest + runs-on: ubuntu-26.04-arm needs: ci steps: - name: Set release version to nightly run: echo "RELEASE_VERSION=nightly" >> $GITHUB_ENV - name: Checkout - uses: actions/checkout@v7.0.0 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Setup pnpm and install dependencies - uses: pnpm/setup@v2.0.2 + uses: pnpm/setup@fbda4c85fc2e1e08721cd8763afea8f48d60f024 # v3.0.0 with: cache: true @@ -132,7 +132,7 @@ jobs: echo "$EOF" >> $GITHUB_OUTPUT - name: Create Release - uses: softprops/action-gh-release@v3.0.1 + uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3 with: token: ${{ secrets.GITHUB_TOKEN }} files: it-tools-${{ env.RELEASE_VERSION }}.zip diff --git a/.github/workflows/sharevb-docker-realease-baseurl-it-tools.yml b/.github/workflows/sharevb-docker-realease-baseurl-it-tools.yml index c27140c4..599cf7a2 100644 --- a/.github/workflows/sharevb-docker-realease-baseurl-it-tools.yml +++ b/.github/workflows/sharevb-docker-realease-baseurl-it-tools.yml @@ -8,42 +8,35 @@ name: Build and Push Docker Image (baseurl-it-tools) env: VITE_VERCEL_ENV: production +# Runs after the ci workflow passes on a push to the default branch, rather than +# repeating its lint, tests, typecheck and build here: the image build compiles +# the app anyway, and ci is what decides whether this commit is fit to publish. on: - push: + workflow_run: + workflows: [ci] + types: [completed] branches: - chore/all-my-stuffs +concurrency: + # One publish at a time, newest wins: without this, an older run that finishes + # last would overwrite the tags with an older commit. ci cancels its own + # superseded runs, so these runs arrive in commit order and cancelling the + # older one always leaves the newest commit published. + group: ${{ github.workflow }} + cancel-in-progress: true + jobs: - ci: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v7.0.0 - - name: Setup pnpm and install dependencies - uses: pnpm/setup@v2.0.2 - with: - cache: true - - - name: Run linters - run: pnpm lint - - - name: Run unit tests - run: pnpm test:unit - - - name: Type check - run: pnpm typecheck - - - name: Build the app - run: pnpm build - build: - runs-on: ubuntu-latest - needs: - - ci + # Only a successful ci run for a push; a pull request's run must never publish. + if: >- + github.event.workflow_run.conclusion == 'success' && + github.event.workflow_run.event == 'push' + runs-on: ubuntu-26.04-arm steps: - name: Docker meta id: meta - uses: docker/metadata-action@v6.2.0 + uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 with: images: sharevb/it-tools labels: | @@ -51,29 +44,32 @@ jobs: # Checkout the repository - name: Checkout repository - uses: actions/checkout@v7.0.0 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + # The commit ci tested, not whatever the branch points at by now. + ref: ${{ github.event.workflow_run.head_sha }} - name: Login to Docker Hub - uses: docker/login-action@v4.4.0 + uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to GitHub Container Registry - uses: docker/login-action@v4.4.0 + uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Set up QEMU - uses: docker/setup-qemu-action@v4.2.0 + uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v4.2.0 + uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 - name: Build and push (BASE_URL) - uses: docker/build-push-action@v7.3.0 + uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 with: context: . file: ./Dockerfile diff --git a/.github/workflows/sharevb-docker-realease-latest.yml b/.github/workflows/sharevb-docker-realease-latest.yml index c6f1b943..bcff7aea 100644 --- a/.github/workflows/sharevb-docker-realease-latest.yml +++ b/.github/workflows/sharevb-docker-realease-latest.yml @@ -3,45 +3,38 @@ name: Build and Push Docker Image (latest) env: VITE_VERCEL_ENV: production +# Runs after the ci workflow passes on a push to the default branch, rather than +# repeating its lint, tests, typecheck and build here: the image build compiles +# the app anyway, and ci is what decides whether this commit is fit to publish. on: - push: + workflow_run: + workflows: [ci] + types: [completed] branches: - chore/all-my-stuffs +concurrency: + # One publish at a time, newest wins: without this, an older run that finishes + # last would overwrite the tags with an older commit. ci cancels its own + # superseded runs, so these runs arrive in commit order and cancelling the + # older one always leaves the newest commit published. + group: ${{ github.workflow }} + cancel-in-progress: true + jobs: - ci: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v7.0.0 - - name: Setup pnpm and install dependencies - uses: pnpm/setup@v2.0.2 - with: - cache: true - - - name: Run linters - run: pnpm lint - - - name: Run unit tests - run: pnpm test:unit - - - name: Type check - run: pnpm typecheck - - - name: Build the app - run: pnpm build - build: - runs-on: ubuntu-latest - needs: - - ci + # Only a successful ci run for a push; a pull request's run must never publish. + if: >- + github.event.workflow_run.conclusion == 'success' && + github.event.workflow_run.event == 'push' + runs-on: ubuntu-26.04-arm strategy: matrix: language: ['', 'en'] steps: - name: Docker meta id: meta - uses: docker/metadata-action@v6.2.0 + uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 with: images: sharevb/it-tools labels: | @@ -49,29 +42,32 @@ jobs: # Checkout the repository - name: Checkout repository - uses: actions/checkout@v7.0.0 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + # The commit ci tested, not whatever the branch points at by now. + ref: ${{ github.event.workflow_run.head_sha }} - name: Login to Docker Hub - uses: docker/login-action@v4.4.0 + uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to GitHub Container Registry - uses: docker/login-action@v4.4.0 + uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Set up QEMU - uses: docker/setup-qemu-action@v4.2.0 + uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v4.2.0 + uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 - name: Build and push - uses: docker/build-push-action@v7.3.0 + uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 with: context: . file: ./Dockerfile diff --git a/.github/workflows/sharevb-e2e-tests.yml b/.github/workflows/sharevb-e2e-tests.yml index d00c46cd..07e2215a 100644 --- a/.github/workflows/sharevb-e2e-tests.yml +++ b/.github/workflows/sharevb-e2e-tests.yml @@ -4,11 +4,42 @@ on: push: branches: - chore/all-my-stuffs + +concurrency: + # A new push supersedes the previous run on the same ref, so a burst of pushes + # costs one run instead of one per push. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: + # Built once and shared: the build output is the same for every browser, so + # each test job downloads it instead of spending a minute rebuilding it. + build: + runs-on: ubuntu-26.04-arm + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Setup pnpm and install dependencies + uses: pnpm/setup@fbda4c85fc2e1e08721cd8763afea8f48d60f024 # v3.0.0 + with: + cache: true + + - name: Build app + run: pnpm build + + - name: Upload build output + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: dist + path: dist + if-no-files-found: error + retention-days: 1 + test: + needs: build name: test (${{ matrix.browser }}) timeout-minutes: 120 - runs-on: ubuntu-latest + runs-on: ubuntu-26.04-arm strategy: # Always report every browser, rather than cancelling the rest on the # first failure. @@ -16,10 +47,10 @@ jobs: matrix: browser: [chromium, firefox, webkit] steps: - - uses: actions/checkout@v7.0.0 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Setup pnpm and install dependencies - uses: pnpm/setup@v2.0.2 + uses: pnpm/setup@fbda4c85fc2e1e08721cd8763afea8f48d60f024 # v3.0.0 with: cache: true @@ -30,17 +61,20 @@ jobs: # cached browsers out of sync with Playwright. run: echo "PLAYWRIGHT_VERSION=$(jq -r .version node_modules/@playwright/test/package.json)" >> "$GITHUB_OUTPUT" - - name: Build app - run: pnpm build + - name: Download build output + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: dist + path: dist - name: Restore Playwright browsers from cache - uses: actions/cache@v6.1.0 + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: ~/.cache/ms-playwright - key: ${{ runner.os }}-playwright-${{ matrix.browser }}-${{ steps.playwright-version.outputs.PLAYWRIGHT_VERSION }}-${{ hashFiles('**/playwright.config.ts') }} + key: ${{ runner.os }}-${{ runner.arch }}-playwright-${{ matrix.browser }}-${{ steps.playwright-version.outputs.PLAYWRIGHT_VERSION }}-${{ hashFiles('**/playwright.config.ts') }} restore-keys: | - ${{ runner.os }}-playwright-${{ matrix.browser }}-${{ steps.playwright-version.outputs.PLAYWRIGHT_VERSION }}- - ${{ runner.os }}-playwright-${{ matrix.browser }}- + ${{ runner.os }}-${{ runner.arch }}-playwright-${{ matrix.browser }}-${{ steps.playwright-version.outputs.PLAYWRIGHT_VERSION }}- + ${{ runner.os }}-${{ runner.arch }}-playwright-${{ matrix.browser }}- - name: Install Playwright Browsers run: pnpm exec playwright install --with-deps ${{ matrix.browser }} diff --git a/.github/workflows/sharevb-github-pages-publish.yml b/.github/workflows/sharevb-github-pages-publish.yml index c325ebc4..18ee3c7f 100644 --- a/.github/workflows/sharevb-github-pages-publish.yml +++ b/.github/workflows/sharevb-github-pages-publish.yml @@ -29,13 +29,13 @@ jobs: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest + runs-on: ubuntu-26.04-arm steps: - name: Checkout - uses: actions/checkout@v7.0.0 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Setup pnpm and install dependencies - uses: pnpm/setup@v2.0.2 + uses: pnpm/setup@fbda4c85fc2e1e08721cd8763afea8f48d60f024 # v3.0.0 with: cache: true @@ -50,13 +50,13 @@ jobs: BASE_URL="/it-tools/" pnpm build cp dist/index.html dist/404.html - name: Setup Pages - uses: actions/configure-pages@v6.0.0 + uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0 - name: Upload artifact - uses: actions/upload-pages-artifact@v5.0.0 + uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0 with: path: './dist' - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v5.0.0 \ No newline at end of file + uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1 \ No newline at end of file diff --git a/.github/workflows/sharevb-releases.yml b/.github/workflows/sharevb-releases.yml index c81e6414..29214b06 100644 --- a/.github/workflows/sharevb-releases.yml +++ b/.github/workflows/sharevb-releases.yml @@ -10,11 +10,11 @@ on: jobs: docker-release: - runs-on: ubuntu-latest + runs-on: ubuntu-26.04-arm steps: - name: Docker meta id: meta - uses: docker/metadata-action@v6.2.0 + uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 with: images: sharevb/it-tools @@ -22,29 +22,29 @@ jobs: run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV - name: Checkout - uses: actions/checkout@v7.0.0 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Login to Docker Hub - uses: docker/login-action@v4.4.0 + uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to GitHub Container Registry - uses: docker/login-action@v4.4.0 + uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Set up QEMU - uses: docker/setup-qemu-action@v4.2.0 + uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v4.2.0 + uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 - name: Build and push (BASE_URL) - uses: docker/build-push-action@v7.3.0 + uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 with: context: . file: ./Dockerfile @@ -62,7 +62,7 @@ jobs: ghcr.io/sharevb/it-tools:${{ env.RELEASE_VERSION}}-baseurl-it-tools - name: Build and push - uses: docker/build-push-action@v7.3.0 + uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 with: context: . file: ./Dockerfile @@ -78,17 +78,17 @@ jobs: ghcr.io/sharevb/it-tools:${{ env.RELEASE_VERSION}} github-release: - runs-on: ubuntu-latest + runs-on: ubuntu-26.04-arm needs: docker-release steps: - name: Get release version run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV - name: Checkout - uses: actions/checkout@v7.0.0 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Setup pnpm and install dependencies - uses: pnpm/setup@v2.0.2 + uses: pnpm/setup@fbda4c85fc2e1e08721cd8763afea8f48d60f024 # v3.0.0 with: cache: true @@ -113,7 +113,7 @@ jobs: echo "$EOF" >> $GITHUB_OUTPUT - name: Create Release - uses: softprops/action-gh-release@v3.0.1 + uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3 with: token: ${{ secrets.GITHUB_TOKEN }} files: it-tools-${{ env.RELEASE_VERSION }}.zip diff --git a/.github/workflows/sharevb-vercel-preview.yml b/.github/workflows/sharevb-vercel-preview.yml deleted file mode 100644 index 07a8f7eb..00000000 --- a/.github/workflows/sharevb-vercel-preview.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Vercel Preview Deployment -env: - VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} - VITE_VERCEL_ENV: preview - VITE_VERCEL_DEPLOY: true -on: - push: - branches-ignore: - - chore/all-my-stuffs - pull_request: -jobs: - Deploy-Preview: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - - name: Install Vercel CLI - run: npm install --global vercel@latest - - name: Pull Vercel Environment Information - run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} - - name: Build Project Artifacts - run: vercel build --token=${{ secrets.VERCEL_TOKEN }} - - name: Deploy Project Artifacts to Vercel - run: vercel deploy --prebuilt --archive=tgz --token=${{ secrets.VERCEL_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/sharevb-vercel-prod.yml b/.github/workflows/sharevb-vercel-prod.yml deleted file mode 100644 index 0b547358..00000000 --- a/.github/workflows/sharevb-vercel-prod.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Vercel Production Deployment -env: - VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} - VITE_VERCEL_ENV: production - VITE_VERCEL_DEPLOY: true - HOSTNAME: https://sharevb-it-tools.vercel.app/ -on: - push: - branches: - - chore/all-my-stuffs -jobs: - Deploy-Production: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - - name: Install Vercel CLI - run: npm install --global vercel@latest - - name: Pull Vercel Environment Information - run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} - - name: Build Project Artifacts - run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} - - name: Deploy Project Artifacts to Vercel - run: vercel deploy --prebuilt --archive=tgz --prod --token=${{ secrets.VERCEL_TOKEN }} diff --git a/Dockerfile b/Dockerfile index 56cb60dd..d85ef6d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # build stage -FROM --platform=$BUILDPLATFORM node:24-alpine AS build-stage +FROM --platform=$BUILDPLATFORM node:24-alpine@sha256:ebfe2f90462722a7a4de65e91990e97fe0d401c70e0e762c5b53302f905ec1c1 AS build-stage # Set environment variables for non-interactive npm installs ENV NPM_CONFIG_LOGLEVEL=warn ENV CI=true @@ -11,7 +11,7 @@ WORKDIR /app COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ COPY patches patches COPY stubs stubs -RUN npm install -g pnpm@11 && pnpm i --ignore-scripts --frozen-lockfile +RUN npm install -g pnpm@12.6.0 && pnpm i --ignore-scripts --frozen-lockfile COPY . . # Deliberately no BASE_URL here: the bundle is built path-agnostic (relative asset URLs # plus a `` in index.html) so that one image can be served from any @@ -23,7 +23,7 @@ ENV VITE_VERCEL_ENV=production RUN pnpm build # production stage -FROM nginxinc/nginx-unprivileged:stable-alpine AS production-stage +FROM nginxinc/nginx-unprivileged:stable-alpine@sha256:4714e0b1b2577eaa1a6131d07c958b67f0eb68e6d0521e90c6e5287db8cf0bc5 AS production-stage LABEL maintainer="ShareVB " \ org.opencontainers.image.authors="ShareVB " diff --git a/package.json b/package.json index d2931e0c..af6dbdff 100644 --- a/package.json +++ b/package.json @@ -477,11 +477,15 @@ "workbox-window": "^7.4.1", "zx": "^8.8.5" }, - "packageManager": "pnpm@11.22.0+sha512.1ff870c4c6133dfd88fb2afc46dd13d47f09c9794b438c6fdb47ca98caf3bc16381ee0be93a091b8e3824cf01f889f46d7d9e20910fb0be1ab0fb5baa80dd621", "engines": { "node": "24.x" }, "devEngines": { + "packageManager": { + "name": "pnpm", + "version": "12.6.0", + "onFail": "download" + }, "runtime": { "name": "node", "version": "24.x", diff --git a/playwright.config.ts b/playwright.config.ts index 9da43fac..eedb1618 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -82,6 +82,11 @@ export default defineConfig({ command: 'pnpm preview', url: previewUrl, reuseExistingServer: !isCI, + // pnpm 12 runs the script in its own process group, so Playwright's + // default SIGKILL to the `pnpm preview` group misses vite: it survives, + // holds the output pipes open, and the run never exits. pnpm forwards + // SIGTERM to the script, so stop it that way. + gracefulShutdown: { signal: 'SIGTERM', timeout: 5_000 }, }, }), }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1658a06c..26da3600 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,3 +1,161 @@ +--- +lockfileVersion: '9.0' + +importers: + + .: + configDependencies: {} + packageManagerDependencies: + pnpm: + specifier: 12.6.0 + version: 12.6.0 + +packages: + + '@pnpm/exe.android-arm64@12.6.0': + resolution: {integrity: sha512-kviIHft9h02q+7N2In7tSL9T/HRUSGwYmU74YPtsWU5ee7vgqPyC0JT6RRX6miW+NxX1CvHgQxg69qq1qTLJYQ==} + cpu: [arm64] + os: [android] + + '@pnpm/exe.android-x64@12.6.0': + resolution: {integrity: sha512-CT8aJKLq2mtZFE71pr4E5Z2xHL8uGnRGr+NclDqsXlVF4SVcQ2QAs14mWi0C8gjT4hbmi+Q0lJRRIkMAWfjjng==} + cpu: [x64] + os: [android] + + '@pnpm/exe.darwin-arm64@12.6.0': + resolution: {integrity: sha512-rafpVkjzugKBMxSvGQd5wK1x5eOTkD/+lcJIFHeQhvd+BJ8kDisOOvwhQDrpGd4vd2Fx+hhW0P2Ptt638OlhFg==} + cpu: [arm64] + os: [darwin] + + '@pnpm/exe.darwin-x64@12.6.0': + resolution: {integrity: sha512-72Jpuv1m24gI8zUNcaylYpBWEhBzz1VPhnDIU2GYM2eRP+KsOqVLwV78i+JrihI39zY2NNXmaN4eAKX1inpaDQ==} + cpu: [x64] + os: [darwin] + + '@pnpm/exe.freebsd-x64@12.6.0': + resolution: {integrity: sha512-LON4QgNy1w/XF4uySZIyC/5hEB0oGdelXsY9tSKqstER+2j2X2oHz67skD11RRd/HWFRtMr64shQZ4I9ZoZ0zg==} + cpu: [x64] + os: [freebsd] + + '@pnpm/exe.linux-arm64-musl@12.6.0': + resolution: {integrity: sha512-BdDpX+DeaMUc5x6WNcE6FkmFy36NwrBbBvwsZU737Zt3u1fTY+iKFPchjEQNCM4rT6q6xvF2oN3ZwExGsJCkxQ==} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@pnpm/exe.linux-arm64@12.6.0': + resolution: {integrity: sha512-8h2sNoIhHDpHDYqZZCh9PXr6krqW10btb0GHVGuw710muDHlFAHMtUG2ogmaHge6zJG1xgY4Y7mwX5g/LWvrYg==} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@pnpm/exe.linux-ppc64@12.6.0': + resolution: {integrity: sha512-ld6xgcEhFCFrsVsJhbmdmR714PnsEspO/Ij8w0/D7OSiz2hYGu3fZd5tKRxOI5m6H6Gl0/RRFAPncTHbsgXVjQ==} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@pnpm/exe.linux-riscv64@12.6.0': + resolution: {integrity: sha512-HIbImydoC3J8NFt+8MXfhTCf5rO6NjCMyinSAHac0VmV8uCHw+kbQkyAzxV84rzz9ZOzmBOnj0b1N461UIYGsw==} + cpu: [riscv64] + os: [linux] + libc: [glibc] + + '@pnpm/exe.linux-s390x@12.6.0': + resolution: {integrity: sha512-DjSqT7+BZ/lWcDHwNMuzsRVfyxUimh+D54Xw4tSWbdVVQhtWtNMUyI93LVnwCmsoEpar2gC3SFeAgywx37svKQ==} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@pnpm/exe.linux-x64-musl@12.6.0': + resolution: {integrity: sha512-31lKeGPmRE6xfV6I3VjaEGVFRei14pl/zgoFDK4w+UkbJqOuNl2Ht3O1GuqNIg3Gl14qTEb4kZRAYFHXifDx9A==} + cpu: [x64] + os: [linux] + libc: [musl] + + '@pnpm/exe.linux-x64@12.6.0': + resolution: {integrity: sha512-qFWBneHJAJ73W4whtbaFOL1M/7DBC6ILHXuxc7ZPtEhfPuT1zeZiGrmKHoMAfJA+mcm6xhOFljqVTUS+00Jabw==} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@pnpm/exe.win32-arm64@12.6.0': + resolution: {integrity: sha512-OhfefXEEykZlslSUhR8PPRe6MVPV3Oink/dVfIecE5velpc7j80cZYsHlaDrtRDcm3TPwQHkaRW1SJ1efX9oFg==} + cpu: [arm64] + os: [win32] + + '@pnpm/exe.win32-x64@12.6.0': + resolution: {integrity: sha512-L2tuyrD2+Imgxs3VK/ST/2L3xD6vDP0ktJQxM0TaGw7TbAQEMq+RMc8iK6Ew7Id579uzjJe8jSfJID2ZGsOHCA==} + cpu: [x64] + os: [win32] + + pnpm@12.6.0: + resolution: {integrity: sha512-PvaPlRyxEawgS0paFvCy3fDaVqluBBPoHYVdnwtV75JnFHCQKOHNAMQFwsX7e56OxNxGd3yAXQNzwvL/AP0g7A==} + engines: {node: '>=18.*'} + hasBin: true + +snapshots: + + '@pnpm/exe.android-arm64@12.6.0': + optional: true + + '@pnpm/exe.android-x64@12.6.0': + optional: true + + '@pnpm/exe.darwin-arm64@12.6.0': + optional: true + + '@pnpm/exe.darwin-x64@12.6.0': + optional: true + + '@pnpm/exe.freebsd-x64@12.6.0': + optional: true + + '@pnpm/exe.linux-arm64-musl@12.6.0': + optional: true + + '@pnpm/exe.linux-arm64@12.6.0': + optional: true + + '@pnpm/exe.linux-ppc64@12.6.0': + optional: true + + '@pnpm/exe.linux-riscv64@12.6.0': + optional: true + + '@pnpm/exe.linux-s390x@12.6.0': + optional: true + + '@pnpm/exe.linux-x64-musl@12.6.0': + optional: true + + '@pnpm/exe.linux-x64@12.6.0': + optional: true + + '@pnpm/exe.win32-arm64@12.6.0': + optional: true + + '@pnpm/exe.win32-x64@12.6.0': + optional: true + + pnpm@12.6.0: + optionalDependencies: + '@pnpm/exe.android-arm64': 12.6.0 + '@pnpm/exe.android-x64': 12.6.0 + '@pnpm/exe.darwin-arm64': 12.6.0 + '@pnpm/exe.darwin-x64': 12.6.0 + '@pnpm/exe.freebsd-x64': 12.6.0 + '@pnpm/exe.linux-arm64': 12.6.0 + '@pnpm/exe.linux-arm64-musl': 12.6.0 + '@pnpm/exe.linux-ppc64': 12.6.0 + '@pnpm/exe.linux-riscv64': 12.6.0 + '@pnpm/exe.linux-s390x': 12.6.0 + '@pnpm/exe.linux-x64': 12.6.0 + '@pnpm/exe.linux-x64-musl': 12.6.0 + '@pnpm/exe.win32-arm64': 12.6.0 + '@pnpm/exe.win32-x64': 12.6.0 + +--- lockfileVersion: '9.0' settings: diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index c990fc6d..f0e7140f 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -38,8 +38,12 @@ allowBuilds: protobufjs: false sharp: false tesseract.js: false - tree-sitter: true - tree-sitter-bash: true + # Native Node bindings for curlconverter's shell parser. The app only uses + # curlconverter in the browser, where its `browser` field swaps in + # web-tree-sitter (WASM), so the addon is never loaded. There is no + # linux-arm64 prebuild, and compiling it fails against Node 24's C++20 headers. + tree-sitter: false + tree-sitter-bash: false vue-demi: true minimumReleaseAgeExclude: