From 7373c49e2ef56189411f9d30525269d6a07f6f42 Mon Sep 17 00:00:00 2001 From: Antonis Kordatzakis Date: Sat, 23 May 2026 21:14:55 +0300 Subject: [PATCH] ci: use locked restore and fix step indentation in workflows Changes add `--locked-mode` to `dotnet restore` and `--no-restore` to downstream steps in both workflows, ensuring reproducible builds from the lock file. Also fixes YAML step indentation in the PR workflow. --- .github/workflows/pr-build-test.yml | 64 +++++++++++++------------- .github/workflows/publish-to-nuget.yml | 7 ++- 2 files changed, 37 insertions(+), 34 deletions(-) diff --git a/.github/workflows/pr-build-test.yml b/.github/workflows/pr-build-test.yml index 0aedac9..fff1741 100644 --- a/.github/workflows/pr-build-test.yml +++ b/.github/workflows/pr-build-test.yml @@ -2,9 +2,9 @@ name: Build and Test on PR on: pull_request: - branches: [ main ] + branches: [main] push: - branches: [ main ] + branches: [main] jobs: build-and-test: @@ -12,38 +12,38 @@ jobs: strategy: matrix: - dotnet-version: ['8.0.x'] + dotnet-version: ["8.0.x"] steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup .NET - uses: actions/setup-dotnet@v5 - with: - dotnet-version: ${{ matrix.dotnet-version }} - - - name: Restore dependencies - run: dotnet restore - - - name: Build solution - run: dotnet build --configuration Release --no-restore - - - name: Run tests - run: | - dotnet test --configuration Release --no-build --verbosity normal \ - --results-directory ./TestResults \ - --collect:"XPlat Code Coverage" \ - -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura - - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v5 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: ./TestResults/**/coverage.cobertura.xml - flags: unittests - fail_ci_if_error: false - continue-on-error: true + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v5 + with: + dotnet-version: ${{ matrix.dotnet-version }} + + - name: Restore dependencies + run: dotnet restore --locked-mode + + - name: Build solution + run: dotnet build --configuration Release --no-restore + + - name: Run tests + run: | + dotnet test --configuration Release --no-build --no-restore --verbosity normal \ + --results-directory ./TestResults \ + --collect:"XPlat Code Coverage" \ + -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v5 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./TestResults/**/coverage.cobertura.xml + flags: unittests + fail_ci_if_error: false + continue-on-error: true # https://github.com/actions/setup-dotnet # https://github.com/codecov/codecov-action diff --git a/.github/workflows/publish-to-nuget.yml b/.github/workflows/publish-to-nuget.yml index fdf3fa0..19cb655 100644 --- a/.github/workflows/publish-to-nuget.yml +++ b/.github/workflows/publish-to-nuget.yml @@ -20,11 +20,14 @@ jobs: with: dotnet-version: 8.x + - name: Restore dependencies + run: dotnet restore --locked-mode + - name: Build - run: dotnet build --configuration Release + run: dotnet build --configuration Release --no-restore - name: Pack - run: dotnet pack --configuration Release --no-build -p:Version=${{ inputs.version }} --output ./nupkg + run: dotnet pack --configuration Release --no-build --no-restore -p:Version=${{ inputs.version }} --output ./nupkg - name: Publish run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate