S3: resource limits + Linux cgroup v2 (Mechanism.CgroupV2) + Windows … #21
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: CI | |
| on: | |
| pull_request: | |
| branches: [main] | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| concurrency: | |
| group: ci-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| yaml-lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 | |
| - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | |
| with: | |
| python-version: '3.x' | |
| - name: Install yamllint | |
| run: pip install yamllint | |
| # Config is .yamllint.yml — tuned for Actions YAML. Real defects (tabs, | |
| # duplicate keys, bad indentation) fail; cosmetic line-length stays a | |
| # non-failing warning. | |
| - name: Lint YAML | |
| run: yamllint . | |
| format: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Actions are pinned to a full commit SHA (supply-chain hardening); the | |
| # trailing comment records the human-readable version. Dependabot bumps the | |
| # SHA and updates the comment on its weekly run. | |
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 | |
| - uses: actions/setup-dotnet@9a946fdbd5fb07b82b2f5a4466058b876ab72bb2 # v5 | |
| with: | |
| dotnet-version: '10.0.x' | |
| # Fantomas is the F# formatter and this repo's style authority — the F# | |
| # compiler does not enforce .editorconfig style the way Roslyn does for C#. | |
| - name: Restore tools | |
| run: dotnet tool restore | |
| - name: Check formatting | |
| run: dotnet fantomas --check src tests | |
| test: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 | |
| - uses: actions/setup-dotnet@9a946fdbd5fb07b82b2f5a4466058b876ab72bb2 # v5 | |
| with: | |
| dotnet-version: '10.0.x' | |
| # Cache the global NuGet package folder across runs. Keyed on the central | |
| # version files so the cache invalidates only when dependencies change. | |
| - name: Cache NuGet packages | |
| uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 | |
| with: | |
| path: ~/.nuget/packages | |
| key: ${{ runner.os }}-nuget-${{ hashFiles('Directory.Packages.props', 'nuget.config', 'global.json') }} | |
| restore-keys: ${{ runner.os }}-nuget- | |
| - name: Restore | |
| run: dotnet restore | |
| - name: Build | |
| run: dotnet build --no-restore --configuration Release | |
| - name: Test | |
| run: dotnet test --no-build --configuration Release --logger "trx;LogFileName=test-results.trx" --results-directory ./TestResults | |
| # Test results are uploaded even when the Test step fails, so a red CI run | |
| # can be diagnosed from the .trx without re-running locally. | |
| - name: Upload test results | |
| if: ${{ !cancelled() }} | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: test-results-${{ matrix.os }} | |
| path: ./TestResults/*.trx | |
| if-no-files-found: ignore | |
| # The Linux cgroup v2 `limits` backend can only enable controllers at the real cgroup root, so | |
| # it never engages under the unprivileged matrix legs (a systemd scope / private cgroup | |
| # namespace). This leg runs the limits tests in a privileged container with the host cgroup | |
| # namespace and moves the test process to the real root, so cgroup enforcement is actually | |
| # exercised (PROCESSKIT_EXPECT_CGROUP makes the tests require the cgroup path, not the fallback). | |
| test-cgroup-limits: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 | |
| - name: Run cgroup v2 limits tests (privileged) | |
| run: | | |
| docker run --rm --privileged --cgroupns=host \ | |
| -v "$PWD:/src" -w /src \ | |
| -e DOTNET_CLI_TELEMETRY_OPTOUT=1 -e DOTNET_NOLOGO=1 \ | |
| mcr.microsoft.com/dotnet/sdk:10.0 \ | |
| bash -c ' | |
| set -e | |
| if echo $$ > /sys/fs/cgroup/cgroup.procs 2>/dev/null; then | |
| export PROCESSKIT_EXPECT_CGROUP=1 | |
| fi | |
| echo "PROCESSKIT_EXPECT_CGROUP=$PROCESSKIT_EXPECT_CGROUP" | |
| dotnet build --configuration Release | |
| dotnet test --no-build --configuration Release \ | |
| --filter "FullyQualifiedName~LimitsTests" | |
| ' |