From 4a1f6278fe781facbc170afa4535953118d78a1d Mon Sep 17 00:00:00 2001 From: Alibek Seksenali Date: Fri, 13 Nov 2026 16:01:35 +0500 Subject: [PATCH 1/3] ci: run native SDK checks on isolated self-hosted runners --- .github/workflows/quality.yml | 36 ++++++++++++++++++++++++++++------- AGENTS.md | 4 ++++ 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index e3b2d92..a52b9f9 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -10,8 +10,24 @@ concurrency: cancel-in-progress: true jobs: contract: - runs-on: ubuntu-24.04 + # Fork code needs maintainer review and an owned branch before shared-runner execution. + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository + runs-on: [self-hosted, 1msg-ci-heavy] + timeout-minutes: 45 + # Native packages are installed only inside this disposable job container. + container: + image: ubuntu:24.04@sha256:2198e4c65076e9cb0b3d695219df667c0e3b0072da64ca3c2648aca17dcecaf5 + defaults: + run: + shell: bash steps: + - name: Prepare the isolated native toolchain environment + run: | + echo "CI_WORKSPACE_OWNER=$(stat -c '%u:%g' "$GITHUB_WORKSPACE/..")" >> "$GITHUB_ENV" + apt-get update + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + build-essential ca-certificates curl git gzip lsb-release sudo tar unzip xz-utils + git config --global --add safe.directory "$GITHUB_WORKSPACE" - uses: actions/checkout@v4 with: fetch-depth: 0 @@ -39,12 +55,12 @@ jobs: - run: pnpm run lint:duplicates:full - run: node quality/generator/generate.mjs - run: node quality/generator/verify-negative.mjs - - run: sudo apt-get update && sudo apt-get install -y libcpprest-dev libboost-all-dev cmake ninja-build + - run: apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends libcpprest-dev libboost-all-dev cmake ninja-build - run: cmake -S quality -B .quality-build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=20 - run: cmake --build .quality-build --parallel 2 - run: ctest --test-dir .quality-build --output-on-failure - - run: cmake --install .quality-build/sdk --prefix "${{ runner.temp }}/sdk-install" - - run: cmake -S quality/consumer -B .quality-build/consumer -DCMAKE_PREFIX_PATH="${{ runner.temp }}/sdk-install" + - run: cmake --install .quality-build/sdk --prefix "${{ runner.temp }}/sdk-install-${{ github.run_id }}-${{ github.run_attempt }}" + - run: cmake -S quality/consumer -B .quality-build/consumer -DCMAKE_PREFIX_PATH="${{ runner.temp }}/sdk-install-${{ github.run_id }}-${{ github.run_attempt }}" - run: cmake --build .quality-build/consumer --parallel 2 - run: ctest --test-dir .quality-build/consumer --output-on-failure - uses: actions/upload-artifact@v4 @@ -55,11 +71,17 @@ jobs: quality/generator/provenance.json quality/generator/inventory.json quality/reports/ + - name: Restore this checkout ownership for later jobs + if: always() + run: | + if [ -n "${CI_WORKSPACE_OWNER:-}" ]; then + chown -hR "$CI_WORKSPACE_OWNER" "$GITHUB_WORKSPACE" + fi quality-required: if: always() needs: [contract] - runs-on: ubuntu-24.04 + runs-on: [self-hosted, 1msg-ci] steps: - env: - RESULTS: ${{ toJSON(needs) }} - run: node -e 'const jobs=JSON.parse(process.env.RESULTS); if(!Object.values(jobs).every(job=>job.result==="success")) process.exit(1)' + CONTRACT_RESULT: ${{ needs.contract.result }} + run: test "$CONTRACT_RESULT" = success diff --git a/AGENTS.md b/AGENTS.md index 4272b52..0042bca 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -9,3 +9,7 @@ Use Node 26.13.1 for tooling and `pnpm --dir tools/quality --ignore-workspace in The `quality-required` aggregate fails if any required job is failed, skipped or cancelled. Repository branch protection must require that check; a workflow file alone does not configure GitHub protection. No generation/build/publish command may swallow errors. `tools/quality` is a checksum-sealed versioned vendor preset, validated by its own executable tests and integrity check; Knip analyzes the consumer tooling graph and excludes that nested vendor workspace. `java` is the explicitly provisioned native generator runtime (CI Temurin24), not an npm package; its pinned generator JAR checksum is mandatory. No authored consumer source is excluded. + +CI runs on the existing self-hosted pools: `1msg-ci-heavy` executes the native contract in a digest-pinned disposable Ubuntu 24.04 container, and `1msg-ci` only evaluates its result. Install operating-system packages inside the job container, never on the shared runner host. Keep the pnpm installer path unique per job and restore checkout ownership after container work. Native fixtures, generator replay and all required quality checks remain mandatory. + +Public fork pull requests do not execute on shared self-hosted runners. A maintainer must review the change and copy it to a repository-owned branch before running the native contract. The aggregate remains failed while that required contract is skipped; do not switch to `pull_request_target` to bypass the boundary. From 5b5d1b028b145b2c099a4f62d416e55fe577b3ef Mon Sep 17 00:00:00 2001 From: Alibek Seksenali Date: Fri, 13 Nov 2026 16:05:55 +0500 Subject: [PATCH 2/3] ci: limit shared runner execution to trusted repository pushes --- .github/workflows/quality.yml | 6 ++---- AGENTS.md | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index a52b9f9..cc55156 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -1,8 +1,8 @@ name: Quality on: - pull_request: + # Only repository writers may schedule code on the shared runner pool. push: - branches: [main] + workflow_dispatch: permissions: contents: read concurrency: @@ -10,8 +10,6 @@ concurrency: cancel-in-progress: true jobs: contract: - # Fork code needs maintainer review and an owned branch before shared-runner execution. - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository runs-on: [self-hosted, 1msg-ci-heavy] timeout-minutes: 45 # Native packages are installed only inside this disposable job container. diff --git a/AGENTS.md b/AGENTS.md index 0042bca..eea5d29 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -12,4 +12,4 @@ The `quality-required` aggregate fails if any required job is failed, skipped or CI runs on the existing self-hosted pools: `1msg-ci-heavy` executes the native contract in a digest-pinned disposable Ubuntu 24.04 container, and `1msg-ci` only evaluates its result. Install operating-system packages inside the job container, never on the shared runner host. Keep the pnpm installer path unique per job and restore checkout ownership after container work. Native fixtures, generator replay and all required quality checks remain mandatory. -Public fork pull requests do not execute on shared self-hosted runners. A maintainer must review the change and copy it to a repository-owned branch before running the native contract. The aggregate remains failed while that required contract is skipped; do not switch to `pull_request_target` to bypass the boundary. +Quality runs on repository pushes and manual dispatch, so same-repository PR heads receive the required checks without executing fork PR code. A maintainer must review a fork change and copy it to a repository-owned branch before scheduling the native contract. Keep external-contributor approval enabled; do not add `pull_request` or `pull_request_target` as a shortcut around this execution boundary. From 825e3adfbc0bb9980592aa7a1d9e5ef7847e4ecc Mon Sep 17 00:00:00 2001 From: Alibek Seksenali Date: Fri, 13 Nov 2026 16:12:00 +0500 Subject: [PATCH 3/3] ci: isolate container tool caches and restore runner ownership --- .github/workflows/quality.yml | 22 ++++++++++++++++++---- AGENTS.md | 2 +- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index cc55156..bdc2ae4 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -12,6 +12,9 @@ jobs: contract: runs-on: [self-hosted, 1msg-ci-heavy] timeout-minutes: 45 + env: + RUNNER_TOOL_CACHE: /tmp/sdk-tools-${{ github.run_id }}-${{ github.run_attempt }} + SDK_INSTALL_PREFIX: /tmp/sdk-install-${{ github.run_id }}-${{ github.run_attempt }} # Native packages are installed only inside this disposable job container. container: image: ubuntu:24.04@sha256:2198e4c65076e9cb0b3d695219df667c0e3b0072da64ca3c2648aca17dcecaf5 @@ -29,6 +32,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 + persist-credentials: false - uses: actions/setup-node@v4 with: node-version: "26.13.1" @@ -57,8 +61,8 @@ jobs: - run: cmake -S quality -B .quality-build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=20 - run: cmake --build .quality-build --parallel 2 - run: ctest --test-dir .quality-build --output-on-failure - - run: cmake --install .quality-build/sdk --prefix "${{ runner.temp }}/sdk-install-${{ github.run_id }}-${{ github.run_attempt }}" - - run: cmake -S quality/consumer -B .quality-build/consumer -DCMAKE_PREFIX_PATH="${{ runner.temp }}/sdk-install-${{ github.run_id }}-${{ github.run_attempt }}" + - run: cmake --install .quality-build/sdk --prefix "$SDK_INSTALL_PREFIX" + - run: cmake -S quality/consumer -B .quality-build/consumer -DCMAKE_PREFIX_PATH="$SDK_INSTALL_PREFIX" - run: cmake --build .quality-build/consumer --parallel 2 - run: ctest --test-dir .quality-build/consumer --output-on-failure - uses: actions/upload-artifact@v4 @@ -69,11 +73,21 @@ jobs: quality/generator/provenance.json quality/generator/inventory.json quality/reports/ - - name: Restore this checkout ownership for later jobs + - name: Restore ownership of this job's mounted files if: always() + env: + PNPM_INSTALL_DIR: ${{ runner.temp }}/pnpm-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }} run: | if [ -n "${CI_WORKSPACE_OWNER:-}" ]; then - chown -hR "$CI_WORKSPACE_OWNER" "$GITHUB_WORKSPACE" + for directory in "$GITHUB_WORKSPACE" "$PNPM_INSTALL_DIR"; do + if [ -d "$directory" ]; then + chown -hR "$CI_WORKSPACE_OWNER" "$directory" + fi + done + # GitHub mounts only this job's temporary home at /github/home. + if [ "$HOME" = /github/home ]; then + chown -hR "$CI_WORKSPACE_OWNER" "$HOME" + fi fi quality-required: if: always() diff --git a/AGENTS.md b/AGENTS.md index eea5d29..1ade20a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -10,6 +10,6 @@ The `quality-required` aggregate fails if any required job is failed, skipped or `tools/quality` is a checksum-sealed versioned vendor preset, validated by its own executable tests and integrity check; Knip analyzes the consumer tooling graph and excludes that nested vendor workspace. `java` is the explicitly provisioned native generator runtime (CI Temurin24), not an npm package; its pinned generator JAR checksum is mandatory. No authored consumer source is excluded. -CI runs on the existing self-hosted pools: `1msg-ci-heavy` executes the native contract in a digest-pinned disposable Ubuntu 24.04 container, and `1msg-ci` only evaluates its result. Install operating-system packages inside the job container, never on the shared runner host. Keep the pnpm installer path unique per job and restore checkout ownership after container work. Native fixtures, generator replay and all required quality checks remain mandatory. +CI runs on the existing self-hosted pools: `1msg-ci-heavy` executes the native contract in a digest-pinned disposable Ubuntu 24.04 container, and `1msg-ci` only evaluates its result. Install operating-system packages inside the job container, never on the shared runner host. Keep the pnpm installer path unique per job, put native installs and the runner tool cache inside the container /tmp, and restore ownership of the checkout, pnpm installation and mounted container home after container work. Native fixtures, generator replay and all required quality checks remain mandatory. Quality runs on repository pushes and manual dispatch, so same-repository PR heads receive the required checks without executing fork PR code. A maintainer must review a fork change and copy it to a repository-owned branch before scheduling the native contract. Keep external-contributor approval enabled; do not add `pull_request` or `pull_request_target` as a shortcut around this execution boundary.