Skip to content
76 changes: 76 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ on:
workflow_dispatch:
workflow_call: # Allow this workflow to be called by other workflows

permissions:
packages: write # Required for vcpkg binary caching with GitHub Packages

jobs:
build:
runs-on: ${{ matrix.os }}

env:
VCPKG_BINARY_SOURCES: "clear;nuget,https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json,readwrite"

strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
Expand Down Expand Up @@ -89,6 +95,75 @@ jobs:
run: ./bootstrap-vcpkg.bat
working-directory: ${{ github.workspace }}/vcpkg

- name: Install mono for NuGet (Linux)
if: runner.os != 'Windows'
run: sudo apt-get install -y mono-complete

- name: Install buildcache (Linux)
if: runner.os != 'Windows'
run: |
wget https://github.com/mbitsnbites/buildcache/releases/download/v0.28.1/buildcache-linux.tar.gz
tar -xzf buildcache-linux.tar.gz
sudo cp buildcache/bin/buildcache /usr/local/bin/
buildcache --version

- name: Install buildcache (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
Invoke-WebRequest -Uri "https://github.com/mbitsnbites/buildcache/releases/download/v0.28.1/buildcache-windows.zip" -OutFile "buildcache.zip"
Expand-Archive -Path "buildcache.zip" -DestinationPath "buildcache" -Force
Copy-Item -Path "buildcache\buildcache\bin\buildcache.exe" -Destination "C:\Windows\System32\buildcache.exe" -Force
buildcache --version
Comment on lines +116 to +117
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copying to C:\Windows\System32\ requires elevated permissions and may fail in GitHub Actions runners. Consider using a location in the PATH that doesn't require admin rights, such as adding the buildcache directory to $env:PATH or using a user-accessible directory.

Suggested change
Copy-Item -Path "buildcache\buildcache\bin\buildcache.exe" -Destination "C:\Windows\System32\buildcache.exe" -Force
buildcache --version
echo "$env:GITHUB_WORKSPACE\buildcache\buildcache\bin" | Out-File -Append -FilePath $env:GITHUB_PATH
buildcache\buildcache\bin\buildcache.exe --version

Copilot uses AI. Check for mistakes.

- name: Cache buildcache (Linux)
if: runner.os != 'Windows'
uses: actions/cache@v4
with:
path: ~/.buildcache
key: buildcache-${{ matrix.os }}-${{ matrix.c_compiler }}-${{ github.sha }}
restore-keys: |
buildcache-${{ matrix.os }}-${{ matrix.c_compiler }}-
Comment on lines +124 to +126
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cache key includes github.sha which means a new cache entry is created for every commit, preventing effective cache reuse across commits. Consider using a more stable key like the hash of dependency files or remove github.sha to allow cache hits across commits: key: buildcache-${{ matrix.os }}-${{ matrix.c_compiler }}-${{ hashFiles('**/vcpkg.json') }}

Copilot uses AI. Check for mistakes.

- name: Cache buildcache (Windows)
if: runner.os == 'Windows'
uses: actions/cache@v4
with:
path: ~\AppData\Local\buildcache
key: buildcache-${{ matrix.os }}-${{ matrix.c_compiler }}-${{ github.sha }}
restore-keys: |
buildcache-${{ matrix.os }}-${{ matrix.c_compiler }}-
Comment on lines +133 to +135
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as the Linux buildcache configuration. The cache key includes github.sha which creates a new entry for every commit. Use a more stable key to improve cache hit rate: key: buildcache-${{ matrix.os }}-${{ matrix.c_compiler }}-${{ hashFiles('**/vcpkg.json') }}

Copilot uses AI. Check for mistakes.

- name: Setup NuGet authentication for vcpkg binary caching (Linux)
if: runner.os != 'Windows'
shell: bash
run: |
mono `${{ github.workspace }}/vcpkg/vcpkg fetch nuget | tail -n 1` \
sources add \
-Source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \
-StorePasswordInClearText \
-Name GitHubPackages \
-UserName "${{ github.repository_owner }}" \
-Password "${{ secrets.GITHUB_TOKEN }}"
mono `${{ github.workspace }}/vcpkg/vcpkg fetch nuget | tail -n 1` \
Comment on lines +141 to +148
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command substitution syntax is incorrect for bash. Use $(...) instead of backticks when the substitution contains ${{ }} GitHub Actions expressions. The backticks will cause shell parsing issues. Change to: mono $(vcpkg/vcpkg fetch nuget | tail -n 1)

Suggested change
mono `${{ github.workspace }}/vcpkg/vcpkg fetch nuget | tail -n 1` \
sources add \
-Source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \
-StorePasswordInClearText \
-Name GitHubPackages \
-UserName "${{ github.repository_owner }}" \
-Password "${{ secrets.GITHUB_TOKEN }}"
mono `${{ github.workspace }}/vcpkg/vcpkg fetch nuget | tail -n 1` \
mono $(${{ github.workspace }}/vcpkg/vcpkg fetch nuget | tail -n 1) \
sources add \
-Source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \
-StorePasswordInClearText \
-Name GitHubPackages \
-UserName "${{ github.repository_owner }}" \
-Password "${{ secrets.GITHUB_TOKEN }}"
mono $(${{ github.workspace }}/vcpkg/vcpkg fetch nuget | tail -n 1) \

Copilot uses AI. Check for mistakes.
Comment on lines +141 to +148
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same command substitution syntax issue as above. Use $(...) instead of backticks. Change to: mono $(vcpkg/vcpkg fetch nuget | tail -n 1)

Suggested change
mono `${{ github.workspace }}/vcpkg/vcpkg fetch nuget | tail -n 1` \
sources add \
-Source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \
-StorePasswordInClearText \
-Name GitHubPackages \
-UserName "${{ github.repository_owner }}" \
-Password "${{ secrets.GITHUB_TOKEN }}"
mono `${{ github.workspace }}/vcpkg/vcpkg fetch nuget | tail -n 1` \
mono $(${{ github.workspace }}/vcpkg/vcpkg fetch nuget | tail -n 1) \
sources add \
-Source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \
-StorePasswordInClearText \
-Name GitHubPackages \
-UserName "${{ github.repository_owner }}" \
-Password "${{ secrets.GITHUB_TOKEN }}"
mono $(${{ github.workspace }}/vcpkg/vcpkg fetch nuget | tail -n 1) \

Copilot uses AI. Check for mistakes.
setapikey "${{ secrets.GITHUB_TOKEN }}" \
-Source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"

- name: Setup NuGet authentication for vcpkg binary caching (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
& "$(${{ github.workspace }}/vcpkg/vcpkg fetch nuget)" `
sources add `
-Source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" `
-StorePasswordInClearText `
-Name GitHubPackages `
-UserName "${{ github.repository_owner }}" `
-Password "${{ secrets.GITHUB_TOKEN }}"
& "$(${{ github.workspace }}/vcpkg/vcpkg fetch nuget)" `
Comment on lines +156 to +163
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PowerShell syntax is incorrect. The $(...) should wrap the entire command execution, not be used to concatenate strings with GitHub Actions expressions. Change to: & \"$(vcpkg/vcpkg fetch nuget)\" or use proper string interpolation.

Suggested change
& "$(${{ github.workspace }}/vcpkg/vcpkg fetch nuget)" `
sources add `
-Source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" `
-StorePasswordInClearText `
-Name GitHubPackages `
-UserName "${{ github.repository_owner }}" `
-Password "${{ secrets.GITHUB_TOKEN }}"
& "$(${{ github.workspace }}/vcpkg/vcpkg fetch nuget)" `
& "$(${{ github.workspace }}\vcpkg\vcpkg fetch nuget)" `
sources add `
-Source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" `
-StorePasswordInClearText `
-Name GitHubPackages `
-UserName "${{ github.repository_owner }}" `
-Password "${{ secrets.GITHUB_TOKEN }}"
& "$(${{ github.workspace }}\vcpkg\vcpkg fetch nuget)" `

Copilot uses AI. Check for mistakes.
Comment on lines +156 to +163
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same PowerShell syntax issue as above. The $(...) should wrap the entire command execution. Change to: & \"$(vcpkg/vcpkg fetch nuget)\" or use proper string interpolation.

Suggested change
& "$(${{ github.workspace }}/vcpkg/vcpkg fetch nuget)" `
sources add `
-Source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" `
-StorePasswordInClearText `
-Name GitHubPackages `
-UserName "${{ github.repository_owner }}" `
-Password "${{ secrets.GITHUB_TOKEN }}"
& "$(${{ github.workspace }}/vcpkg/vcpkg fetch nuget)" `
& "$(& '${{ github.workspace }}/vcpkg/vcpkg fetch nuget')" `
sources add `
-Source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" `
-StorePasswordInClearText `
-Name GitHubPackages `
-UserName "${{ github.repository_owner }}" `
-Password "${{ secrets.GITHUB_TOKEN }}"
& "$(& '${{ github.workspace }}/vcpkg/vcpkg fetch nuget')" `

Copilot uses AI. Check for mistakes.
setapikey "${{ secrets.GITHUB_TOKEN }}" `
-Source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
Expand All @@ -104,6 +179,7 @@ jobs:
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DUSE_CACHE=ON
-G Ninja
-S ${{ github.workspace }}/gladius
env:
Expand Down
Loading