Skip to content

Conversation

@maximn
Copy link
Owner

@maximn maximn commented Sep 19, 2025

Summary

  • Split the GitHub Actions workflow into separate build and test jobs
  • Test job now depends on build job completion (needs: build)
  • Provides better visibility in CI status indicators

Benefits

  • Faster feedback on build failures (no need to wait for tests)
  • Clearer separation of concerns in CI pipeline
  • Two distinct status squares in GitHub UI
  • Standard practice for mature .NET projects

Test plan

  • Workflow file syntax is valid
  • Verify two separate jobs appear in GitHub Actions UI
  • Confirm build failures prevent test execution
  • Ensure tests still run with Google API key

- Separate build and test into distinct GitHub Actions jobs
- Test job depends on build job completion
- Provides better visibility into CI pipeline status
- Enables faster feedback on build vs test failures
Comment on lines 10 to 27
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore

test:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 5 months ago

The fix is to explicitly specify the permissions key for this workflow to restrict the GITHUB_TOKEN permission set according to the principle of least privilege. Since the jobs only perform build and test operations and do not interact with issues, pull requests, or write to the repository, the minimal required permission is contents: read. To ensure that all jobs inherit these settings (unless overridden), add the permissions: block at the root of the workflow, directly under the name (ideally after on:). No other changes, imports, definitions, or logic are needed, as this change is entirely a declarative addition to the workflow YAML.


Suggested changeset 1
.github/workflows/dotnet.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml
--- a/.github/workflows/dotnet.yml
+++ b/.github/workflows/dotnet.yml
@@ -5,6 +5,9 @@
     branches: [ master ]
   pull_request:
 
+permissions:
+  contents: read
+
 jobs:
   build-only:
     runs-on: ubuntu-latest
EOF
@@ -5,6 +5,9 @@
branches: [ master ]
pull_request:

permissions:
contents: read

jobs:
build-only:
runs-on: ubuntu-latest
Copilot is powered by AI and may make mistakes. Always verify output.
@maximn maximn closed this Sep 19, 2025
@maximn maximn deleted the ci/split-build-test-jobs branch September 19, 2025 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants