diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d3e7976..c8059e1 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,36 +2,71 @@ name: Deploy to GitHub Pages on: push: - branches: 'main' + branches: [main] + pull_request: + +permissions: + contents: read + +# A newer push to the same pull request supersedes this run; a branch's runs +# queue instead, so a deploy that is already running is never cancelled. +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +# Container jobs default to `sh`; the steps are bash. +defaults: + run: + shell: bash jobs: + # Runs on pull requests too, so a pull request shows the site builds. Only + # the artifact upload and the deploy job below are gated to main. build_site: - runs-on: ubuntu-latest - permissions: - contents: read + runs-on: ubuntu-24.04 + timeout-minutes: 45 + # The wasm CI image: Rust stable 1.99.1 with the wasm32 targets, + # wasm-bindgen 0.2.127 and binaryen (wasm-opt), which is what + # `comline-simulator`'s `prepack` needs to build its WASM. + container: ghcr.io/comlineproject/ci-wasm@sha256:74efbad4c8b06d554d28e8a1e486f12ae5b6b4bd15a15db21a0925e020caa40a steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - name: Install Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: - node-version: 24 - cache: yarn + node-version: 24.22.3 + + # `.yarnrc.yml` points `yarnPath` at the committed Yarn release; + # corepack provides the `yarn` command that hands over to it. + - name: Yarn + run: corepack enable # `comline-simulator` is a git dependency that compiles to WASM in its - # `prepack` (Rust → wasm-bindgen). The runner has cargo + wasm-opt; this - # caches the one-time `wasm-bindgen-cli` build across runs. + # `prepack` (Rust to wasm-bindgen). The image has cargo, wasm-bindgen and + # wasm-opt; this caches the registry and git checkouts across runs. - name: Cache cargo - uses: actions/cache@v4 + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: | - ~/.cargo/bin - ~/.cargo/registry - ~/.cargo/git - key: ${{ runner.os }}-cargo-${{ hashFiles('yarn.lock') }} - restore-keys: ${{ runner.os }}-cargo- + /usr/local/cargo/registry + /usr/local/cargo/git + key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('yarn.lock') }} + restore-keys: ${{ runner.os }}-${{ runner.arch }}-cargo- + + # Yarn Berry's global cache holds the built `comline-simulator` + # archive: a hit skips the Rust build entirely. + - name: Cache yarn + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ~/.yarn/berry/cache + key: ${{ runner.os }}-${{ runner.arch }}-yarn-${{ hashFiles('yarn.lock') }} + restore-keys: ${{ runner.os }}-${{ runner.arch }}-yarn- + # Yarn's `npmMinimalAgeGate` (its default, one day) stays on. - name: Install dependencies env: COMLINE_SIMULATOR_SCRIPT: '0' # the tutorial only needs the lean sim @@ -43,16 +78,20 @@ jobs: run: yarn build - name: Upload Artifacts - uses: actions/upload-pages-artifact@v3 + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' + uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0 with: # this should match the `pages` option in your adapter-static options path: 'build/' deploy: needs: build_site - runs-on: ubuntu-latest + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' + runs-on: ubuntu-24.04 + timeout-minutes: 10 permissions: + contents: read pages: write id-token: write @@ -61,6 +100,10 @@ jobs: url: ${{ steps.deployment.outputs.page_url }} steps: + - uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit + - name: Deploy id: deployment - uses: actions/deploy-pages@v4 + uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..d4cdcbe --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,27 @@ +name: Lint + +# actionlint on the workflows, and the Renovate config checked with +# `--strict`: the org's reusable lint workflow. + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +# Not `lint-...`: the reusable workflow's own group is that, and groups are +# case-insensitive, so the same name would make the call wait on itself. +concurrency: + group: ci-lint-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + lint: + name: lint + permissions: + contents: read + uses: ComlineProject/.github/.github/workflows/lint.yml@797d473553d7f2fc50895bb2573acb83ac63c7cb # main, no release tag yet + with: + renovate-config: renovate.json diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..c2e2d12 --- /dev/null +++ b/renovate.json @@ -0,0 +1,30 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "github>ComlineProject/.github:renovate-config" + ], + "packageRules": [ + { + "description": [ + "Cross-repo git pins (the simulator) are bumped by hand, like the Cargo `rev =` pins the preset already leaves alone" + ], + "matchManagers": [ + "npm" + ], + "matchDatasources": [ + "git-refs", + "git-tags" + ], + "enabled": false + }, + { + "description": [ + "Yarn refuses versions younger than its npmMinimalAgeGate (one day by default); do not propose them before then" + ], + "matchManagers": [ + "npm" + ], + "minimumReleaseAge": "3 days" + } + ] +}