-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
83 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: Go CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
tags: | ||
- '**' | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: 1.13 | ||
|
||
- name: Download Go modules | ||
run: go mod download | ||
|
||
- name: Verify Go modules | ||
run: go mod verify | ||
|
||
- name: Run tests | ||
run: go test ./pkg/hwapi/ | ||
|
||
- name: Build binary | ||
run: go build -ldflags "-X main.gitcommit=${{ github.sha }} -X main.gittag=${{ github.ref_name }}" -o test_pci_walk cmd/test_pci_walk/main.go | ||
|
||
- name: Compile tests | ||
run: go test -c ./pkg/... | ||
|
||
- name: Create output directory | ||
run: mkdir -p out | ||
|
||
- name: Copy test binary to output | ||
run: cp hwapi.test out/ | ||
|
||
- name: Upload output to workspace | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: hwapi-test | ||
path: out/hwapi.test | ||
|
||
test_in_qemu: | ||
runs-on: ubuntu-latest | ||
needs: [build] | ||
|
||
steps: | ||
- name: Download artifact from build job | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: hwapi-test | ||
path: /tmp/out | ||
|
||
- name: Set up QEMU environment | ||
run: | | ||
docker pull 9elements/qemu-linux-runtime | ||
docker run -d --name qemu-runtime 9elements/qemu-linux-runtime tail -f /dev/null | ||
- name: Copy test binary to QEMU container | ||
run: docker cp /tmp/out/hwapi.test qemu-runtime:/repo/scripts/hwapi.test | ||
|
||
- name: Create test script | ||
run: | | ||
echo 'RUN_IN_QEMU=TRUE ./hwapi.test -test.v' > runtest.sh | ||
chmod +x runtest.sh | ||
docker cp runtest.sh qemu-runtime:/repo/scripts/runtest.sh | ||
- name: Run tests in QEMU | ||
run: docker exec -e TERM=xterm-256color qemu-runtime /repo/entrypoint.sh | ||
|
||
- name: Clean up | ||
run: docker stop qemu-runtime && docker rm qemu-runtime |
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