Skip to content

Fix Snyk workflow failure caused by broad project auto-discovery - #12

Merged
ruslanlap merged 3 commits into
masterfrom
copilot/fix-github-actions-job
Sep 20, 2026
Merged

ruslanlap merged 3 commits into
masterfrom
copilot/fix-github-actions-job

Conversation

Copilot AI commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

The Snyk GitHub Actions job was failing because --all-projects picked up generated NuGet assets under obj/, including a project.assets.json path that depends on a missing PackageOverrides.txt in the runner’s .NET reference packs. This change narrows the workflow to the actual repository projects and avoids scanning transient build output.

  • Scope the scan to real project manifests

    • Replace snyk test --all-projects / snyk monitor --all-projects with explicit scans of:
      • src/Community.PowerToys.Run.Plugin.Templates.csproj
      • tests/Community.PowerToys.Run.Plugin.Templates.Tests.csproj
    • Store the project list once in workflow env to keep scan targets centralized.
  • Restore the intended solution explicitly

    • Change restore from repository-wide discovery to dotnet restore Templates.sln.
    • Keeps dependency resolution aligned with the template/test solution instead of incidental files in the workspace.
  • Harden failure behavior

    • Run test and monitor sequentially per project in PowerShell.
    • Exit immediately on any Snyk command failure rather than continuing through the remaining targets.
env:
  SNYK_PROJECTS: |
    src/Community.PowerToys.Run.Plugin.Templates.csproj
    tests/Community.PowerToys.Run.Plugin.Templates.Tests.csproj

- name: Test and monitor
  shell: pwsh
  run: |
    $projects = $env:SNYK_PROJECTS -split "\r?\n" | Where-Object { $_ }

    foreach ($project in $projects) {
      snyk test --file=$project --package-manager=nuget
      if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

      snyk monitor --file=$project --package-manager=nuget
      if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
    }

Copilot AI and others added 3 commits September 20, 2026 21:39
Co-authored-by: ruslanlap <106077551+ruslanlap@users.noreply.github.com>
Co-authored-by: ruslanlap <106077551+ruslanlap@users.noreply.github.com>
Co-authored-by: ruslanlap <106077551+ruslanlap@users.noreply.github.com>
@ruslanlap
ruslanlap marked this pull request as ready for review September 20, 2026 21:42
@ruslanlap
ruslanlap merged commit 273b16c into master Sep 20, 2026
1 check passed
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