add windows CI #1534
Workflow file for this run
This file contains 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: ci | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
TMPDIR: /tmp | |
CI_MAX_KERNEL_VERSION: '6.11' | |
CI_MAX_EFW_VERSION: '0.20.0' | |
CI_MIN_CLANG_VERSION: '11' | |
go_version: '~1.23' | |
prev_go_version: '~1.22' | |
CGO_ENABLED: '0' | |
# This needs to match whatever Netlify supports. | |
# Also defined in Pipfile. | |
python_version: '~3.8' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
jobs: | |
build-and-lint: | |
name: Build and Lint | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '${{ env.go_version }}' | |
- name: Run golangci-lint | |
uses: golangci/golangci-lint-action@v6.1.1 | |
with: | |
args: "--out-format colored-line-number" | |
- name: Generate and format code | |
run: | | |
make clean && make container-all | |
if ! git diff --exit-code; then | |
echo "found unformatted source files, or generated files are not up to date, run 'make'" >&2 | |
exit 1 | |
fi | |
- name: Test bpf2go | |
run: | | |
sudo apt-get install clang-11 llvm-11 | |
go test -v ./cmd/bpf2go | |
- name: Build examples | |
run: go build -v ./... | |
working-directory: ./examples | |
- name: Cross build windows | |
env: | |
GOOS: windows | |
run: | | |
go build -v ./... | |
go test -c -o /dev/null ./... >/dev/null | |
- name: Cross build arm32 | |
env: | |
GOARCH: arm | |
GOARM: 6 | |
run: | | |
go build -v ./... | |
go test -c -o /dev/null ./... >/dev/null | |
build-docs: | |
name: Build Documentation | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# The mkdocs git-authors plugin needs access to the full revision | |
# history to correctly generate its statistics. | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '${{ env.go_version }}' | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '${{ env.python_version }}' | |
cache: 'pipenv' | |
- name: Install pipenv | |
run: pip3 install pipenv | |
- name: Install Dependencies | |
run: pipenv install | |
working-directory: ./docs | |
- name: Build Documentation | |
run: make build | |
working-directory: ./docs | |
test-on-prev-go: | |
name: Run tests on previous stable Go | |
runs-on: ubuntu-latest | |
needs: build-and-lint | |
timeout-minutes: 15 | |
env: | |
CI_KERNEL_SELFTESTS: '/usr/src/linux/tools/testing/selftests/bpf' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '${{ env.prev_go_version }}' | |
- run: go install lmb.io/vimto@latest | |
- run: go install gotest.tools/gotestsum@v1.8.1 | |
- run: sudo apt-get update && sudo apt-get install -y --no-install-recommends qemu-system-x86 | |
- run: sudo chmod 0666 /dev/kvm | |
- name: Test | |
env: | |
GOTRACEBACK: crash | |
run: | | |
gotestsum --raw-command --ignore-non-json-output-lines --junitfile junit.xml -- vimto -kernel :stable-selftests -- go test -timeout 5m -short -count 1 -json ./... | |
- name: Benchmark | |
run: vimto -kernel :stable-selftests -- go test -short -run '^$' -bench . -benchtime=1x ./... | |
- name: Upload coredumps | |
uses: actions/upload-artifact@v4 | |
if: ${{ failure() }} | |
with: | |
name: cores | |
if-no-files-found: ignore | |
path: | | |
**/core-* | |
**/*.test | |
- name: Upload Test Results | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Test Results (previous stable Go) | |
path: junit.xml | |
test-on-arm64: | |
name: Run tests on arm64 | |
runs-on: ubuntu-22.04-arm64 | |
needs: build-and-lint | |
timeout-minutes: 15 | |
env: | |
EBPF_TEST_IGNORE_VERSION: 'TestKprobeMulti,TestKprobeMultiErrors,TestKprobeMultiCookie,TestKprobeMultiProgramCall,TestHaveBPFLinkKprobeMulti,TestKprobeSession,TestHaveBPFLinkKprobeSession,TestHaveProgramType/LircMode2' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '${{ env.go_version }}' | |
- run: go install gotest.tools/gotestsum@v1.8.1 | |
- name: Test | |
# Skip TestGoarches/loong64 because the GH arm64 Go toolchain seems to be weird. | |
run: gotestsum --ignore-non-json-output-lines --junitfile junit.xml -- -exec 'sudo -E' -short -count 1 -skip '^TestGoarches/loong64$' -json ./... | |
- name: Benchmark | |
run: go test -exec sudo -short -run '^$' -bench . -benchtime=1x ./... | |
- name: Upload Test Results | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Test Results (arm64) | |
path: junit.xml | |
- name: Show dmesg | |
if: failure() | |
run: | | |
sudo dmesg | |
linux-test: | |
name: Run tests (Linux) | |
runs-on: ubuntu-latest | |
needs: build-and-lint | |
timeout-minutes: 15 | |
strategy: | |
matrix: | |
tag: | |
- "mainline" | |
- "stable" | |
- "6.6" | |
- "6.1" | |
- "5.15" | |
- "5.10" | |
- "5.4" | |
- "4.19" | |
- "4.14" | |
- "4.9" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '${{ env.go_version }}' | |
- run: go install gotest.tools/gotestsum@v1.8.1 | |
- run: go install lmb.io/vimto@latest | |
- run: sudo apt-get update && sudo apt-get install -y --no-install-recommends qemu-system-x86 | |
- run: sudo chmod 0666 /dev/kvm | |
- name: Test | |
run: gotestsum --raw-command --ignore-non-json-output-lines --junitfile junit.xml -- vimto -kernel :${{ matrix.tag }} -- go test -short -count 1 -json ./... | |
- name: Upload Test Results | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Test Results (linux ${{ matrix.tag }}) | |
path: junit.xml | |
windows-test: | |
name: Run tests (Windows) | |
runs-on: windows-2022 | |
needs: build-and-lint | |
timeout-minutes: 15 | |
strategy: | |
matrix: | |
version: | |
- "0.20.0" | |
env: | |
# Fix slow Go compile and cache restore | |
# See https://github.com/actions/setup-go/pull/515 | |
GOCACHE: D:\gocache | |
GOMODCACHE: D:\gomodcache | |
GOTMPDIR: D:\gotmp | |
steps: | |
# Go requires gotmp to be present | |
- run: mkdir D:\gotmp | |
shell: pwsh | |
- name: Download and Install eBPF for Windows | |
shell: pwsh | |
run: | | |
Invoke-WebRequest -Uri "https://github.com/microsoft/ebpf-for-windows/releases/download/Release-v${{ matrix.version }}/Build-x64.Debug.zip" -OutFile "$env:TEMP\efw.zip" | |
Expand-Archive -Path "$env:TEMP\efw.zip" -DestinationPath "$env:TEMP\ebpf" | |
Set-Location "$env:TEMP\ebpf" | |
# setup-ebpf.ps1 can't handle spaces in the path to the MSI. | |
mv "Build-x64 Debug" "debug" | |
$setupScript = Get-ChildItem -Path . -Filter "setup-ebpf.ps1" -Recurse | Select-Object -First 1 | |
if ($setupScript) { | |
Write-Host "Found setup script: $($setupScript.FullName)" | |
Set-Location -Path $setupScript.DirectoryName | |
Write-Host "Changed directory to: $(Get-Location)" | |
& $setupScript.FullName | |
# Change service account to SYSTEM, until https://github.com/microsoft/ebpf-for-windows/pull/4095 is in a release. | |
Write-Host "Changing ebpfsvc to run as SYSTEM" | |
sc.exe config ebpfsvc obj= "LocalSystem" | |
sc.exe start ebpfsvc | |
} else { | |
Write-Error "Setup script not found in the extracted package" | |
exit 1 | |
} | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '${{ env.go_version }}' | |
- run: go install gotest.tools/gotestsum@v1.8.1 | |
- name: Test | |
run: gotestsum --raw-command --ignore-non-json-output-lines --junitfile junit.xml -- go test -short -count 1 -json ./asm ./internal ./internal/kallsyms ./internal/kconfig ./internal/sysenc ./internal/testutils ./internal/tracefs | |
- name: Upload Test Results | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Test Results (windows ${{ matrix.tag }}) | |
path: junit.xml | |