From 516e1ce93baffb1ea5d7e2eb44a0726aa198f653 Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Tue, 24 Nov 2026 16:04:14 +0700 Subject: [PATCH 1/4] Add opt-in Linux RISC-V runner builds Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/scripts/setup-riscv64-dotnet.sh | 18 + .github/workflows/build.yml | 20 +- .github/workflows/patch_update_main.yml | 10 +- .github/workflows/patch_update_release.yml | 2 +- .github/workflows/release.yml | 61 ++- docs/riscv64.md | 53 +++ patches/runner-main-sdk8-riscv64.patch | 461 ++++++++++++++++++++ patches/runner-sdk8-riscv64.patch | 469 +++++++++++++++++++++ 8 files changed, 1083 insertions(+), 11 deletions(-) create mode 100644 .github/scripts/setup-riscv64-dotnet.sh create mode 100644 docs/riscv64.md create mode 100644 patches/runner-main-sdk8-riscv64.patch create mode 100644 patches/runner-sdk8-riscv64.patch diff --git a/.github/scripts/setup-riscv64-dotnet.sh b/.github/scripts/setup-riscv64-dotnet.sh new file mode 100644 index 00000000000..921b4258bb7 --- /dev/null +++ b/.github/scripts/setup-riscv64-dotnet.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -euo pipefail + +version=10.0.115 +sha256=f06bcd3f7cff2781711150ae817190ce67d630b075be0b0aedeb021049c8a0d4 +archive="${RUNNER_TEMP:?}/dotnet-sdk-${version}-linux-riscv64.tar.gz" +sdk_dir="${RUNNER_TEMP}/dotnet-riscv64-${version}" + +curl -fsSL --retry 3 -o "$archive" \ + "https://github.com/filipnavara/dotnet-riscv/releases/download/${version}/dotnet-sdk-${version}-linux-riscv64.tar.gz" +printf '%s %s\n' "$sha256" "$archive" | sha256sum --check +mkdir -p "$sdk_dir" +tar -xzf "$archive" -C "$sdk_dir" +rm "$archive" + +"$sdk_dir/dotnet" --version +echo "$sdk_dir" >> "${GITHUB_PATH:?}" +echo "DOTNET_ROOT=$sdk_dir" >> "${GITHUB_ENV:?}" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 41a357425a8..c3413a08fb1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: build: strategy: matrix: - runtime: [ linux-s390x, linux-ppc64le, linux-x64, linux-arm64, linux-arm ] + runtime: ${{ fromJSON(vars.ENABLE_RISCV64_BUILDS == 'true' && '["linux-s390x","linux-ppc64le","linux-x64","linux-arm64","linux-arm","linux-riscv64"]' || '["linux-s390x","linux-ppc64le","linux-x64","linux-arm64","linux-arm"]') }} include: - runtime: linux-x64 @@ -39,19 +39,29 @@ jobs: runs_on: s390x patch_tag: s390x - runs-on: [ self-hosted, noble, generic, "${{ matrix.runs_on }}" ] + runs-on: [ self-hosted, noble, generic, "${{ matrix.runs_on || 'riscv64' }}" ] steps: - uses: actions/checkout@v7 - name: Install DotNet SDK + if: matrix.runtime != 'linux-riscv64' run: sudo apt-get update && sudo apt-get install -y dotnet-sdk-8.0 + - name: Install community RISC-V DotNet SDK + if: matrix.runtime == 'linux-riscv64' + run: bash .github/scripts/setup-riscv64-dotnet.sh + - name: Apply patches - if: matrix.runtime == 'linux-s390x' || matrix.runtime == 'linux-ppc64le' || matrix.runtime == 'linux-arm' + if: matrix.runtime == 'linux-s390x' || matrix.runtime == 'linux-ppc64le' || matrix.runtime == 'linux-arm' || matrix.runtime == 'linux-riscv64' run: | - git apply patches/runner-main-sdk8-${{ matrix.patch_tag }}.patch + if [[ "${{ matrix.runtime }}" == "linux-riscv64" && ( "$GITHUB_REF" == refs/heads/releases/* || "$GITHUB_BASE_REF" == releases/* ) ]]; then + git apply patches/runner-sdk8-riscv64.patch + else + git apply patches/runner-main-sdk8-${{ matrix.patch_tag || 'riscv64' }}.patch + fi - name: Update DotNet required version pin + if: matrix.runtime != 'linux-riscv64' run: | current_version=$( cat src/global.json | jq -r '.sdk.version' ) if [ "${{ matrix.runtime }}" = "linux-arm" ]; then @@ -81,7 +91,7 @@ jobs: unset ACTIONS_RUNNER_HOOK_JOB_STARTED ACTIONS_RUNNER_HOOK_JOB_COMPLETED ./dev.sh test working-directory: src - if: matrix.runtime == 'linux-x64' + if: matrix.runtime == 'linux-x64' || matrix.runtime == 'linux-riscv64' # Create runner package tar.gz/zip - name: Package Release diff --git a/.github/workflows/patch_update_main.yml b/.github/workflows/patch_update_main.yml index f085a5bf9ab..bee5f263095 100644 --- a/.github/workflows/patch_update_main.yml +++ b/.github/workflows/patch_update_main.yml @@ -72,7 +72,7 @@ jobs: mkdir -p patches touch successful_arches.txt - for arch in ppc64le s390x arm; do + for arch in ppc64le s390x arm riscv64; do echo "Processing $arch..." cd upstream-runner @@ -133,6 +133,14 @@ jobs: rm -f successful_arches.txt cd upstream-runner && git checkout ${{ steps.get-commits.outputs.LATEST_COMMIT_SHORT }} && cd .. cp -r upstream-runner/* . + # Preserve the fork's fix until upstream includes this dependency. + if ! grep -q 'PackageReference Include="Microsoft.AspNetCore.WebUtilities"' src/Runner.Worker/Runner.Worker.csproj; then + sed -i '/' src/Runner.Worker/Runner.Worker.csproj + fi + if ! grep -q 'PackageReference Include="Microsoft.AspNetCore.WebUtilities"' src/Runner.Worker/Runner.Worker.csproj; then + echo "::error::Could not preserve the WebUtilities dependency" + exit 1 + fi rm -rf upstream-runner - name: Import and configure the GPG key for Platform Engineering bot diff --git a/.github/workflows/patch_update_release.yml b/.github/workflows/patch_update_release.yml index 4afb159405d..32e3aa354d2 100644 --- a/.github/workflows/patch_update_release.yml +++ b/.github/workflows/patch_update_release.yml @@ -70,7 +70,7 @@ jobs: mkdir -p patches touch successful_arches.txt - for arch in ppc64le s390x arm; do + for arch in ppc64le s390x arm riscv64; do echo "Processing $arch..." cd upstream-runner diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 789b7817638..2d2ca4e5bf9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,6 +15,8 @@ jobs: check: if: startsWith(github.ref, 'refs/heads/releases/') || github.ref == 'refs/heads/main' runs-on: ubuntu-latest + outputs: + riscv64-enabled: ${{ vars.ENABLE_RISCV64_BUILDS == 'true' }} steps: - uses: actions/checkout@v7 @@ -55,9 +57,11 @@ jobs: linux-s390x-sha: ${{ steps.sha.outputs.linux-s390x-sha256 }} linux-ppc64le-sha: ${{ steps.sha.outputs.linux-ppc64le-sha256 }} linux-arm-sha: ${{ steps.sha.outputs.linux-arm-sha256 }} + linux-riscv64-sha: ${{ steps.sha.outputs.linux-riscv64-sha256 }} + riscv64-enabled: ${{ needs.check.outputs.riscv64-enabled }} strategy: matrix: - runtime: [ linux-s390x, linux-ppc64le, linux-x64, linux-arm64, linux-arm ] + runtime: ${{ fromJSON(needs.check.outputs.riscv64-enabled == 'true' && '["linux-s390x","linux-ppc64le","linux-x64","linux-arm64","linux-arm","linux-riscv64"]' || '["linux-s390x","linux-ppc64le","linux-x64","linux-arm64","linux-arm"]') }} include: - runtime: linux-s390x runs_on: s390x @@ -77,19 +81,29 @@ jobs: runs_on: arm64 patch_tag: arm - runs-on: [ self-hosted, noble, generic, "${{ matrix.runs_on }}" ] + runs-on: [ self-hosted, noble, generic, "${{ matrix.runs_on || 'riscv64' }}" ] steps: - uses: actions/checkout@v7 - name: Install DotNet SDK + if: matrix.runtime != 'linux-riscv64' run: sudo apt-get update && sudo apt-get install -y dotnet-sdk-8.0 + - name: Install community RISC-V DotNet SDK + if: matrix.runtime == 'linux-riscv64' + run: bash .github/scripts/setup-riscv64-dotnet.sh + - name: Apply patches - if: matrix.runtime == 'linux-s390x' || matrix.runtime == 'linux-ppc64le' || matrix.runtime == 'linux-arm' + if: matrix.runtime == 'linux-s390x' || matrix.runtime == 'linux-ppc64le' || matrix.runtime == 'linux-arm' || matrix.runtime == 'linux-riscv64' run: | - git apply patches/runner-sdk8-${{ matrix.patch_tag }}.patch + if [[ "${{ matrix.runtime }}" == "linux-riscv64" && "$GITHUB_REF" == "refs/heads/main" ]]; then + git apply patches/runner-main-sdk8-riscv64.patch + else + git apply patches/runner-sdk8-${{ matrix.patch_tag || 'riscv64' }}.patch + fi - name: Update DotNet required version pin + if: matrix.runtime != 'linux-riscv64' run: | current_version=$( cat src/global.json | jq -r '.sdk.version' ) if [ "${{ matrix.runtime }}" = "linux-arm" ]; then @@ -102,6 +116,12 @@ jobs: sed -i "s/${current_version}/8.0/" src/global.json fi + - name: Ensure patched WebUtilities dependency + run: | + if ! grep -q 'PackageReference Include="Microsoft.AspNetCore.WebUtilities"' src/Runner.Worker/Runner.Worker.csproj; then + dotnet add src/Runner.Worker/Runner.Worker.csproj package Microsoft.AspNetCore.WebUtilities --version 8.0.34 --no-restore + fi + # Build runner layout - name: Build & Layout Release run: | @@ -112,6 +132,13 @@ jobs: - name: Strip bundled npm and corepack run: .github/scripts/strip-bundled-npm.sh _layout ${{ matrix.runtime }} + - name: RISC-V L0 + if: matrix.runtime == 'linux-riscv64' + working-directory: src + run: | + unset ACTIONS_RUNNER_HOOK_JOB_STARTED ACTIONS_RUNNER_HOOK_JOB_COMPLETED + ./dev.sh test + # Create runner package tar.gz/zip - name: Package Release if: github.event_name != 'pull_request' @@ -203,6 +230,13 @@ jobs: name: runner-packages-linux-arm path: ./ + - name: Download Artifact (linux-riscv64) + if: needs.build.outputs.riscv64-enabled == 'true' + uses: actions/download-artifact@v4 + with: + name: runner-packages-linux-riscv64 + path: ./ + # Create ReleaseNote file - name: Create ReleaseNote id: releaseNote @@ -221,6 +255,9 @@ jobs: releaseNote = releaseNote.replace(//g, '${{needs.build.outputs.linux-ppc64le-sha}}') releaseNote = releaseNote.replace(//g, '${{needs.build.outputs.linux-s390x-sha}}') releaseNote = releaseNote.replace(//g, '${{needs.build.outputs.linux-arm-sha}}') + if ('${{ needs.build.outputs.riscv64-enabled }}' === 'true') { + releaseNote += `\n\n## Linux RISC-V 64\n\nAsset: \`actions-runner-linux-riscv64-${runnerVersion}.tar.gz\`\n\nSHA-256: \`${{ needs.build.outputs.linux-riscv64-sha }}\`\n` + } console.log(releaseNote) core.setOutput('version', runnerVersion); core.setOutput('note', releaseNote); @@ -234,6 +271,11 @@ jobs: echo "${{needs.build.outputs.linux-s390x-sha}} actions-runner-linux-s390x-${{ steps.releaseNote.outputs.version }}.tar.gz" | shasum -a 256 -c echo "${{needs.build.outputs.linux-arm-sha}} actions-runner-linux-arm-${{ steps.releaseNote.outputs.version }}.tar.gz" | shasum -a 256 -c + - name: Validate RISC-V Package HASH + if: needs.build.outputs.riscv64-enabled == 'true' + run: | + echo "${{ needs.build.outputs.linux-riscv64-sha }} actions-runner-linux-riscv64-${{ steps.releaseNote.outputs.version }}.tar.gz" | shasum -a 256 -c + # Create GitHub release - uses: actions/create-release@master id: createRelease @@ -296,6 +338,17 @@ jobs: asset_name: actions-runner-linux-arm-${{ steps.releaseNote.outputs.version }}.tar.gz asset_content_type: application/octet-stream + - name: Upload Release Asset (linux-riscv64) + if: needs.build.outputs.riscv64-enabled == 'true' + uses: actions/upload-release-asset@v1.0.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.createRelease.outputs.upload_url }} + asset_path: ${{ github.workspace }}/actions-runner-linux-riscv64-${{ steps.releaseNote.outputs.version }}.tar.gz + asset_name: actions-runner-linux-riscv64-${{ steps.releaseNote.outputs.version }}.tar.gz + asset_content_type: application/octet-stream + - uses: mattermost/action-mattermost-notify@master if: ${{ failure() }} with: diff --git a/docs/riscv64.md b/docs/riscv64.md new file mode 100644 index 00000000000..410fc5aca46 --- /dev/null +++ b/docs/riscv64.md @@ -0,0 +1,53 @@ +# Linux RISC-V 64 runner + +The RISC-V runner is an unofficial build. It uses the community +[.NET 10 SDK](https://github.com/filipnavara/dotnet-riscv) and the Node.js +[unofficial RISC-V builds](https://unofficial-builds.nodejs.org/). Neither is +an official Microsoft-supported RISC-V runner runtime. Track their security +updates and update the SDK version, archive checksum, Node versions and Node +checksums together when upgrading. + +## Build on RISC-V + +Apply `patches/runner-main-sdk8-riscv64.patch` for the current main source, or +`patches/runner-sdk8-riscv64.patch` for the corresponding upstream release +source. The patch names follow the existing architecture-patch convention; +the RISC-V target uses .NET 10, not .NET 8. + +Install the community SDK and its included runtime packs in a separate +directory, then put its `dotnet` on `PATH`: + +```sh +version=10.0.115 +archive="dotnet-sdk-${version}-linux-riscv64.tar.gz" +curl -fLO "https://github.com/filipnavara/dotnet-riscv/releases/download/${version}/${archive}" +echo "f06bcd3f7cff2781711150ae817190ce67d630b075be0b0aedeb021049c8a0d4 ${archive}" | sha256sum --check +mkdir -p "$HOME/dotnet-riscv64" +tar -xzf "$archive" -C "$HOME/dotnet-riscv64" +export DOTNET_ROOT="$HOME/dotnet-riscv64" +export PATH="$DOTNET_ROOT:$PATH" +cd src +./dev.sh layout Release linux-riscv64 +../.github/scripts/strip-bundled-npm.sh ../_layout linux-riscv64 +./dev.sh test +./dev.sh package Release linux-riscv64 +``` + +The SDK must be installed separately from .NET 8 so the RISC-V build does not +select the .NET 8 SDK. Node 20 and 24 archives are checksum-verified before +extraction. The resulting archive is +`_package/actions-runner-linux-riscv64-.tar.gz`. + +## Enable CI and releases + +CI and releases do not schedule RISC-V builds by default. Once a native +Ubuntu 24.04 RISC-V builder with the self-hosted labels `noble`, `generic` and +`riscv64` is available, set the repository variable `ENABLE_RISCV64_BUILDS` +to `true`. Enabled releases run the RISC-V L0 tests and package smoke test, +then publish the archive and its SHA-256 checksum. + +Configure RISC-V runners with `--disableupdate` and maintain timely upgrades +from this repository's releases; GitHub's official runner download service +does not provide this fork's RISC-V package. Individual actions, container +images and tools used by jobs also need RISC-V support. JavaScript actions in +Alpine job containers are not supported on non-x64 runners. diff --git a/patches/runner-main-sdk8-riscv64.patch b/patches/runner-main-sdk8-riscv64.patch new file mode 100644 index 00000000000..3a1dbcdbed9 --- /dev/null +++ b/patches/runner-main-sdk8-riscv64.patch @@ -0,0 +1,461 @@ +diff --git a/src/Directory.Build.props b/src/Directory.Build.props +index 9c069b1..e7b433e 100644 +--- a/src/Directory.Build.props ++++ b/src/Directory.Build.props +@@ -44,6 +44,10 @@ + + $(DefineConstants);ARM64 + ++ ++ $(DefineConstants);RISCV64 ++ $(WarningsNotAsErrors);NU1510 ++ + + + +diff --git a/src/Misc/externals.sh b/src/Misc/externals.sh +index b85b669..31b7042 100755 +--- a/src/Misc/externals.sh ++++ b/src/Misc/externals.sh +@@ -4,6 +4,7 @@ PRECACHE=$2 + + NODE_URL=https://nodejs.org/dist + NODE_ALPINE_URL=https://github.com/actions/alpine_nodejs/releases/download ++NODE_UNOFFICIAL_URL=https://unofficial-builds.nodejs.org/download/release + # When you update Node versions you must also create a new release of alpine_nodejs at that updated version. + # Follow the instructions here: https://github.com/actions/alpine_nodejs?tab=readme-ov-file#getting-started + NODE20_VERSION="20.20.2" +@@ -30,10 +31,19 @@ function checkRC() { + fi + } + ++function verifyChecksum() { ++ local file=$1 ++ local checksum=$2 ++ if [[ -n "$checksum" ]]; then ++ printf '%s %s\n' "$checksum" "$file" | sha256sum --check --status || failed "SHA-256 mismatch for $file" ++ fi ++} ++ + function acquireExternalTool() { + local download_source=$1 # E.g. https://github.com/microsoft/vswhere/releases/download/2.6.7/vswhere.exe + local target_dir="$LAYOUT_DIR/externals/$2" # E.g. $LAYOUT_DIR/externals/vswhere + local fix_nested_dir=$3 # Flag that indicates whether to move nested contents up one directory. ++ local checksum=$4 + + # Extract the portion of the URL after the protocol. E.g. github.com/microsoft/vswhere/releases/download/2.6.7/vswhere.exe + local relative_url="${download_source#*://}" +@@ -46,6 +56,7 @@ function acquireExternalTool() { + if [[ "$PRECACHE" != "" ]]; then + if [ -f "$download_target" ]; then + echo "Download exists: $download_basename" ++ verifyChecksum "$download_target" "$checksum" + else + # Delete any previous partial file. + local partial_target="$DOWNLOAD_DIR/partial/$download_basename" +@@ -74,6 +85,8 @@ function acquireExternalTool() { + curl -fSL --retry 3 --retry-all-errors -o "$partial_target" "$download_source" 2>"${download_target}_download.log" || checkRC 'curl' + fi + ++ verifyChecksum "$partial_target" "$checksum" ++ + # Move the partial file to the download target. + mv "$partial_target" "$download_target" || checkRC 'mv' + +@@ -95,6 +108,7 @@ function acquireExternalTool() { + fi + fi + else ++ verifyChecksum "$download_target" "$checksum" + # Extract to layout. + mkdir -p "$target_dir" || checkRC 'mkdir' + local nested_dir="" +@@ -187,3 +201,8 @@ fi + if [[ "$PACKAGERUNTIME" == "linux-arm" ]]; then + acquireExternalTool "$NODE_URL/v${NODE20_VERSION}/node-v${NODE20_VERSION}-linux-armv7l.tar.gz" node20 fix_nested_dir + fi ++ ++if [[ "$PACKAGERUNTIME" == "linux-riscv64" ]]; then ++ acquireExternalTool "$NODE_UNOFFICIAL_URL/v${NODE20_VERSION}/node-v${NODE20_VERSION}-linux-riscv64.tar.gz" node20 fix_nested_dir 257bac5e327ccabce86863965417ee40d00d5f23d2825ddff528adc5116e7c13 ++ acquireExternalTool "$NODE_UNOFFICIAL_URL/v${NODE24_VERSION}/node-v${NODE24_VERSION}-linux-riscv64.tar.gz" node24 fix_nested_dir 905acca6208f44ac8d193217251920500bd501c68059d71de8e2dbbcf13c246b ++fi +diff --git a/src/Runner.Common/Constants.cs b/src/Runner.Common/Constants.cs +index 3c9a176..e2dd008 100644 +--- a/src/Runner.Common/Constants.cs ++++ b/src/Runner.Common/Constants.cs +@@ -59,7 +59,8 @@ namespace GitHub.Runner.Common + X86, + X64, + Arm, +- Arm64 ++ Arm64, ++ RiscV64 + } + + public static class Runner +@@ -82,6 +83,8 @@ namespace GitHub.Runner.Common + public static readonly Architecture PlatformArchitecture = Architecture.Arm; + #elif ARM64 + public static readonly Architecture PlatformArchitecture = Architecture.Arm64; ++#elif RISCV64 ++ public static readonly Architecture PlatformArchitecture = Architecture.RiscV64; + #else + public static readonly Architecture PlatformArchitecture = Architecture.X64; + #endif +diff --git a/src/Runner.Common/Runner.Common.csproj b/src/Runner.Common/Runner.Common.csproj +index 54b6251..cd81043 100644 +--- a/src/Runner.Common/Runner.Common.csproj ++++ b/src/Runner.Common/Runner.Common.csproj +@@ -1,9 +1,11 @@ + + + +- net8.0 ++ net8.0 ++ net10.0 + Library + win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64 ++ linux-riscv64 + true + NU1701;NU1603;SYSLIB0050;SYSLIB0051 + $(Version) +diff --git a/src/Runner.Common/Util/VarUtil.cs b/src/Runner.Common/Util/VarUtil.cs +index 97273a1..766015f 100644 +--- a/src/Runner.Common/Util/VarUtil.cs ++++ b/src/Runner.Common/Util/VarUtil.cs +@@ -53,6 +53,8 @@ namespace GitHub.Runner.Common.Util + return "ARM"; + case Constants.Architecture.Arm64: + return "ARM64"; ++ case Constants.Architecture.RiscV64: ++ return "RISCV64"; + default: + throw new NotSupportedException(); // Should never reach here. + } +diff --git a/src/Runner.Listener/Runner.Listener.csproj b/src/Runner.Listener/Runner.Listener.csproj +index b532500..cf41fe2 100644 +--- a/src/Runner.Listener/Runner.Listener.csproj ++++ b/src/Runner.Listener/Runner.Listener.csproj +@@ -1,9 +1,11 @@ + + + +- net8.0 ++ net8.0 ++ net10.0 + Exe + win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64 ++ linux-riscv64 + true + true + NU1701;NU1603;SYSLIB0050;SYSLIB0051 +diff --git a/src/Runner.PluginHost/Runner.PluginHost.csproj b/src/Runner.PluginHost/Runner.PluginHost.csproj +index 81a8d2e..ae69c6e 100644 +--- a/src/Runner.PluginHost/Runner.PluginHost.csproj ++++ b/src/Runner.PluginHost/Runner.PluginHost.csproj +@@ -1,9 +1,11 @@ +  + + +- net8.0 ++ net8.0 ++ net10.0 + Exe + win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64 ++ linux-riscv64 + true + true + NU1701;NU1603;SYSLIB0050;SYSLIB0051 +diff --git a/src/Runner.Plugins/Runner.Plugins.csproj b/src/Runner.Plugins/Runner.Plugins.csproj +index a786cf1..d523d36 100644 +--- a/src/Runner.Plugins/Runner.Plugins.csproj ++++ b/src/Runner.Plugins/Runner.Plugins.csproj +@@ -1,9 +1,11 @@ +  + + +- net8.0 ++ net8.0 ++ net10.0 + Library + win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64 ++ linux-riscv64 + true + true + NU1701;NU1603;SYSLIB0050;SYSLIB0051 +diff --git a/src/Runner.Sdk/Runner.Sdk.csproj b/src/Runner.Sdk/Runner.Sdk.csproj +index 70c9891..60e68fb 100644 +--- a/src/Runner.Sdk/Runner.Sdk.csproj ++++ b/src/Runner.Sdk/Runner.Sdk.csproj +@@ -1,9 +1,11 @@ +  + + +- net8.0 ++ net8.0 ++ net10.0 + Library + win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64 ++ linux-riscv64 + true + true + NU1701;NU1603;SYSLIB0050;SYSLIB0051 +diff --git a/src/Runner.Worker/Runner.Worker.csproj b/src/Runner.Worker/Runner.Worker.csproj +index 2ed4f42..6d60dc5 100644 +--- a/src/Runner.Worker/Runner.Worker.csproj ++++ b/src/Runner.Worker/Runner.Worker.csproj +@@ -1,9 +1,11 @@ + + + +- net8.0 ++ net8.0 ++ net10.0 + Exe + win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64 ++ linux-riscv64 + true + true + NU1701;NU1603;SYSLIB0050;SYSLIB0051 +diff --git a/src/Sdk/Sdk.csproj b/src/Sdk/Sdk.csproj +index 13a8cf7..c8686e5 100644 +--- a/src/Sdk/Sdk.csproj ++++ b/src/Sdk/Sdk.csproj +@@ -1,9 +1,11 @@ + + + +- net8.0 ++ net8.0 ++ net10.0 + Library + win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64 ++ linux-riscv64 + + true + NU1701;NU1603;SYSLIB0050;SYSLIB0051 +diff --git a/src/Test/L0/ConstantGenerationL0.cs b/src/Test/L0/ConstantGenerationL0.cs +index 4ff2dbb..8febad5 100644 +--- a/src/Test/L0/ConstantGenerationL0.cs ++++ b/src/Test/L0/ConstantGenerationL0.cs +@@ -20,6 +20,7 @@ namespace GitHub.Runner.Common.Tests + "linux-x64", + "linux-arm", + "linux-arm64", ++ "linux-riscv64", + "osx-x64", + "osx-arm64" + }; +diff --git a/src/Test/L0/Listener/Configuration/ConfigurationManagerL0.cs b/src/Test/L0/Listener/Configuration/ConfigurationManagerL0.cs +index 3c698fd..a76bc14 100644 +--- a/src/Test/L0/Listener/Configuration/ConfigurationManagerL0.cs ++++ b/src/Test/L0/Listener/Configuration/ConfigurationManagerL0.cs +@@ -2,6 +2,7 @@ + using GitHub.Runner.Listener; + using GitHub.Runner.Listener.Configuration; + using GitHub.Runner.Common.Util; ++using GitHub.Runner.Sdk; + using GitHub.Services.WebApi; + using Moq; + using System; +@@ -199,7 +200,8 @@ namespace GitHub.Runner.Common.Tests.Listener.Configuration + // validate GetAgentPoolsAsync gets called twice with automation pool type + _runnerServer.Verify(x => x.GetAgentPoolsAsync(It.IsAny(), It.Is(p => p == TaskAgentPoolType.Automation)), Times.Exactly(2)); + +- var expectedLabels = new List() { "self-hosted", VarUtil.OS, VarUtil.OSArchitecture }; ++ var expectedArchitecture = BuildConstants.RunnerPackage.PackageName == "linux-riscv64" ? "RISCV64" : VarUtil.OSArchitecture; ++ var expectedLabels = new List() { "self-hosted", VarUtil.OS, expectedArchitecture }; + expectedLabels.AddRange(userLabels.Split(",").ToList()); + + _runnerServer.Verify(x => x.AddAgentAsync(It.IsAny(), It.Is(a => a.Labels.Select(x => x.Name).ToHashSet().SetEquals(expectedLabels))), Times.Once); +diff --git a/src/Test/L0/Listener/SelfUpdaterL0.cs b/src/Test/L0/Listener/SelfUpdaterL0.cs +index 8003dd0..0985032 100644 +--- a/src/Test/L0/Listener/SelfUpdaterL0.cs ++++ b/src/Test/L0/Listener/SelfUpdaterL0.cs +@@ -58,7 +58,9 @@ namespace GitHub.Runner.Common.Tests.Listener + latestVersion = match.Groups["version"].Value; + + #if !OS_WINDOWS +- _packageUrl = $"https://github.com/actions/runner/releases/download/v{latestVersion}/actions-runner-{BuildConstants.RunnerPackage.PackageName}-{latestVersion}.tar.gz"; ++ // The official RISC-V archive is unavailable; this fixture is only extracted. ++ var packageName = BuildConstants.RunnerPackage.PackageName == "linux-riscv64" ? "linux-x64" : BuildConstants.RunnerPackage.PackageName; ++ _packageUrl = $"https://github.com/actions/runner/releases/download/v{latestVersion}/actions-runner-{packageName}-{latestVersion}.tar.gz"; + #else + _packageUrl = $"https://github.com/actions/runner/releases/download/v{latestVersion}/actions-runner-{BuildConstants.RunnerPackage.PackageName}-{latestVersion}.zip"; + #endif +diff --git a/src/Test/L0/Listener/SelfUpdaterV2L0.cs b/src/Test/L0/Listener/SelfUpdaterV2L0.cs +index a91e112..8fedf49 100644 +--- a/src/Test/L0/Listener/SelfUpdaterV2L0.cs ++++ b/src/Test/L0/Listener/SelfUpdaterV2L0.cs +@@ -58,7 +58,9 @@ namespace GitHub.Runner.Common.Tests.Listener + latestVersion = match.Groups["version"].Value; + + #if !OS_WINDOWS +- _packageUrl = $"https://github.com/actions/runner/releases/download/v{latestVersion}/actions-runner-{BuildConstants.RunnerPackage.PackageName}-{latestVersion}.tar.gz"; ++ // The official RISC-V archive is unavailable; this fixture is only extracted. ++ var packageName = BuildConstants.RunnerPackage.PackageName == "linux-riscv64" ? "linux-x64" : BuildConstants.RunnerPackage.PackageName; ++ _packageUrl = $"https://github.com/actions/runner/releases/download/v{latestVersion}/actions-runner-{packageName}-{latestVersion}.tar.gz"; + #else + _packageUrl = $"https://github.com/actions/runner/releases/download/v{latestVersion}/actions-runner-{BuildConstants.RunnerPackage.PackageName}-{latestVersion}.zip"; + #endif +diff --git a/src/Test/L0/Worker/StepHostL0.cs b/src/Test/L0/Worker/StepHostL0.cs +index bac7d41..d81bf9b 100644 +--- a/src/Test/L0/Worker/StepHostL0.cs ++++ b/src/Test/L0/Worker/StepHostL0.cs +@@ -32,6 +32,20 @@ namespace GitHub.Runner.Common.Tests.Worker + } + + #if OS_LINUX ++ private async Task AssertAlpineNodeVersionAsync(ContainerStepHost stepHost, string preferredVersion) ++ { ++ if (Constants.Runner.PlatformArchitecture == Constants.Architecture.X64) ++ { ++ var nodeVersion = await stepHost.DetermineNodeRuntimeVersion(_ec.Object, preferredVersion); ++ Assert.Equal($"{preferredVersion}_alpine", nodeVersion); ++ } ++ else ++ { ++ var error = await Assert.ThrowsAsync(() => stepHost.DetermineNodeRuntimeVersion(_ec.Object, preferredVersion)); ++ Assert.Contains("only supported on x64 Linux runners", error.Message); ++ } ++ } ++ + [Fact] + [Trait("Level", "L0")] + [Trait("Category", "Worker")] +@@ -74,11 +88,7 @@ namespace GitHub.Runner.Common.Tests.Worker + }) + .ReturnsAsync(0); + +- // Act. +- var nodeVersion = await sh.DetermineNodeRuntimeVersion(_ec.Object, "node20"); +- +- // Assert. +- Assert.Equal("node20_alpine", nodeVersion); ++ await AssertAlpineNodeVersionAsync(sh, "node20"); + } + } + +@@ -101,11 +111,7 @@ namespace GitHub.Runner.Common.Tests.Worker + }) + .ReturnsAsync(0); + +- // Act. +- var nodeVersion = await sh.DetermineNodeRuntimeVersion(_ec.Object, "node20"); +- +- // Assert. +- Assert.Equal("node20_alpine", nodeVersion); ++ await AssertAlpineNodeVersionAsync(sh, "node20"); + } + } + +@@ -182,11 +188,7 @@ namespace GitHub.Runner.Common.Tests.Worker + }) + .ReturnsAsync(0); + +- // Act. +- var nodeVersion = await sh.DetermineNodeRuntimeVersion(_ec.Object, "node24"); +- +- // Assert. +- Assert.Equal("node24_alpine", nodeVersion); ++ await AssertAlpineNodeVersionAsync(sh, "node24"); + } + } + +diff --git a/src/Test/Test.csproj b/src/Test/Test.csproj +index 5ad39f3..3487b7a 100644 +--- a/src/Test/Test.csproj ++++ b/src/Test/Test.csproj +@@ -1,7 +1,9 @@ + + +- net8.0 ++ net8.0 ++ net10.0 + win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64 ++ linux-riscv64 + true + NU1701;NU1603;NU1603;xUnit2013;SYSLIB0050;SYSLIB0051 + +diff --git a/src/dev.sh b/src/dev.sh +index e4e8d10..b85192f 100755 +--- a/src/dev.sh ++++ b/src/dev.sh +@@ -54,6 +54,7 @@ elif [[ "$CURRENT_PLATFORM" == 'linux' ]]; then + case $CPU_NAME in + armv7l) RUNTIME_ID="linux-arm";; + aarch64) RUNTIME_ID="linux-arm64";; ++ riscv64) RUNTIME_ID="linux-riscv64";; + esac + fi + elif [[ "$CURRENT_PLATFORM" == 'darwin' ]]; then +@@ -72,7 +73,7 @@ fi + + # Make sure current platform support publish the dotnet runtime + # Windows can publish win-x86/x64/arm64 +-# Linux can publish linux-x64/arm/arm64 ++# Linux can publish linux-x64/arm/arm64/riscv64 + # OSX can publish osx-x64/arm64 + if [[ "$CURRENT_PLATFORM" == 'windows' ]]; then + if [[ ("$RUNTIME_ID" != 'win-x86') && ("$RUNTIME_ID" != 'win-x64') && ("$RUNTIME_ID" != 'win-arm64') ]]; then +@@ -80,7 +81,7 @@ if [[ "$CURRENT_PLATFORM" == 'windows' ]]; then + exit 1 + fi + elif [[ "$CURRENT_PLATFORM" == 'linux' ]]; then +- if [[ ("$RUNTIME_ID" != 'linux-x64') && ("$RUNTIME_ID" != 'linux-x86') && ("$RUNTIME_ID" != 'linux-arm64') && ("$RUNTIME_ID" != 'linux-arm') ]]; then ++ if [[ ("$RUNTIME_ID" != 'linux-x64') && ("$RUNTIME_ID" != 'linux-x86') && ("$RUNTIME_ID" != 'linux-arm64') && ("$RUNTIME_ID" != 'linux-arm') && ("$RUNTIME_ID" != 'linux-riscv64') ]]; then + echo "Failed: Can't build $RUNTIME_ID package $CURRENT_PLATFORM" >&2 + exit 1 + fi +@@ -200,7 +201,11 @@ function package () + } + + # Install .NET SDK +-if [[ (! -d "${DOTNETSDK_INSTALLDIR}") || (! -e "${DOTNETSDK_INSTALLDIR}/.${DOTNETSDK_VERSION}") || (! -e "${DOTNETSDK_INSTALLDIR}/dotnet") ]]; then ++if [[ "$RUNTIME_ID" == 'linux-riscv64' ]]; then ++ if ! command -v dotnet > /dev/null || [[ "$(dotnet --version)" != 10.0.* ]]; then ++ failed "linux-riscv64 requires a community .NET 10 SDK on PATH" ++ fi ++elif [[ (! -d "${DOTNETSDK_INSTALLDIR}") || (! -e "${DOTNETSDK_INSTALLDIR}/.${DOTNETSDK_VERSION}") || (! -e "${DOTNETSDK_INSTALLDIR}/dotnet") ]]; then + + # Download dotnet SDK to ../_dotnetsdk directory + heading "Ensure Dotnet SDK" +@@ -225,8 +230,10 @@ if [[ (! -d "${DOTNETSDK_INSTALLDIR}") || (! -e "${DOTNETSDK_INSTALLDIR}/.${DOTN + echo "${DOTNETSDK_VERSION}" > "${DOTNETSDK_INSTALLDIR}/.${DOTNETSDK_VERSION}" + fi + +-echo "Prepend ${DOTNETSDK_INSTALLDIR} to %PATH%" +-export PATH=${DOTNETSDK_INSTALLDIR}:$PATH ++if [[ "$RUNTIME_ID" != 'linux-riscv64' ]]; then ++ echo "Prepend ${DOTNETSDK_INSTALLDIR} to %PATH%" ++ export PATH=${DOTNETSDK_INSTALLDIR}:$PATH ++fi + + heading "Dotnet SDK Version" + dotnet --version +diff --git a/src/dir.proj b/src/dir.proj +index 056a312..c00520d 100644 +--- a/src/dir.proj ++++ b/src/dir.proj +@@ -48,7 +48,7 @@ + + + +- ++ + + + +diff --git a/src/global.json b/src/global.json +index 63e95af..bbe87d2 100644 +--- a/src/global.json ++++ b/src/global.json +@@ -1,5 +1,6 @@ + { + "sdk": { +- "version": "8.0.427" ++ "version": "8.0.427", ++ "rollForward": "major" + } + } +# From upstream commit: 01e888680892c6f31f5f9617c606505db6b4cfc7 diff --git a/patches/runner-sdk8-riscv64.patch b/patches/runner-sdk8-riscv64.patch new file mode 100644 index 00000000000..2c459bdb7d3 --- /dev/null +++ b/patches/runner-sdk8-riscv64.patch @@ -0,0 +1,469 @@ +diff --git a/src/Directory.Build.props b/src/Directory.Build.props +index 9c069b1..e7b433e 100644 +--- a/src/Directory.Build.props ++++ b/src/Directory.Build.props +@@ -44,6 +44,10 @@ + + $(DefineConstants);ARM64 + ++ ++ $(DefineConstants);RISCV64 ++ $(WarningsNotAsErrors);NU1510 ++ + + + +diff --git a/src/Misc/externals.sh b/src/Misc/externals.sh +index c385c5e..aff00b4 100755 +--- a/src/Misc/externals.sh ++++ b/src/Misc/externals.sh +@@ -4,6 +4,7 @@ PRECACHE=$2 + + NODE_URL=https://nodejs.org/dist + NODE_ALPINE_URL=https://github.com/actions/alpine_nodejs/releases/download ++NODE_UNOFFICIAL_URL=https://unofficial-builds.nodejs.org/download/release + # When you update Node versions you must also create a new release of alpine_nodejs at that updated version. + # Follow the instructions here: https://github.com/actions/alpine_nodejs?tab=readme-ov-file#getting-started + NODE20_VERSION="20.20.2" +@@ -30,10 +31,19 @@ function checkRC() { + fi + } + ++function verifyChecksum() { ++ local file=$1 ++ local checksum=$2 ++ if [[ -n "$checksum" ]]; then ++ printf '%s %s\n' "$checksum" "$file" | sha256sum --check --status || failed "SHA-256 mismatch for $file" ++ fi ++} ++ + function acquireExternalTool() { + local download_source=$1 # E.g. https://github.com/microsoft/vswhere/releases/download/2.6.7/vswhere.exe + local target_dir="$LAYOUT_DIR/externals/$2" # E.g. $LAYOUT_DIR/externals/vswhere + local fix_nested_dir=$3 # Flag that indicates whether to move nested contents up one directory. ++ local checksum=$4 + + # Extract the portion of the URL after the protocol. E.g. github.com/microsoft/vswhere/releases/download/2.6.7/vswhere.exe + local relative_url="${download_source#*://}" +@@ -46,6 +56,7 @@ function acquireExternalTool() { + if [[ "$PRECACHE" != "" ]]; then + if [ -f "$download_target" ]; then + echo "Download exists: $download_basename" ++ verifyChecksum "$download_target" "$checksum" + else + # Delete any previous partial file. + local partial_target="$DOWNLOAD_DIR/partial/$download_basename" +@@ -74,6 +85,8 @@ function acquireExternalTool() { + curl -fSL --retry 3 --retry-all-errors -o "$partial_target" "$download_source" 2>"${download_target}_download.log" || checkRC 'curl' + fi + ++ verifyChecksum "$partial_target" "$checksum" ++ + # Move the partial file to the download target. + mv "$partial_target" "$download_target" || checkRC 'mv' + +@@ -95,6 +108,7 @@ function acquireExternalTool() { + fi + fi + else ++ verifyChecksum "$download_target" "$checksum" + # Extract to layout. + mkdir -p "$target_dir" || checkRC 'mkdir' + local nested_dir="" +@@ -187,3 +201,8 @@ fi + if [[ "$PACKAGERUNTIME" == "linux-arm" ]]; then + acquireExternalTool "$NODE_URL/v${NODE20_VERSION}/node-v${NODE20_VERSION}-linux-armv7l.tar.gz" node20 fix_nested_dir + fi ++ ++if [[ "$PACKAGERUNTIME" == "linux-riscv64" ]]; then ++ acquireExternalTool "$NODE_UNOFFICIAL_URL/v${NODE20_VERSION}/node-v${NODE20_VERSION}-linux-riscv64.tar.gz" node20 fix_nested_dir 257bac5e327ccabce86863965417ee40d00d5f23d2825ddff528adc5116e7c13 ++ acquireExternalTool "$NODE_UNOFFICIAL_URL/v${NODE24_VERSION}/node-v${NODE24_VERSION}-linux-riscv64.tar.gz" node24 fix_nested_dir 73acf79cdac8d94792e16ae71871b79457c30ab7ca316c642e6209a516bad4ea ++fi +diff --git a/src/Runner.Common/Constants.cs b/src/Runner.Common/Constants.cs +index 4acf494..327fb89 100644 +--- a/src/Runner.Common/Constants.cs ++++ b/src/Runner.Common/Constants.cs +@@ -59,7 +59,8 @@ namespace GitHub.Runner.Common + X86, + X64, + Arm, +- Arm64 ++ Arm64, ++ RiscV64 + } + + public static class Runner +@@ -82,6 +83,8 @@ namespace GitHub.Runner.Common + public static readonly Architecture PlatformArchitecture = Architecture.Arm; + #elif ARM64 + public static readonly Architecture PlatformArchitecture = Architecture.Arm64; ++#elif RISCV64 ++ public static readonly Architecture PlatformArchitecture = Architecture.RiscV64; + #else + public static readonly Architecture PlatformArchitecture = Architecture.X64; + #endif +diff --git a/src/Runner.Common/Runner.Common.csproj b/src/Runner.Common/Runner.Common.csproj +index 9c087c8..c9207bc 100644 +--- a/src/Runner.Common/Runner.Common.csproj ++++ b/src/Runner.Common/Runner.Common.csproj +@@ -1,9 +1,11 @@ + + + +- net8.0 ++ net8.0 ++ net10.0 + Library + win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64 ++ linux-riscv64 + true + NU1701;NU1603;SYSLIB0050;SYSLIB0051 + $(Version) +diff --git a/src/Runner.Common/Util/VarUtil.cs b/src/Runner.Common/Util/VarUtil.cs +index 97273a1..766015f 100644 +--- a/src/Runner.Common/Util/VarUtil.cs ++++ b/src/Runner.Common/Util/VarUtil.cs +@@ -53,6 +53,8 @@ namespace GitHub.Runner.Common.Util + return "ARM"; + case Constants.Architecture.Arm64: + return "ARM64"; ++ case Constants.Architecture.RiscV64: ++ return "RISCV64"; + default: + throw new NotSupportedException(); // Should never reach here. + } +diff --git a/src/Runner.Listener/Runner.Listener.csproj b/src/Runner.Listener/Runner.Listener.csproj +index b532500..cf41fe2 100644 +--- a/src/Runner.Listener/Runner.Listener.csproj ++++ b/src/Runner.Listener/Runner.Listener.csproj +@@ -1,9 +1,11 @@ + + + +- net8.0 ++ net8.0 ++ net10.0 + Exe + win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64 ++ linux-riscv64 + true + true + NU1701;NU1603;SYSLIB0050;SYSLIB0051 +diff --git a/src/Runner.PluginHost/Runner.PluginHost.csproj b/src/Runner.PluginHost/Runner.PluginHost.csproj +index 81a8d2e..ae69c6e 100644 +--- a/src/Runner.PluginHost/Runner.PluginHost.csproj ++++ b/src/Runner.PluginHost/Runner.PluginHost.csproj +@@ -1,9 +1,11 @@ +  + + +- net8.0 ++ net8.0 ++ net10.0 + Exe + win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64 ++ linux-riscv64 + true + true + NU1701;NU1603;SYSLIB0050;SYSLIB0051 +diff --git a/src/Runner.Plugins/Runner.Plugins.csproj b/src/Runner.Plugins/Runner.Plugins.csproj +index a786cf1..d523d36 100644 +--- a/src/Runner.Plugins/Runner.Plugins.csproj ++++ b/src/Runner.Plugins/Runner.Plugins.csproj +@@ -1,9 +1,11 @@ +  + + +- net8.0 ++ net8.0 ++ net10.0 + Library + win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64 ++ linux-riscv64 + true + true + NU1701;NU1603;SYSLIB0050;SYSLIB0051 +diff --git a/src/Runner.Sdk/Runner.Sdk.csproj b/src/Runner.Sdk/Runner.Sdk.csproj +index 3f58d58..1b53d48 100644 +--- a/src/Runner.Sdk/Runner.Sdk.csproj ++++ b/src/Runner.Sdk/Runner.Sdk.csproj +@@ -1,9 +1,11 @@ +  + + +- net8.0 ++ net8.0 ++ net10.0 + Library + win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64 ++ linux-riscv64 + true + true + NU1701;NU1603;SYSLIB0050;SYSLIB0051 +diff --git a/src/Runner.Worker/Runner.Worker.csproj b/src/Runner.Worker/Runner.Worker.csproj +index 6a7f36e..5ab8a19 100644 +--- a/src/Runner.Worker/Runner.Worker.csproj ++++ b/src/Runner.Worker/Runner.Worker.csproj +@@ -1,9 +1,11 @@ + + + +- net8.0 ++ net8.0 ++ net10.0 + Exe + win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64 ++ linux-riscv64 + true + true + NU1701;NU1603;SYSLIB0050;SYSLIB0051 +@@ -19,6 +21,7 @@ + + + ++ + + + +diff --git a/src/Sdk/Sdk.csproj b/src/Sdk/Sdk.csproj +index 45c8f8f..202dd13 100644 +--- a/src/Sdk/Sdk.csproj ++++ b/src/Sdk/Sdk.csproj +@@ -1,9 +1,11 @@ + + + +- net8.0 ++ net8.0 ++ net10.0 + Library + win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64 ++ linux-riscv64 + + true + NU1701;NU1603;SYSLIB0050;SYSLIB0051 +diff --git a/src/Test/L0/ConstantGenerationL0.cs b/src/Test/L0/ConstantGenerationL0.cs +index 4ff2dbb..8febad5 100644 +--- a/src/Test/L0/ConstantGenerationL0.cs ++++ b/src/Test/L0/ConstantGenerationL0.cs +@@ -20,6 +20,7 @@ namespace GitHub.Runner.Common.Tests + "linux-x64", + "linux-arm", + "linux-arm64", ++ "linux-riscv64", + "osx-x64", + "osx-arm64" + }; +diff --git a/src/Test/L0/Listener/Configuration/ConfigurationManagerL0.cs b/src/Test/L0/Listener/Configuration/ConfigurationManagerL0.cs +index 3c698fd..a76bc14 100644 +--- a/src/Test/L0/Listener/Configuration/ConfigurationManagerL0.cs ++++ b/src/Test/L0/Listener/Configuration/ConfigurationManagerL0.cs +@@ -2,6 +2,7 @@ + using GitHub.Runner.Listener; + using GitHub.Runner.Listener.Configuration; + using GitHub.Runner.Common.Util; ++using GitHub.Runner.Sdk; + using GitHub.Services.WebApi; + using Moq; + using System; +@@ -199,7 +200,8 @@ namespace GitHub.Runner.Common.Tests.Listener.Configuration + // validate GetAgentPoolsAsync gets called twice with automation pool type + _runnerServer.Verify(x => x.GetAgentPoolsAsync(It.IsAny(), It.Is(p => p == TaskAgentPoolType.Automation)), Times.Exactly(2)); + +- var expectedLabels = new List() { "self-hosted", VarUtil.OS, VarUtil.OSArchitecture }; ++ var expectedArchitecture = BuildConstants.RunnerPackage.PackageName == "linux-riscv64" ? "RISCV64" : VarUtil.OSArchitecture; ++ var expectedLabels = new List() { "self-hosted", VarUtil.OS, expectedArchitecture }; + expectedLabels.AddRange(userLabels.Split(",").ToList()); + + _runnerServer.Verify(x => x.AddAgentAsync(It.IsAny(), It.Is(a => a.Labels.Select(x => x.Name).ToHashSet().SetEquals(expectedLabels))), Times.Once); +diff --git a/src/Test/L0/Listener/SelfUpdaterL0.cs b/src/Test/L0/Listener/SelfUpdaterL0.cs +index 8003dd0..0985032 100644 +--- a/src/Test/L0/Listener/SelfUpdaterL0.cs ++++ b/src/Test/L0/Listener/SelfUpdaterL0.cs +@@ -58,7 +58,9 @@ namespace GitHub.Runner.Common.Tests.Listener + latestVersion = match.Groups["version"].Value; + + #if !OS_WINDOWS +- _packageUrl = $"https://github.com/actions/runner/releases/download/v{latestVersion}/actions-runner-{BuildConstants.RunnerPackage.PackageName}-{latestVersion}.tar.gz"; ++ // The official RISC-V archive is unavailable; this fixture is only extracted. ++ var packageName = BuildConstants.RunnerPackage.PackageName == "linux-riscv64" ? "linux-x64" : BuildConstants.RunnerPackage.PackageName; ++ _packageUrl = $"https://github.com/actions/runner/releases/download/v{latestVersion}/actions-runner-{packageName}-{latestVersion}.tar.gz"; + #else + _packageUrl = $"https://github.com/actions/runner/releases/download/v{latestVersion}/actions-runner-{BuildConstants.RunnerPackage.PackageName}-{latestVersion}.zip"; + #endif +diff --git a/src/Test/L0/Listener/SelfUpdaterV2L0.cs b/src/Test/L0/Listener/SelfUpdaterV2L0.cs +index a91e112..8fedf49 100644 +--- a/src/Test/L0/Listener/SelfUpdaterV2L0.cs ++++ b/src/Test/L0/Listener/SelfUpdaterV2L0.cs +@@ -58,7 +58,9 @@ namespace GitHub.Runner.Common.Tests.Listener + latestVersion = match.Groups["version"].Value; + + #if !OS_WINDOWS +- _packageUrl = $"https://github.com/actions/runner/releases/download/v{latestVersion}/actions-runner-{BuildConstants.RunnerPackage.PackageName}-{latestVersion}.tar.gz"; ++ // The official RISC-V archive is unavailable; this fixture is only extracted. ++ var packageName = BuildConstants.RunnerPackage.PackageName == "linux-riscv64" ? "linux-x64" : BuildConstants.RunnerPackage.PackageName; ++ _packageUrl = $"https://github.com/actions/runner/releases/download/v{latestVersion}/actions-runner-{packageName}-{latestVersion}.tar.gz"; + #else + _packageUrl = $"https://github.com/actions/runner/releases/download/v{latestVersion}/actions-runner-{BuildConstants.RunnerPackage.PackageName}-{latestVersion}.zip"; + #endif +diff --git a/src/Test/L0/Worker/StepHostL0.cs b/src/Test/L0/Worker/StepHostL0.cs +index bac7d41..d81bf9b 100644 +--- a/src/Test/L0/Worker/StepHostL0.cs ++++ b/src/Test/L0/Worker/StepHostL0.cs +@@ -32,6 +32,20 @@ namespace GitHub.Runner.Common.Tests.Worker + } + + #if OS_LINUX ++ private async Task AssertAlpineNodeVersionAsync(ContainerStepHost stepHost, string preferredVersion) ++ { ++ if (Constants.Runner.PlatformArchitecture == Constants.Architecture.X64) ++ { ++ var nodeVersion = await stepHost.DetermineNodeRuntimeVersion(_ec.Object, preferredVersion); ++ Assert.Equal($"{preferredVersion}_alpine", nodeVersion); ++ } ++ else ++ { ++ var error = await Assert.ThrowsAsync(() => stepHost.DetermineNodeRuntimeVersion(_ec.Object, preferredVersion)); ++ Assert.Contains("only supported on x64 Linux runners", error.Message); ++ } ++ } ++ + [Fact] + [Trait("Level", "L0")] + [Trait("Category", "Worker")] +@@ -74,11 +88,7 @@ namespace GitHub.Runner.Common.Tests.Worker + }) + .ReturnsAsync(0); + +- // Act. +- var nodeVersion = await sh.DetermineNodeRuntimeVersion(_ec.Object, "node20"); +- +- // Assert. +- Assert.Equal("node20_alpine", nodeVersion); ++ await AssertAlpineNodeVersionAsync(sh, "node20"); + } + } + +@@ -101,11 +111,7 @@ namespace GitHub.Runner.Common.Tests.Worker + }) + .ReturnsAsync(0); + +- // Act. +- var nodeVersion = await sh.DetermineNodeRuntimeVersion(_ec.Object, "node20"); +- +- // Assert. +- Assert.Equal("node20_alpine", nodeVersion); ++ await AssertAlpineNodeVersionAsync(sh, "node20"); + } + } + +@@ -182,11 +188,7 @@ namespace GitHub.Runner.Common.Tests.Worker + }) + .ReturnsAsync(0); + +- // Act. +- var nodeVersion = await sh.DetermineNodeRuntimeVersion(_ec.Object, "node24"); +- +- // Assert. +- Assert.Equal("node24_alpine", nodeVersion); ++ await AssertAlpineNodeVersionAsync(sh, "node24"); + } + } + +diff --git a/src/Test/Test.csproj b/src/Test/Test.csproj +index 843071c..cd455b4 100644 +--- a/src/Test/Test.csproj ++++ b/src/Test/Test.csproj +@@ -1,7 +1,9 @@ + + +- net8.0 ++ net8.0 ++ net10.0 + win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64 ++ linux-riscv64 + true + NU1701;NU1603;NU1603;xUnit2013;SYSLIB0050;SYSLIB0051 + +diff --git a/src/dev.sh b/src/dev.sh +index e4e8d10..b85192f 100755 +--- a/src/dev.sh ++++ b/src/dev.sh +@@ -54,6 +54,7 @@ elif [[ "$CURRENT_PLATFORM" == 'linux' ]]; then + case $CPU_NAME in + armv7l) RUNTIME_ID="linux-arm";; + aarch64) RUNTIME_ID="linux-arm64";; ++ riscv64) RUNTIME_ID="linux-riscv64";; + esac + fi + elif [[ "$CURRENT_PLATFORM" == 'darwin' ]]; then +@@ -72,7 +73,7 @@ fi + + # Make sure current platform support publish the dotnet runtime + # Windows can publish win-x86/x64/arm64 +-# Linux can publish linux-x64/arm/arm64 ++# Linux can publish linux-x64/arm/arm64/riscv64 + # OSX can publish osx-x64/arm64 + if [[ "$CURRENT_PLATFORM" == 'windows' ]]; then + if [[ ("$RUNTIME_ID" != 'win-x86') && ("$RUNTIME_ID" != 'win-x64') && ("$RUNTIME_ID" != 'win-arm64') ]]; then +@@ -80,7 +81,7 @@ if [[ "$CURRENT_PLATFORM" == 'windows' ]]; then + exit 1 + fi + elif [[ "$CURRENT_PLATFORM" == 'linux' ]]; then +- if [[ ("$RUNTIME_ID" != 'linux-x64') && ("$RUNTIME_ID" != 'linux-x86') && ("$RUNTIME_ID" != 'linux-arm64') && ("$RUNTIME_ID" != 'linux-arm') ]]; then ++ if [[ ("$RUNTIME_ID" != 'linux-x64') && ("$RUNTIME_ID" != 'linux-x86') && ("$RUNTIME_ID" != 'linux-arm64') && ("$RUNTIME_ID" != 'linux-arm') && ("$RUNTIME_ID" != 'linux-riscv64') ]]; then + echo "Failed: Can't build $RUNTIME_ID package $CURRENT_PLATFORM" >&2 + exit 1 + fi +@@ -200,7 +201,11 @@ function package () + } + + # Install .NET SDK +-if [[ (! -d "${DOTNETSDK_INSTALLDIR}") || (! -e "${DOTNETSDK_INSTALLDIR}/.${DOTNETSDK_VERSION}") || (! -e "${DOTNETSDK_INSTALLDIR}/dotnet") ]]; then ++if [[ "$RUNTIME_ID" == 'linux-riscv64' ]]; then ++ if ! command -v dotnet > /dev/null || [[ "$(dotnet --version)" != 10.0.* ]]; then ++ failed "linux-riscv64 requires a community .NET 10 SDK on PATH" ++ fi ++elif [[ (! -d "${DOTNETSDK_INSTALLDIR}") || (! -e "${DOTNETSDK_INSTALLDIR}/.${DOTNETSDK_VERSION}") || (! -e "${DOTNETSDK_INSTALLDIR}/dotnet") ]]; then + + # Download dotnet SDK to ../_dotnetsdk directory + heading "Ensure Dotnet SDK" +@@ -225,8 +230,10 @@ if [[ (! -d "${DOTNETSDK_INSTALLDIR}") || (! -e "${DOTNETSDK_INSTALLDIR}/.${DOTN + echo "${DOTNETSDK_VERSION}" > "${DOTNETSDK_INSTALLDIR}/.${DOTNETSDK_VERSION}" + fi + +-echo "Prepend ${DOTNETSDK_INSTALLDIR} to %PATH%" +-export PATH=${DOTNETSDK_INSTALLDIR}:$PATH ++if [[ "$RUNTIME_ID" != 'linux-riscv64' ]]; then ++ echo "Prepend ${DOTNETSDK_INSTALLDIR} to %PATH%" ++ export PATH=${DOTNETSDK_INSTALLDIR}:$PATH ++fi + + heading "Dotnet SDK Version" + dotnet --version +diff --git a/src/dir.proj b/src/dir.proj +index 056a312..c00520d 100644 +--- a/src/dir.proj ++++ b/src/dir.proj +@@ -48,7 +48,7 @@ + + + +- ++ + + + +diff --git a/src/global.json b/src/global.json +index 63e95af..bbe87d2 100644 +--- a/src/global.json ++++ b/src/global.json +@@ -1,5 +1,6 @@ + { + "sdk": { +- "version": "8.0.427" ++ "version": "8.0.427", ++ "rollForward": "major" + } + } +# From upstream release: v2.338.2 From 3461615dfcbfab53f607f4d1d418a1f5f211e3d9 Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Thu, 26 Nov 2026 14:26:42 +0700 Subject: [PATCH 2/4] Gate RISC-V patch synchronization Keep optional RISC-V sync from blocking existing architectures when disabled, and use its own patch baseline when enabled. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/scripts/patch-sync-baseline.sh | 39 ++++++++ .github/workflows/patch_update_main.yml | 11 ++- .github/workflows/patch_update_release.yml | 15 ++- docs/riscv64.md | 11 ++- src/Test/L0/Workflow/PatchSyncL0.cs | 109 +++++++++++++++++++++ 5 files changed, 176 insertions(+), 9 deletions(-) create mode 100644 .github/scripts/patch-sync-baseline.sh create mode 100644 src/Test/L0/Workflow/PatchSyncL0.cs diff --git a/.github/scripts/patch-sync-baseline.sh b/.github/scripts/patch-sync-baseline.sh new file mode 100644 index 00000000000..fda4398aacc --- /dev/null +++ b/.github/scripts/patch-sync-baseline.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +set -euo pipefail + +architecture=$1 +enabled=$2 +shared_baseline=$3 +patch=$4 +kind=$5 + +if [[ "$architecture" != "riscv64" ]]; then + printf '%s\n' "$shared_baseline" + exit 0 +fi + +if [[ "$enabled" != "true" ]]; then + exit 0 +fi + +case "$kind" in + commit) prefix="# From upstream commit: " ;; + release) prefix="# From upstream release: " ;; + *) echo "Invalid RISC-V patch marker type: $kind" >&2; exit 1 ;; +esac + +if [[ ! -f "$patch" ]]; then + echo "Invalid RISC-V patch marker: missing $patch" >&2 + exit 1 +fi + +marker=$(tail -n 1 "$patch") +baseline=${marker#"$prefix"} +if [[ "$marker" != "$prefix"* || -z "$baseline" ]] || + [[ "$kind" == "commit" && ! "$baseline" =~ ^([0-9a-f]{40}|[0-9a-f]{64})$ ]] || + [[ "$kind" == "release" && ! "$baseline" =~ ^v[0-9][0-9A-Za-z.+_-]*$ ]]; then + echo "Invalid RISC-V patch marker in $patch" >&2 + exit 1 +fi + +printf '%s\n' "$baseline" diff --git a/.github/workflows/patch_update_main.yml b/.github/workflows/patch_update_main.yml index 6b4342b2523..587db6757e4 100644 --- a/.github/workflows/patch_update_main.yml +++ b/.github/workflows/patch_update_main.yml @@ -68,11 +68,18 @@ jobs: - name: Process architectures if: steps.get-commits.outputs.PREVIOUS_COMMIT != '' && steps.get-commits.outputs.PREVIOUS_COMMIT != steps.get-commits.outputs.LATEST_COMMIT id: process-arches + env: + ENABLE_RISCV64_BUILDS: ${{ vars.ENABLE_RISCV64_BUILDS }} run: | mkdir -p patches touch successful_arches.txt for arch in ppc64le s390x arm riscv64; do + patch_baseline=$(bash .github/scripts/patch-sync-baseline.sh "$arch" "${ENABLE_RISCV64_BUILDS:-}" "${{ steps.get-commits.outputs.PREVIOUS_COMMIT }}" "patches/runner-main-sdk8-$arch.patch" commit) + if [[ -z "$patch_baseline" ]]; then + echo "Skipping $arch while RISC-V builds are disabled" + continue + fi echo "Processing $arch..." cd upstream-runner @@ -82,13 +89,13 @@ jobs: # Check if previous patch exists if [ ! -f "../patches/runner-main-sdk8-$arch.patch" ] || \ - ! grep -q "${{ steps.get-commits.outputs.PREVIOUS_COMMIT }}" "../patches/runner-main-sdk8-$arch.patch"; then + ! grep -Fq -- "$patch_baseline" "../patches/runner-main-sdk8-$arch.patch"; then echo "::error::No valid previous patch for $arch" exit 1 fi # Apply previous patch to previous commit - git checkout ${{ steps.get-commits.outputs.PREVIOUS_COMMIT }} + git checkout "$patch_baseline" if ! git apply --check --whitespace=nowarn "../patches/runner-main-sdk8-$arch.patch"; then echo "::error::Previous patch application failed for $arch" exit 1 diff --git a/.github/workflows/patch_update_release.yml b/.github/workflows/patch_update_release.yml index 32e3aa354d2..205138e144f 100644 --- a/.github/workflows/patch_update_release.yml +++ b/.github/workflows/patch_update_release.yml @@ -66,11 +66,18 @@ jobs: - name: Process architectures if: steps.get-tags.outputs.PREVIOUS_TAG != '' && steps.get-tags.outputs.PREVIOUS_TAG != steps.get-tags.outputs.LATEST_TAG id: process-arches + env: + ENABLE_RISCV64_BUILDS: ${{ vars.ENABLE_RISCV64_BUILDS }} run: | mkdir -p patches touch successful_arches.txt for arch in ppc64le s390x arm riscv64; do + patch_baseline=$(bash .github/scripts/patch-sync-baseline.sh "$arch" "${ENABLE_RISCV64_BUILDS:-}" "${{ steps.get-tags.outputs.PREVIOUS_TAG }}" "patches/runner-sdk8-$arch.patch" release) + if [[ -z "$patch_baseline" ]]; then + echo "Skipping $arch while RISC-V builds are disabled" + continue + fi echo "Processing $arch..." cd upstream-runner @@ -96,16 +103,16 @@ jobs: # Check if previous patch exists if [ ! -f "../patches/runner-sdk8-$arch.patch" ] || \ - ! grep -q "${{ steps.get-tags.outputs.PREVIOUS_TAG }}" "../patches/runner-sdk8-$arch.patch"; then - echo "::error::No valid previous patch for $arch — patch file missing or does not reference ${{ steps.get-tags.outputs.PREVIOUS_TAG }}" + ! grep -Fq -- "$patch_baseline" "../patches/runner-sdk8-$arch.patch"; then + echo "::error::No valid previous patch for $arch — patch file missing or does not reference $patch_baseline" cd .. exit 1 fi # Apply previous patch to previous release - git checkout ${{ steps.get-tags.outputs.PREVIOUS_TAG }} + git checkout "$patch_baseline" if ! git apply --check --whitespace=nowarn "../patches/runner-sdk8-$arch.patch"; then - echo "::error::Previous patch application failed for $arch — patch does not apply cleanly to ${{ steps.get-tags.outputs.PREVIOUS_TAG }}" + echo "::error::Previous patch application failed for $arch — patch does not apply cleanly to $patch_baseline" cd .. exit 1 fi diff --git a/docs/riscv64.md b/docs/riscv64.md index 90d9ba67fe2..01c2d91f404 100644 --- a/docs/riscv64.md +++ b/docs/riscv64.md @@ -47,9 +47,14 @@ be incompatible with Node 24 and may need to be updated. CI and releases do not schedule RISC-V builds by default. Once a native Ubuntu 24.04 RISC-V builder with the self-hosted labels `noble`, `generic` and -`riscv64` is available, set the repository variable `ENABLE_RISCV64_BUILDS` -to `true`. Enabled releases run the RISC-V L0 tests and package smoke test, -then publish the archive and its SHA-256 checksum. +`riscv64` is available, refresh and check both RISC-V patches against the +current main source and latest upstream release before setting the repository +variable `ENABLE_RISCV64_BUILDS` to `true`. Patch synchronization skips RISC-V +while disabled and uses each RISC-V patch's own source marker when enabled. +Enabling the variable does not itself refresh stale patches; update the pinned +Node checksum when porting to a new Node version. +Enabled releases run the RISC-V L0 tests and package smoke test, then publish +the archive and its SHA-256 checksum. Configure RISC-V runners with `--disableupdate` and maintain timely upgrades from this repository's releases; GitHub's official runner download service diff --git a/src/Test/L0/Workflow/PatchSyncL0.cs b/src/Test/L0/Workflow/PatchSyncL0.cs new file mode 100644 index 00000000000..12db68fefc3 --- /dev/null +++ b/src/Test/L0/Workflow/PatchSyncL0.cs @@ -0,0 +1,109 @@ +#if OS_LINUX +using System; +using System.Diagnostics; +using System.IO; +using Xunit; + +namespace GitHub.Runner.Common.Tests.Workflow +{ + public sealed class PatchSyncL0 + { + [Theory] + [InlineData("")] + [InlineData("false")] + [Trait("Level", "L0")] + [Trait("Category", "Common")] + public void DisabledRiscVDoesNotRequireAPatch(string enabled) + { + var result = GetBaseline("riscv64", enabled, "global", "missing.patch", "commit"); + + Assert.Equal(0, result.ExitCode); + Assert.Equal(string.Empty, result.Output); + } + + [Theory] + [InlineData("ppc64le", "false")] + [InlineData("s390x", "true")] + [InlineData("arm", "")] + [Trait("Level", "L0")] + [Trait("Category", "Common")] + public void ExistingArchitecturesKeepTheSharedBaseline(string architecture, string enabled) + { + var result = GetBaseline(architecture, enabled, "global", "missing.patch", "commit"); + + Assert.Equal(0, result.ExitCode); + Assert.Equal("global", result.Output); + } + + [Theory] + [InlineData("commit", "# From upstream commit: 0123456789abcdef0123456789abcdef01234567", "0123456789abcdef0123456789abcdef01234567")] + [InlineData("release", "# From upstream release: v2.338.2", "v2.338.2")] + [Trait("Level", "L0")] + [Trait("Category", "Common")] + public void EnabledRiscVUsesItsOwnPatchBaseline(string kind, string marker, string expected) + { + string patch = Path.GetTempFileName(); + try + { + File.WriteAllText(patch, $"diff --git a/file b/file\n{marker}\n"); + + var result = GetBaseline("riscv64", "true", "newer-global", patch, kind); + + Assert.Equal(0, result.ExitCode); + Assert.Equal(expected, result.Output); + } + finally + { + File.Delete(patch); + } + } + + [Theory] + [InlineData("commit", "# From upstream release: v2.338.2")] + [InlineData("commit", "# From upstream commit: not-a-commit")] + [InlineData("release", "# From upstream release: ")] + [InlineData("release", "# From upstream release: -not-a-tag")] + [Trait("Level", "L0")] + [Trait("Category", "Common")] + public void EnabledRiscVRejectsInvalidPatchMarkers(string kind, string marker) + { + string patch = Path.GetTempFileName(); + try + { + File.WriteAllText(patch, $"{marker}\n"); + + var result = GetBaseline("riscv64", "true", "global", patch, kind); + + Assert.NotEqual(0, result.ExitCode); + Assert.Contains("Invalid RISC-V patch marker", result.Error); + } + finally + { + File.Delete(patch); + } + } + + private static (int ExitCode, string Output, string Error) GetBaseline(params string[] arguments) + { + string script = Path.GetFullPath(Path.Combine(TestUtil.GetSrcPath(), "..", ".github", "scripts", "patch-sync-baseline.sh")); + var startInfo = new ProcessStartInfo("bash") + { + RedirectStandardOutput = true, + RedirectStandardError = true, + UseShellExecute = false, + }; + startInfo.ArgumentList.Add(script); + foreach (string argument in arguments) + { + startInfo.ArgumentList.Add(argument); + } + + using var process = Process.Start(startInfo); + string output = process.StandardOutput.ReadToEnd().TrimEnd('\r', '\n'); + string error = process.StandardError.ReadToEnd(); + process.WaitForExit(); + return (process.ExitCode, output, error); + } + } +} +#endif From 0c276303990bb2eda39b820a37a0b5210db48ab6 Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Thu, 26 Nov 2026 16:05:28 +0700 Subject: [PATCH 3/4] Honor mixed-case RISC-V build flags Match GitHub Actions string comparison when deciding whether to synchronize the optional RISC-V patches. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/scripts/patch-sync-baseline.sh | 2 +- src/Test/L0/Workflow/PatchSyncL0.cs | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/scripts/patch-sync-baseline.sh b/.github/scripts/patch-sync-baseline.sh index fda4398aacc..7b104e77d4c 100644 --- a/.github/scripts/patch-sync-baseline.sh +++ b/.github/scripts/patch-sync-baseline.sh @@ -12,7 +12,7 @@ if [[ "$architecture" != "riscv64" ]]; then exit 0 fi -if [[ "$enabled" != "true" ]]; then +if [[ "${enabled,,}" != "true" ]]; then exit 0 fi diff --git a/src/Test/L0/Workflow/PatchSyncL0.cs b/src/Test/L0/Workflow/PatchSyncL0.cs index 12db68fefc3..ac33dc936ef 100644 --- a/src/Test/L0/Workflow/PatchSyncL0.cs +++ b/src/Test/L0/Workflow/PatchSyncL0.cs @@ -11,6 +11,8 @@ public sealed class PatchSyncL0 [Theory] [InlineData("")] [InlineData("false")] + [InlineData("true ")] + [InlineData("1")] [Trait("Level", "L0")] [Trait("Category", "Common")] public void DisabledRiscVDoesNotRequireAPatch(string enabled) @@ -36,18 +38,20 @@ public void ExistingArchitecturesKeepTheSharedBaseline(string architecture, stri } [Theory] - [InlineData("commit", "# From upstream commit: 0123456789abcdef0123456789abcdef01234567", "0123456789abcdef0123456789abcdef01234567")] - [InlineData("release", "# From upstream release: v2.338.2", "v2.338.2")] + [InlineData("true", "commit", "# From upstream commit: 0123456789abcdef0123456789abcdef01234567", "0123456789abcdef0123456789abcdef01234567")] + [InlineData("TRUE", "commit", "# From upstream commit: 0123456789abcdef0123456789abcdef01234567", "0123456789abcdef0123456789abcdef01234567")] + [InlineData("True", "release", "# From upstream release: v2.338.2", "v2.338.2")] + [InlineData("tRuE", "release", "# From upstream release: v2.338.2", "v2.338.2")] [Trait("Level", "L0")] [Trait("Category", "Common")] - public void EnabledRiscVUsesItsOwnPatchBaseline(string kind, string marker, string expected) + public void EnabledRiscVUsesItsOwnPatchBaseline(string enabled, string kind, string marker, string expected) { string patch = Path.GetTempFileName(); try { File.WriteAllText(patch, $"diff --git a/file b/file\n{marker}\n"); - var result = GetBaseline("riscv64", "true", "newer-global", patch, kind); + var result = GetBaseline("riscv64", enabled, "newer-global", patch, kind); Assert.Equal(0, result.ExitCode); Assert.Equal(expected, result.Output); From f6e8bc8dd521986804003aa38b8ed8e7883824c2 Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Thu, 26 Nov 2026 22:19:22 +0700 Subject: [PATCH 4/4] Keep RISC-V changes in patches and release notes Move workflow regressions into a patch against an existing upstream test file, inline the fork-specific helpers, and preserve x64 CI when optional tests become stale. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/release-note-canonical.md | 69 +++++ .github/scripts/patch-sync-baseline.sh | 39 --- .github/scripts/setup-riscv64-dotnet.sh | 18 -- .github/workflows/build.yml | 43 ++- .github/workflows/patch_update_main.yml | 40 ++- .github/workflows/patch_update_release.yml | 40 ++- .github/workflows/release.yml | 25 +- docs/riscv64.md | 63 ----- patches/patch-sync-l0.patch | 303 +++++++++++++++++++++ src/Test/L0/Workflow/PatchSyncL0.cs | 113 -------- 10 files changed, 516 insertions(+), 237 deletions(-) delete mode 100644 .github/scripts/patch-sync-baseline.sh delete mode 100644 .github/scripts/setup-riscv64-dotnet.sh delete mode 100644 docs/riscv64.md create mode 100644 patches/patch-sync-l0.patch delete mode 100644 src/Test/L0/Workflow/PatchSyncL0.cs diff --git a/.github/release-note-canonical.md b/.github/release-note-canonical.md index 18d24415ef3..970cd43cd79 100644 --- a/.github/release-note-canonical.md +++ b/.github/release-note-canonical.md @@ -22,3 +22,72 @@ The ARM32 runner build retains the local `RUNNER_IGNORE_ARM32_KILL_SWITCH` envir ## Runner package contents Package validation now checks that published bundles contain the expected Node runtime and version. Linux ARM32 bundles use Node 22; other Linux bundles use Node 24. + +## Linux RISC-V 64 runner (experimental) + +The RISC-V runner is an unofficial build using the community +[.NET 10 SDK](https://github.com/filipnavara/dotnet-riscv) and +[Node.js RISC-V builds](https://unofficial-builds.nodejs.org/). Neither is an +official Microsoft-supported RISC-V runner runtime. Track their security +updates and update the SDK version, archive checksum, Node versions and Node +checksums together when upgrading. + +Only Node 24 is bundled. Actions requesting Node 12, 16 or 20 use Node 24 on +RISC-V, even when Node 20 is explicitly enabled. Older actions may need to be +updated for Node 24. Individual actions, container images and tools also need +RISC-V support; JavaScript actions in Alpine job containers are not supported +on non-x64 runners. + +### Build on RISC-V + +Apply `patches/runner-main-sdk8-riscv64.patch` for the current main source, or +`patches/runner-sdk8-riscv64.patch` for the corresponding upstream release +source. The patch names follow the existing architecture-patch convention; +the RISC-V target uses .NET 10, not .NET 8. Apply the workflow-test patch +separately before running L0 tests. + +Install the community SDK and its included runtime packs in a separate +directory, then put its `dotnet` on `PATH`: + +```sh +version=10.0.115 +archive="dotnet-sdk-${version}-linux-riscv64.tar.gz" +curl -fLO "https://github.com/filipnavara/dotnet-riscv/releases/download/${version}/${archive}" +echo "f06bcd3f7cff2781711150ae817190ce67d630b075be0b0aedeb021049c8a0d4 ${archive}" | sha256sum --check +mkdir -p "$HOME/dotnet-riscv64" +tar -xzf "$archive" -C "$HOME/dotnet-riscv64" +export DOTNET_ROOT="$HOME/dotnet-riscv64" +export PATH="$DOTNET_ROOT:$PATH" +# Use runner-sdk8-riscv64.patch instead for the corresponding release. +git apply patches/runner-main-sdk8-riscv64.patch +git apply patches/patch-sync-l0.patch +cd src +./dev.sh layout Release linux-riscv64 +../.github/scripts/strip-bundled-npm.sh ../_layout linux-riscv64 +./dev.sh test +./dev.sh package Release linux-riscv64 +``` + +Keep the SDK separate from .NET 8 so the RISC-V build does not select the +.NET 8 SDK. Node archives are checksum-verified before extraction. The +resulting archive is `_package/actions-runner-linux-riscv64-.tar.gz`. +Refresh `patches/patch-sync-l0.patch` if its upstream test file changes. While +RISC-V is disabled, x64 CI warns and skips those workflow tests if the patch is +stale; when RISC-V is enabled, CI requires the patch to apply. + +### Enable CI and releases + +CI and releases do not schedule RISC-V builds by default. Once a native +Ubuntu 24.04 RISC-V builder with the self-hosted labels `noble`, `generic` and +`riscv64` is available, refresh and check both RISC-V patches against the +current main source and latest upstream release before setting the repository +variable `ENABLE_RISCV64_BUILDS` to `true`. Patch synchronization skips RISC-V +while disabled and uses each RISC-V patch's own source marker when enabled. +Enabling the variable does not itself refresh stale patches; update the pinned +Node checksum when porting to a new Node version. Enabled releases run the +RISC-V L0 tests and package smoke test, then publish the archive and its +SHA-256 checksum. + +Configure RISC-V runners with `--disableupdate` and maintain timely upgrades +from this repository's releases; GitHub's official runner download service +does not provide this fork's RISC-V package. diff --git a/.github/scripts/patch-sync-baseline.sh b/.github/scripts/patch-sync-baseline.sh deleted file mode 100644 index 7b104e77d4c..00000000000 --- a/.github/scripts/patch-sync-baseline.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -architecture=$1 -enabled=$2 -shared_baseline=$3 -patch=$4 -kind=$5 - -if [[ "$architecture" != "riscv64" ]]; then - printf '%s\n' "$shared_baseline" - exit 0 -fi - -if [[ "${enabled,,}" != "true" ]]; then - exit 0 -fi - -case "$kind" in - commit) prefix="# From upstream commit: " ;; - release) prefix="# From upstream release: " ;; - *) echo "Invalid RISC-V patch marker type: $kind" >&2; exit 1 ;; -esac - -if [[ ! -f "$patch" ]]; then - echo "Invalid RISC-V patch marker: missing $patch" >&2 - exit 1 -fi - -marker=$(tail -n 1 "$patch") -baseline=${marker#"$prefix"} -if [[ "$marker" != "$prefix"* || -z "$baseline" ]] || - [[ "$kind" == "commit" && ! "$baseline" =~ ^([0-9a-f]{40}|[0-9a-f]{64})$ ]] || - [[ "$kind" == "release" && ! "$baseline" =~ ^v[0-9][0-9A-Za-z.+_-]*$ ]]; then - echo "Invalid RISC-V patch marker in $patch" >&2 - exit 1 -fi - -printf '%s\n' "$baseline" diff --git a/.github/scripts/setup-riscv64-dotnet.sh b/.github/scripts/setup-riscv64-dotnet.sh deleted file mode 100644 index 921b4258bb7..00000000000 --- a/.github/scripts/setup-riscv64-dotnet.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -version=10.0.115 -sha256=f06bcd3f7cff2781711150ae817190ce67d630b075be0b0aedeb021049c8a0d4 -archive="${RUNNER_TEMP:?}/dotnet-sdk-${version}-linux-riscv64.tar.gz" -sdk_dir="${RUNNER_TEMP}/dotnet-riscv64-${version}" - -curl -fsSL --retry 3 -o "$archive" \ - "https://github.com/filipnavara/dotnet-riscv/releases/download/${version}/dotnet-sdk-${version}-linux-riscv64.tar.gz" -printf '%s %s\n' "$sha256" "$archive" | sha256sum --check -mkdir -p "$sdk_dir" -tar -xzf "$archive" -C "$sdk_dir" -rm "$archive" - -"$sdk_dir/dotnet" --version -echo "$sdk_dir" >> "${GITHUB_PATH:?}" -echo "DOTNET_ROOT=$sdk_dir" >> "${GITHUB_ENV:?}" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index adb840f7958..2fb313cf6e3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,7 +54,26 @@ jobs: - name: Install community RISC-V DotNet SDK if: matrix.runtime == 'linux-riscv64' - run: bash .github/scripts/setup-riscv64-dotnet.sh + run: | + # riscv64-dotnet-setup:start + set -euo pipefail + + version=10.0.115 + sha256=f06bcd3f7cff2781711150ae817190ce67d630b075be0b0aedeb021049c8a0d4 + archive="${RUNNER_TEMP:?}/dotnet-sdk-${version}-linux-riscv64.tar.gz" + sdk_dir="${RUNNER_TEMP}/dotnet-riscv64-${version}" + + curl -fsSL --retry 3 -o "$archive" \ + "https://github.com/filipnavara/dotnet-riscv/releases/download/${version}/dotnet-sdk-${version}-linux-riscv64.tar.gz" + printf '%s %s\n' "$sha256" "$archive" | sha256sum --check + mkdir -p "$sdk_dir" + tar -xzf "$archive" -C "$sdk_dir" + rm "$archive" + + "$sdk_dir/dotnet" --version + echo "$sdk_dir" >> "${GITHUB_PATH:?}" + echo "DOTNET_ROOT=$sdk_dir" >> "${GITHUB_ENV:?}" + # riscv64-dotnet-setup:end - name: Apply patches if: matrix.runtime == 'linux-s390x' || matrix.runtime == 'linux-ppc64le' || matrix.runtime == 'linux-arm' || matrix.runtime == 'linux-riscv64' @@ -94,6 +113,28 @@ jobs: fi .github/scripts/strip-bundled-npm.sh _layout ${{ matrix.runtime }} + - name: Apply workflow test patch + if: matrix.runtime == 'linux-x64' || matrix.runtime == 'linux-riscv64' + env: + ENABLE_RISCV64_BUILDS: ${{ vars.ENABLE_RISCV64_BUILDS }} + run: | + # workflow-test-patch:start + apply_workflow_test_patch() { + local enabled="$1" patch="$2" + + if git apply --check "$patch" >/dev/null 2>&1; then + git apply "$patch" + elif [[ "${enabled,,}" == "true" ]]; then + echo "::error::Workflow test patch is stale; refresh it before enabling RISC-V." + return 1 + else + echo "::warning::Workflow test patch is stale; skipping its tests while RISC-V is disabled." + fi + } + # workflow-test-patch:end + + apply_workflow_test_patch "${ENABLE_RISCV64_BUILDS:-}" patches/patch-sync-l0.patch + # Run tests - name: L0 run: | diff --git a/.github/workflows/patch_update_main.yml b/.github/workflows/patch_update_main.yml index 587db6757e4..cb936a957fd 100644 --- a/.github/workflows/patch_update_main.yml +++ b/.github/workflows/patch_update_main.yml @@ -71,11 +71,49 @@ jobs: env: ENABLE_RISCV64_BUILDS: ${{ vars.ENABLE_RISCV64_BUILDS }} run: | + # patch-sync-baseline:start + patch_sync_baseline() { + local architecture="$1" enabled="$2" shared_baseline="$3" patch="$4" kind="$5" + local prefix marker baseline + + if [[ "$architecture" != "riscv64" ]]; then + printf '%s\n' "$shared_baseline" + return 0 + fi + + if [[ "${enabled,,}" != "true" ]]; then + return 0 + fi + + case "$kind" in + commit) prefix="# From upstream commit: " ;; + release) prefix="# From upstream release: " ;; + *) echo "Invalid RISC-V patch marker type: $kind" >&2; return 1 ;; + esac + + if [[ ! -f "$patch" ]]; then + echo "Invalid RISC-V patch marker: missing $patch" >&2 + return 1 + fi + + marker=$(tail -n 1 "$patch") + baseline=${marker#"$prefix"} + if [[ "$marker" != "$prefix"* || -z "$baseline" ]] || + [[ "$kind" == "commit" && ! "$baseline" =~ ^([0-9a-f]{40}|[0-9a-f]{64})$ ]] || + [[ "$kind" == "release" && ! "$baseline" =~ ^v[0-9][0-9A-Za-z.+_-]*$ ]]; then + echo "Invalid RISC-V patch marker in $patch" >&2 + return 1 + fi + + printf '%s\n' "$baseline" + } + # patch-sync-baseline:end + mkdir -p patches touch successful_arches.txt for arch in ppc64le s390x arm riscv64; do - patch_baseline=$(bash .github/scripts/patch-sync-baseline.sh "$arch" "${ENABLE_RISCV64_BUILDS:-}" "${{ steps.get-commits.outputs.PREVIOUS_COMMIT }}" "patches/runner-main-sdk8-$arch.patch" commit) + patch_baseline=$(patch_sync_baseline "$arch" "${ENABLE_RISCV64_BUILDS:-}" "${{ steps.get-commits.outputs.PREVIOUS_COMMIT }}" "patches/runner-main-sdk8-$arch.patch" commit) if [[ -z "$patch_baseline" ]]; then echo "Skipping $arch while RISC-V builds are disabled" continue diff --git a/.github/workflows/patch_update_release.yml b/.github/workflows/patch_update_release.yml index 205138e144f..8303c3346f1 100644 --- a/.github/workflows/patch_update_release.yml +++ b/.github/workflows/patch_update_release.yml @@ -69,11 +69,49 @@ jobs: env: ENABLE_RISCV64_BUILDS: ${{ vars.ENABLE_RISCV64_BUILDS }} run: | + # patch-sync-baseline:start + patch_sync_baseline() { + local architecture="$1" enabled="$2" shared_baseline="$3" patch="$4" kind="$5" + local prefix marker baseline + + if [[ "$architecture" != "riscv64" ]]; then + printf '%s\n' "$shared_baseline" + return 0 + fi + + if [[ "${enabled,,}" != "true" ]]; then + return 0 + fi + + case "$kind" in + commit) prefix="# From upstream commit: " ;; + release) prefix="# From upstream release: " ;; + *) echo "Invalid RISC-V patch marker type: $kind" >&2; return 1 ;; + esac + + if [[ ! -f "$patch" ]]; then + echo "Invalid RISC-V patch marker: missing $patch" >&2 + return 1 + fi + + marker=$(tail -n 1 "$patch") + baseline=${marker#"$prefix"} + if [[ "$marker" != "$prefix"* || -z "$baseline" ]] || + [[ "$kind" == "commit" && ! "$baseline" =~ ^([0-9a-f]{40}|[0-9a-f]{64})$ ]] || + [[ "$kind" == "release" && ! "$baseline" =~ ^v[0-9][0-9A-Za-z.+_-]*$ ]]; then + echo "Invalid RISC-V patch marker in $patch" >&2 + return 1 + fi + + printf '%s\n' "$baseline" + } + # patch-sync-baseline:end + mkdir -p patches touch successful_arches.txt for arch in ppc64le s390x arm riscv64; do - patch_baseline=$(bash .github/scripts/patch-sync-baseline.sh "$arch" "${ENABLE_RISCV64_BUILDS:-}" "${{ steps.get-tags.outputs.PREVIOUS_TAG }}" "patches/runner-sdk8-$arch.patch" release) + patch_baseline=$(patch_sync_baseline "$arch" "${ENABLE_RISCV64_BUILDS:-}" "${{ steps.get-tags.outputs.PREVIOUS_TAG }}" "patches/runner-sdk8-$arch.patch" release) if [[ -z "$patch_baseline" ]]; then echo "Skipping $arch while RISC-V builds are disabled" continue diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0400c0532ef..39f6caabc25 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -91,7 +91,26 @@ jobs: - name: Install community RISC-V DotNet SDK if: matrix.runtime == 'linux-riscv64' - run: bash .github/scripts/setup-riscv64-dotnet.sh + run: | + # riscv64-dotnet-setup:start + set -euo pipefail + + version=10.0.115 + sha256=f06bcd3f7cff2781711150ae817190ce67d630b075be0b0aedeb021049c8a0d4 + archive="${RUNNER_TEMP:?}/dotnet-sdk-${version}-linux-riscv64.tar.gz" + sdk_dir="${RUNNER_TEMP}/dotnet-riscv64-${version}" + + curl -fsSL --retry 3 -o "$archive" \ + "https://github.com/filipnavara/dotnet-riscv/releases/download/${version}/dotnet-sdk-${version}-linux-riscv64.tar.gz" + printf '%s %s\n' "$sha256" "$archive" | sha256sum --check + mkdir -p "$sdk_dir" + tar -xzf "$archive" -C "$sdk_dir" + rm "$archive" + + "$sdk_dir/dotnet" --version + echo "$sdk_dir" >> "${GITHUB_PATH:?}" + echo "DOTNET_ROOT=$sdk_dir" >> "${GITHUB_ENV:?}" + # riscv64-dotnet-setup:end - name: Apply patches if: matrix.runtime == 'linux-s390x' || matrix.runtime == 'linux-ppc64le' || matrix.runtime == 'linux-arm' || matrix.runtime == 'linux-riscv64' @@ -131,6 +150,10 @@ jobs: fi .github/scripts/strip-bundled-npm.sh _layout ${{ matrix.runtime }} + - name: Apply workflow test patch + if: matrix.runtime == 'linux-riscv64' + run: git apply patches/patch-sync-l0.patch + - name: RISC-V L0 if: matrix.runtime == 'linux-riscv64' working-directory: src diff --git a/docs/riscv64.md b/docs/riscv64.md deleted file mode 100644 index 01c2d91f404..00000000000 --- a/docs/riscv64.md +++ /dev/null @@ -1,63 +0,0 @@ -# Linux RISC-V 64 runner - -The RISC-V runner is an unofficial build. It uses the community -[.NET 10 SDK](https://github.com/filipnavara/dotnet-riscv) and the Node.js -[unofficial RISC-V builds](https://unofficial-builds.nodejs.org/). Neither is -an official Microsoft-supported RISC-V runner runtime. Track their security -updates and update the SDK version, archive checksum, Node versions and Node -checksums together when upgrading. - -## Build on RISC-V - -Apply `patches/runner-main-sdk8-riscv64.patch` for the current main source, or -`patches/runner-sdk8-riscv64.patch` for the corresponding upstream release -source. The patch names follow the existing architecture-patch convention; -the RISC-V target uses .NET 10, not .NET 8. - -Install the community SDK and its included runtime packs in a separate -directory, then put its `dotnet` on `PATH`: - -```sh -version=10.0.115 -archive="dotnet-sdk-${version}-linux-riscv64.tar.gz" -curl -fLO "https://github.com/filipnavara/dotnet-riscv/releases/download/${version}/${archive}" -echo "f06bcd3f7cff2781711150ae817190ce67d630b075be0b0aedeb021049c8a0d4 ${archive}" | sha256sum --check -mkdir -p "$HOME/dotnet-riscv64" -tar -xzf "$archive" -C "$HOME/dotnet-riscv64" -export DOTNET_ROOT="$HOME/dotnet-riscv64" -export PATH="$DOTNET_ROOT:$PATH" -cd src -./dev.sh layout Release linux-riscv64 -../.github/scripts/strip-bundled-npm.sh ../_layout linux-riscv64 -./dev.sh test -./dev.sh package Release linux-riscv64 -``` - -The SDK must be installed separately from .NET 8 so the RISC-V build does not -select the .NET 8 SDK. Only Node 24 is bundled, and its archive is -checksum-verified before extraction. The resulting archive is -`_package/actions-runner-linux-riscv64-.tar.gz`. - -Actions requesting Node 12, 16 or 20 run with Node 24 on RISC-V, even when -Node 20 is explicitly enabled by an environment variable. The internal Node -runtime also falls back to Node 24 if Node 20 is requested. Older actions may -be incompatible with Node 24 and may need to be updated. - -## Enable CI and releases - -CI and releases do not schedule RISC-V builds by default. Once a native -Ubuntu 24.04 RISC-V builder with the self-hosted labels `noble`, `generic` and -`riscv64` is available, refresh and check both RISC-V patches against the -current main source and latest upstream release before setting the repository -variable `ENABLE_RISCV64_BUILDS` to `true`. Patch synchronization skips RISC-V -while disabled and uses each RISC-V patch's own source marker when enabled. -Enabling the variable does not itself refresh stale patches; update the pinned -Node checksum when porting to a new Node version. -Enabled releases run the RISC-V L0 tests and package smoke test, then publish -the archive and its SHA-256 checksum. - -Configure RISC-V runners with `--disableupdate` and maintain timely upgrades -from this repository's releases; GitHub's official runner download service -does not provide this fork's RISC-V package. Individual actions, container -images and tools used by jobs also need RISC-V support. JavaScript actions in -Alpine job containers are not supported on non-x64 runners. diff --git a/patches/patch-sync-l0.patch b/patches/patch-sync-l0.patch new file mode 100644 index 00000000000..ccd6f8ea92c --- /dev/null +++ b/patches/patch-sync-l0.patch @@ -0,0 +1,303 @@ +diff --git a/src/Test/L0/DotnetsdkDownloadScriptL0.cs b/src/Test/L0/DotnetsdkDownloadScriptL0.cs +index 9d3fbd2..be17541 100644 +--- a/src/Test/L0/DotnetsdkDownloadScriptL0.cs ++++ b/src/Test/L0/DotnetsdkDownloadScriptL0.cs +@@ -7,4 +7,298 @@ using System; + namespace GitHub.Runner.Common.Tests + { ++#if OS_LINUX ++ public sealed class PatchSyncL0 ++ { ++ private static readonly string[] SyncWorkflows = { "patch_update_main.yml", "patch_update_release.yml" }; ++ ++ [Theory] ++ [InlineData("")] ++ [InlineData("false")] ++ [InlineData("true ")] ++ [InlineData("1")] ++ [Trait("Level", "L0")] ++ [Trait("Category", "Common")] ++ public void DisabledRiscVDoesNotRequireAPatch(string enabled) ++ { ++ foreach (string workflow in SyncWorkflows) ++ { ++ var result = GetBaseline(workflow, "riscv64", enabled, "global", "missing.patch", "commit"); ++ ++ Assert.Equal(0, result.ExitCode); ++ Assert.Equal(string.Empty, result.Output); ++ } ++ } ++ ++ [Theory] ++ [InlineData("ppc64le", "false")] ++ [InlineData("s390x", "true")] ++ [InlineData("arm", "")] ++ [Trait("Level", "L0")] ++ [Trait("Category", "Common")] ++ public void ExistingArchitecturesKeepTheSharedBaseline(string architecture, string enabled) ++ { ++ foreach (string workflow in SyncWorkflows) ++ { ++ var result = GetBaseline(workflow, architecture, enabled, "global", "missing.patch", "commit"); ++ ++ Assert.Equal(0, result.ExitCode); ++ Assert.Equal("global", result.Output); ++ } ++ } ++ ++ [Theory] ++ [InlineData("true", "commit", "# From upstream commit: 0123456789abcdef0123456789abcdef01234567", "0123456789abcdef0123456789abcdef01234567")] ++ [InlineData("TRUE", "commit", "# From upstream commit: 0123456789abcdef0123456789abcdef01234567", "0123456789abcdef0123456789abcdef01234567")] ++ [InlineData("True", "release", "# From upstream release: v2.338.2", "v2.338.2")] ++ [InlineData("tRuE", "release", "# From upstream release: v2.338.2", "v2.338.2")] ++ [InlineData("true", "commit", "# From upstream commit: 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef")] ++ [Trait("Level", "L0")] ++ [Trait("Category", "Common")] ++ public void EnabledRiscVUsesItsOwnPatchBaseline(string enabled, string kind, string marker, string expected) ++ { ++ string patch = Path.GetTempFileName(); ++ try ++ { ++ File.WriteAllText(patch, $"diff --git a/file b/file\n{marker}\n"); ++ ++ foreach (string workflow in SyncWorkflows) ++ { ++ var result = GetBaseline(workflow, "riscv64", enabled, "newer-global", patch, kind); ++ ++ Assert.Equal(0, result.ExitCode); ++ Assert.Equal(expected, result.Output); ++ } ++ } ++ finally ++ { ++ File.Delete(patch); ++ } ++ } ++ ++ [Theory] ++ [InlineData("commit", "# From upstream release: v2.338.2")] ++ [InlineData("commit", "# From upstream commit: not-a-commit")] ++ [InlineData("release", "# From upstream release: ")] ++ [InlineData("release", "# From upstream release: -not-a-tag")] ++ [Trait("Level", "L0")] ++ [Trait("Category", "Common")] ++ public void EnabledRiscVRejectsInvalidPatchMarkers(string kind, string marker) ++ { ++ string patch = Path.GetTempFileName(); ++ try ++ { ++ File.WriteAllText(patch, $"{marker}\n"); ++ ++ foreach (string workflow in SyncWorkflows) ++ { ++ var result = GetBaseline(workflow, "riscv64", "true", "global", patch, kind); ++ ++ Assert.NotEqual(0, result.ExitCode); ++ Assert.Contains("Invalid RISC-V patch marker", result.Error); ++ } ++ } ++ finally ++ { ++ File.Delete(patch); ++ } ++ } ++ ++ [Fact] ++ [Trait("Level", "L0")] ++ [Trait("Category", "Common")] ++ public void EnabledRiscVRejectsMissingPatch() ++ { ++ string patch = Path.Combine(Path.GetTempPath(), $"missing-{Guid.NewGuid():N}.patch"); ++ ++ foreach (string workflow in SyncWorkflows) ++ { ++ var result = GetBaseline(workflow, "riscv64", "true", "global", patch, "commit"); ++ ++ Assert.NotEqual(0, result.ExitCode); ++ Assert.Contains("Invalid RISC-V patch marker", result.Error); ++ } ++ } ++ ++ [Theory] ++ [InlineData("")] ++ [InlineData("false")] ++ [InlineData("true ")] ++ [InlineData("1")] ++ [Trait("Level", "L0")] ++ [Trait("Category", "Common")] ++ public void StaleWorkflowTestPatchDoesNotBlockDisabledRiscV(string enabled) ++ { ++ string temp = CreateTestPatchFixture("changed\n"); ++ try ++ { ++ var result = ApplyTestPatch(temp, enabled); ++ ++ Assert.Equal(0, result.ExitCode); ++ Assert.Contains("::warning::", result.Output); ++ Assert.Equal("changed\n", File.ReadAllText(Path.Combine(temp, "input"))); ++ } ++ finally ++ { ++ Directory.Delete(temp, recursive: true); ++ } ++ } ++ ++ [Theory] ++ [InlineData("true")] ++ [InlineData("TRUE")] ++ [InlineData("True")] ++ [Trait("Level", "L0")] ++ [Trait("Category", "Common")] ++ public void StaleWorkflowTestPatchBlocksEnabledRiscV(string enabled) ++ { ++ string temp = CreateTestPatchFixture("changed\n"); ++ try ++ { ++ var result = ApplyTestPatch(temp, enabled); ++ ++ Assert.NotEqual(0, result.ExitCode); ++ Assert.Contains("::error::", result.Output); ++ Assert.Equal("changed\n", File.ReadAllText(Path.Combine(temp, "input"))); ++ } ++ finally ++ { ++ Directory.Delete(temp, recursive: true); ++ } ++ } ++ ++ [Theory] ++ [InlineData("")] ++ [InlineData("TRUE")] ++ [Trait("Level", "L0")] ++ [Trait("Category", "Common")] ++ public void CompatibleWorkflowTestPatchIsApplied(string enabled) ++ { ++ string temp = CreateTestPatchFixture("before\n"); ++ try ++ { ++ var result = ApplyTestPatch(temp, enabled); ++ ++ Assert.Equal(0, result.ExitCode); ++ Assert.Equal("after\n", File.ReadAllText(Path.Combine(temp, "input"))); ++ } ++ finally ++ { ++ Directory.Delete(temp, recursive: true); ++ } ++ } ++ ++ [Theory] ++ [InlineData("build.yml")] ++ [InlineData("release.yml")] ++ [Trait("Level", "L0")] ++ [Trait("Category", "Common")] ++ public void DotnetSetupRejectsUnverifiedArchives(string workflow) ++ { ++ string temp = Path.Combine(Path.GetTempPath(), $"riscv-dotnet-{Guid.NewGuid():N}"); ++ string tools = Path.Combine(temp, "bin"); ++ string githubEnv = Path.Combine(temp, "github-env"); ++ string githubPath = Path.Combine(temp, "github-path"); ++ Directory.CreateDirectory(tools); ++ ++ try ++ { ++ string curl = Path.Combine(tools, "curl"); ++ File.WriteAllText(curl, "#!/bin/sh\nwhile [ \"$#\" -gt 0 ]; do\n if [ \"$1\" = -o ]; then shift; printf corrupt > \"$1\"; exit 0; fi\n shift\ndone\nexit 1\n"); ++ if (!OperatingSystem.IsWindows()) ++ { ++ File.SetUnixFileMode(curl, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); ++ } ++ ++ string script = GetWorkflowBlock(workflow, "riscv64-dotnet-setup"); ++ var result = RunShell(script, Array.Empty(), startInfo => ++ { ++ startInfo.Environment["PATH"] = $"{tools}:{Environment.GetEnvironmentVariable("PATH")}"; ++ startInfo.Environment["RUNNER_TEMP"] = temp; ++ startInfo.Environment["GITHUB_ENV"] = githubEnv; ++ startInfo.Environment["GITHUB_PATH"] = githubPath; ++ }); ++ ++ Assert.NotEqual(0, result.ExitCode); ++ Assert.Contains("FAILED", result.Output); ++ Assert.False(File.Exists(githubEnv)); ++ Assert.False(File.Exists(githubPath)); ++ Assert.False(Directory.Exists(Path.Combine(temp, "dotnet-riscv64-10.0.115"))); ++ } ++ finally ++ { ++ Directory.Delete(temp, recursive: true); ++ } ++ } ++ ++ private static (int ExitCode, string Output, string Error) GetBaseline(string workflow, params string[] arguments) ++ { ++ string script = GetWorkflowBlock(workflow, "patch-sync-baseline"); ++ return RunShell($"{script}\npatch_sync_baseline \"$@\"", arguments); ++ } ++ ++ private static string CreateTestPatchFixture(string contents) ++ { ++ string temp = Path.Combine(Path.GetTempPath(), $"workflow-test-patch-{Guid.NewGuid():N}"); ++ Directory.CreateDirectory(temp); ++ File.WriteAllText(Path.Combine(temp, "input"), contents); ++ File.WriteAllText(Path.Combine(temp, "test.patch"), "diff --git a/input b/input\n--- a/input\n+++ b/input\n@@ -1 +1 @@\n-before\n+after\n"); ++ return temp; ++ } ++ ++ private static (int ExitCode, string Output, string Error) ApplyTestPatch(string temp, string enabled) ++ { ++ string script = GetWorkflowBlock("build.yml", "workflow-test-patch"); ++ return RunShell($"{script}\napply_workflow_test_patch \"$@\"", new[] { enabled, "test.patch" }, startInfo => ++ { ++ startInfo.WorkingDirectory = temp; ++ }); ++ } ++ ++ private static string GetWorkflowBlock(string workflow, string marker) ++ { ++ string path = Path.GetFullPath(Path.Combine(TestUtil.GetSrcPath(), "..", ".github", "workflows", workflow)); ++ string[] lines = File.ReadAllLines(path); ++ int start = Array.FindIndex(lines, line => line.Trim() == $"# {marker}:start"); ++ int end = Array.FindIndex(lines, line => line.Trim() == $"# {marker}:end"); ++ Assert.True(start >= 0 && end > start, $"Missing {marker} block in {workflow}"); ++ ++ var script = new System.Text.StringBuilder(); ++ for (int i = start + 1; i < end; i++) ++ { ++ script.AppendLine(lines[i].TrimStart()); ++ } ++ ++ return script.ToString(); ++ } ++ ++ private static (int ExitCode, string Output, string Error) RunShell( ++ string script, ++ string[] arguments, ++ Action configure = null) ++ { ++ var startInfo = new System.Diagnostics.ProcessStartInfo("bash") ++ { ++ RedirectStandardOutput = true, ++ RedirectStandardError = true, ++ UseShellExecute = false, ++ }; ++ startInfo.ArgumentList.Add("-c"); ++ startInfo.ArgumentList.Add($"set -euo pipefail\n{script}"); ++ startInfo.ArgumentList.Add("workflow-test"); ++ foreach (string argument in arguments) ++ { ++ startInfo.ArgumentList.Add(argument); ++ } ++ ++ configure?.Invoke(startInfo); ++ using var process = System.Diagnostics.Process.Start(startInfo); ++ string output = process.StandardOutput.ReadToEnd().TrimEnd('\r', '\n'); ++ string error = process.StandardError.ReadToEnd(); ++ process.WaitForExit(); ++ return (process.ExitCode, output, error); ++ } ++ } ++#endif ++ + public sealed class DotnetsdkDownloadScriptL0 + { diff --git a/src/Test/L0/Workflow/PatchSyncL0.cs b/src/Test/L0/Workflow/PatchSyncL0.cs deleted file mode 100644 index ac33dc936ef..00000000000 --- a/src/Test/L0/Workflow/PatchSyncL0.cs +++ /dev/null @@ -1,113 +0,0 @@ -#if OS_LINUX -using System; -using System.Diagnostics; -using System.IO; -using Xunit; - -namespace GitHub.Runner.Common.Tests.Workflow -{ - public sealed class PatchSyncL0 - { - [Theory] - [InlineData("")] - [InlineData("false")] - [InlineData("true ")] - [InlineData("1")] - [Trait("Level", "L0")] - [Trait("Category", "Common")] - public void DisabledRiscVDoesNotRequireAPatch(string enabled) - { - var result = GetBaseline("riscv64", enabled, "global", "missing.patch", "commit"); - - Assert.Equal(0, result.ExitCode); - Assert.Equal(string.Empty, result.Output); - } - - [Theory] - [InlineData("ppc64le", "false")] - [InlineData("s390x", "true")] - [InlineData("arm", "")] - [Trait("Level", "L0")] - [Trait("Category", "Common")] - public void ExistingArchitecturesKeepTheSharedBaseline(string architecture, string enabled) - { - var result = GetBaseline(architecture, enabled, "global", "missing.patch", "commit"); - - Assert.Equal(0, result.ExitCode); - Assert.Equal("global", result.Output); - } - - [Theory] - [InlineData("true", "commit", "# From upstream commit: 0123456789abcdef0123456789abcdef01234567", "0123456789abcdef0123456789abcdef01234567")] - [InlineData("TRUE", "commit", "# From upstream commit: 0123456789abcdef0123456789abcdef01234567", "0123456789abcdef0123456789abcdef01234567")] - [InlineData("True", "release", "# From upstream release: v2.338.2", "v2.338.2")] - [InlineData("tRuE", "release", "# From upstream release: v2.338.2", "v2.338.2")] - [Trait("Level", "L0")] - [Trait("Category", "Common")] - public void EnabledRiscVUsesItsOwnPatchBaseline(string enabled, string kind, string marker, string expected) - { - string patch = Path.GetTempFileName(); - try - { - File.WriteAllText(patch, $"diff --git a/file b/file\n{marker}\n"); - - var result = GetBaseline("riscv64", enabled, "newer-global", patch, kind); - - Assert.Equal(0, result.ExitCode); - Assert.Equal(expected, result.Output); - } - finally - { - File.Delete(patch); - } - } - - [Theory] - [InlineData("commit", "# From upstream release: v2.338.2")] - [InlineData("commit", "# From upstream commit: not-a-commit")] - [InlineData("release", "# From upstream release: ")] - [InlineData("release", "# From upstream release: -not-a-tag")] - [Trait("Level", "L0")] - [Trait("Category", "Common")] - public void EnabledRiscVRejectsInvalidPatchMarkers(string kind, string marker) - { - string patch = Path.GetTempFileName(); - try - { - File.WriteAllText(patch, $"{marker}\n"); - - var result = GetBaseline("riscv64", "true", "global", patch, kind); - - Assert.NotEqual(0, result.ExitCode); - Assert.Contains("Invalid RISC-V patch marker", result.Error); - } - finally - { - File.Delete(patch); - } - } - - private static (int ExitCode, string Output, string Error) GetBaseline(params string[] arguments) - { - string script = Path.GetFullPath(Path.Combine(TestUtil.GetSrcPath(), "..", ".github", "scripts", "patch-sync-baseline.sh")); - var startInfo = new ProcessStartInfo("bash") - { - RedirectStandardOutput = true, - RedirectStandardError = true, - UseShellExecute = false, - }; - startInfo.ArgumentList.Add(script); - foreach (string argument in arguments) - { - startInfo.ArgumentList.Add(argument); - } - - using var process = Process.Start(startInfo); - string output = process.StandardOutput.ReadToEnd().TrimEnd('\r', '\n'); - string error = process.StandardError.ReadToEnd(); - process.WaitForExit(); - return (process.ExitCode, output, error); - } - } -} -#endif