fix(cd): Add WSL setup and fix LOLWUT assertions for CD pipeline (#…
#28
Workflow file for this run
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: C# CD | |
| on: | |
| push: | |
| tags: | |
| - "v*.*" | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "The release version of GLIDE, formatted as v*.*.* or v*.*.*-rc*" | |
| required: true | |
| nuget_publish: | |
| description: "Publish to NuGet" | |
| required: true | |
| type: boolean | |
| permissions: | |
| contents: read | |
| id-token: write | |
| concurrency: | |
| group: C#-CD-${{ github.head_ref || github.ref }}-${{ toJson(inputs) }} | |
| cancel-in-progress: true | |
| run-name: | |
| # Set custom name if job is started manually and name is given | |
| ${{ github.event_name == 'workflow_dispatch' && (inputs.name == '' && format('{0} @ {1} {2}', github.ref_name, github.sha, toJson(inputs)) || inputs.name) || '' }} | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| load-platform-matrix: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| PLATFORM_MATRIX: ${{ steps.load-platform-matrix.outputs.PLATFORM_MATRIX }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: load-platform-matrix | |
| id: load-platform-matrix | |
| working-directory: .github/json_matrices | |
| run: | | |
| jq -c "[.[] | select(any(.tags[] == \"cd\"; .))]" < os-matrix.json | awk '{ printf "PLATFORM_MATRIX=%s\n", $0 }' | tee -a $GITHUB_OUTPUT | |
| set-release-version: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| RELEASE_VERSION: ${{ steps.release-version.outputs.RELEASE_VERSION }} | |
| steps: | |
| - name: Set the release version | |
| id: release-version | |
| shell: bash | |
| run: | | |
| if ${{ github.event_name == 'workflow_dispatch' }}; then | |
| RAW_VERSION="${{ env.INPUT_VERSION }}" | |
| else | |
| RAW_VERSION=${{ github.ref_name }} | |
| fi | |
| # Strip leading 'v' if present | |
| R_VERSION="${RAW_VERSION#v}" | |
| echo "RELEASE_VERSION=${R_VERSION}" >> $GITHUB_ENV | |
| echo "Release version detected: $R_VERSION (raw: $RAW_VERSION)" | |
| echo "RELEASE_VERSION=$R_VERSION" >> $GITHUB_OUTPUT | |
| env: | |
| INPUT_VERSION: ${{ github.event.inputs.version }} | |
| create-binaries: | |
| needs: [load-platform-matrix] | |
| timeout-minutes: 35 | |
| strategy: | |
| # Run all jobs | |
| fail-fast: false | |
| matrix: | |
| host: ${{ fromJson(needs.load-platform-matrix.outputs.PLATFORM_MATRIX) }} | |
| runs-on: ${{ matrix.host.RUNNER }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: true | |
| - name: Output Matrix Parameters for this job | |
| shell: bash | |
| run: | | |
| echo "Job running with the following matrix configuration:" | |
| echo "${{ toJson(matrix) }}" | |
| - name: Install shared software dependencies | |
| uses: ./.github/workflows/install-shared-dependencies | |
| with: | |
| os: ${{ matrix.host.OS }} | |
| target: ${{ matrix.host.TARGET }} | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: actions/cache@v5 | |
| with: | |
| path: rust/target | |
| key: rust-${{ matrix.host.TARGET }} | |
| - name: Build native libs (linux gnu) | |
| if: ${{ contains(matrix.host.TARGET, 'linux-gnu') }} | |
| working-directory: rust | |
| run: | | |
| cargo zigbuild -r --target ${{ matrix.host.TARGET }}.2.17 | |
| mkdir -p target/release | |
| - name: Build native libs | |
| if: ${{ !contains(matrix.host.TARGET, 'linux-gnu') }} | |
| working-directory: rust | |
| run: cargo build --release --target ${{ matrix.host.TARGET }} | |
| - name: Upload artifacts to publish | |
| continue-on-error: true | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: ${{ matrix.host.TARGET }} | |
| if-no-files-found: error | |
| path: | | |
| rust/target/${{ matrix.host.TARGET }}/release/*.so | |
| rust/target/${{ matrix.host.TARGET }}/release/*.dylib | |
| rust/target/${{ matrix.host.TARGET }}/release/*.dll | |
| build-package-to-publish: | |
| needs: [set-release-version, create-binaries] | |
| runs-on: ubuntu-latest | |
| env: | |
| RELEASE_VERSION: ${{ needs.set-release-version.outputs.RELEASE_VERSION }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Download published artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| path: bin | |
| - name: Rename lib for windows | |
| working-directory: bin | |
| run: | | |
| find . -name glide_rs.dll -execdir mv {} libglide_rs.dll \; | |
| tree -h | |
| - name: Set up dotnet | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| # install all supported versions + latest dotnet too to use language features | |
| dotnet-version: | | |
| 8 | |
| 9 | |
| env: | |
| DOTNET_INSTALL_DIR: ~/.dotnet | |
| - name: Pack the client | |
| working-directory: sources/Valkey.Glide | |
| run: | | |
| dotnet build Valkey.Glide.csproj --configuration Release /property:Version=$RELEASE_VERSION | |
| dotnet pack Valkey.Glide.csproj --configuration Release -p:NuspecProperties=version=$RELEASE_VERSION | |
| tree -h bin/Release | |
| unzip -l bin/Release/Valkey.Glide.$RELEASE_VERSION.nupkg | |
| unzip -l bin/Release/Valkey.Glide.$RELEASE_VERSION.snupkg | |
| env: | |
| SkipCargo: true | |
| - name: Upload artifacts to publish | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: package | |
| if-no-files-found: error | |
| path: sources/Valkey.Glide/bin/Release/Valkey.Glide.*nupkg | |
| publish: | |
| environment: Release | |
| if: ${{ (inputs.nuget_publish == true || github.event_name == 'push') && github.repository_owner == 'valkey-io' }} | |
| needs: [build-package-to-publish, set-release-version] | |
| runs-on: ubuntu-latest | |
| env: | |
| RELEASE_VERSION: ${{ needs.set-release-version.outputs.RELEASE_VERSION }} | |
| steps: | |
| - name: Download package | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: package | |
| - name: Publish | |
| run: | | |
| ls -lh | |
| dotnet nuget push Valkey.Glide.$RELEASE_VERSION.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json | |
| - name: Wait for package to be ready for download | |
| run: | | |
| dotnet new console --name temp-check --output . --framework net8.0 | |
| TIMEOUT=600 # 10 minutes | |
| INTERVAL=10 # 10 seconds | |
| ELAPSED=0 | |
| while [ $ELAPSED -lt $TIMEOUT ]; do | |
| echo "Checking availability... (${ELAPSED}s elapsed)" | |
| if dotnet add package Valkey.Glide --version $RELEASE_VERSION ; then | |
| echo "Package is now available!" | |
| exit 0 | |
| fi | |
| sleep $INTERVAL | |
| ELAPSED=$((ELAPSED + INTERVAL)) | |
| dotnet nuget locals all --clear | |
| done | |
| echo "Timeout: Package is not available after ${TIMEOUT}s" | |
| exit 1 | |
| test: | |
| needs: [publish, set-release-version, load-platform-matrix] | |
| timeout-minutes: 35 | |
| strategy: | |
| # Run all jobs | |
| fail-fast: false | |
| matrix: | |
| host: ${{ fromJson(needs.load-platform-matrix.outputs.PLATFORM_MATRIX) }} | |
| runs-on: ${{ matrix.host.RUNNER }} | |
| env: | |
| RELEASE_VERSION: ${{ needs.set-release-version.outputs.RELEASE_VERSION }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: true | |
| - name: Download package | |
| if: ${{ needs.publish.result == 'skipped' }} | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: package | |
| path: nuget.local | |
| - name: Set up dotnet | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| # install latest dotnet to use language features | |
| dotnet-version: | | |
| 8 | |
| 9 | |
| - name: Set up a local nuget | |
| if: ${{ needs.publish.result == 'skipped' }} | |
| shell: bash | |
| run: | | |
| ls -l $GITHUB_WORKSPACE/nuget.local | |
| dotnet nuget add source $GITHUB_WORKSPACE/nuget.local | |
| dotnet nuget config paths | |
| if [[ "${{ matrix.host.OS }}" != "windows" ]]; then | |
| dotnet nuget config paths | xargs cat | |
| else | |
| cat "C:\\Users\\runneradmin\\AppData\\Roaming\\NuGet\\NuGet.Config" | |
| fi | |
| - name: Patch IT suite to run tests using freshly published version | |
| shell: bash | |
| run: | | |
| # Remove local project references to Valkey.Glide | |
| dotnet remove tests/Valkey.Glide.TestUtils reference sources/Valkey.Glide/Valkey.Glide.csproj | |
| dotnet remove tests/Valkey.Glide.IntegrationTests reference sources/Valkey.Glide/Valkey.Glide.csproj | |
| # Replace with the published NuGet package | |
| dotnet add tests/Valkey.Glide.TestUtils package Valkey.Glide --version $RELEASE_VERSION | |
| dotnet add tests/Valkey.Glide.IntegrationTests package Valkey.Glide --version $RELEASE_VERSION | |
| git diff | |
| - name: Setup WSL (Windows only) | |
| # WSL2 is not available on windows-11-arm runners (no Hyper-V). | |
| if: ${{ matrix.host.OS == 'windows' && matrix.host.ARCH != 'arm64' }} | |
| uses: Vampire/setup-wsl@v7 | |
| with: | |
| distribution: Ubuntu-22.04 | |
| additional-packages: build-essential git make pkg-config libssl-dev | |
| - name: Install server | |
| # WSL2 is not available on windows-11-arm runners (no Hyper-V). | |
| if: ${{ !(matrix.host.OS == 'windows' && matrix.host.ARCH == 'arm64') }} | |
| uses: ./.github/workflows/install-server | |
| with: | |
| os: ${{ matrix.host.OS }} | |
| target: ${{ matrix.host.TARGET }} | |
| server-version: 8.1 | |
| - name: Run command tests | |
| # WSL2 is not available on windows-11-arm runners (no Hyper-V), so we cannot run Valkey server there. | |
| if: ${{ !(matrix.host.OS == 'windows' && matrix.host.ARCH == 'arm64') }} | |
| working-directory: tests/Valkey.Glide.IntegrationTests | |
| run: dotnet test --framework net8.0 --logger "console;verbosity=detailed" --logger "html;LogFileName=TestReport.html" --results-directory . --filter "FullyQualifiedName~CommandTests" | |
| - name: Upload test reports | |
| if: always() | |
| continue-on-error: true | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: test-reports-${{ matrix.host.TARGET }} | |
| path: | | |
| TestReport.html | |
| valkey-glide/utils/clusters/** | |
| remove-package-if-validation-fails: | |
| needs: [publish, test, set-release-version] | |
| if: ${{ !cancelled() }} | |
| runs-on: ubuntu-latest | |
| env: | |
| RELEASE_VERSION: ${{ needs.set-release-version.outputs.RELEASE_VERSION }} | |
| steps: | |
| - name: Remove package from NuGet due to test failures | |
| if: ${{ (needs.test.result == 'failure' && needs.publish.result == 'success') || needs.publish.result == 'failure' }} | |
| run: dotnet nuget delete Valkey.Glide $RELEASE_VERSION --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --non-interactive |