-
Notifications
You must be signed in to change notification settings - Fork 22
Add taskfile for building and running tests #192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dmcgowan
wants to merge
6
commits into
containerd:main
Choose a base branch
from
dmcgowan:use-taskfile
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+398
−95
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3e53cbd
Use test binary to get integration test list
dmcgowan 0cd8c4a
Use taskfile to improve cross platform building
dmcgowan d874780
Improve integration test scripts
dmcgowan ca509bc
Update makefile and gha to use taskfile
dmcgowan 11e7057
Clean up libkrun shutdown to fix tests on Windows
dmcgowan df7c08d
Cleanup integration test scripts
dmcgowan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| _output | ||
| kernel/*.old | ||
| .task |
This file contains hidden or 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
This file contains hidden or 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,149 @@ | ||
| version: '3' | ||
|
|
||
| vars: | ||
| OUTPUT_DIR: '_output' | ||
| GO_TAGS: '-tags "no_grpc"' | ||
|
dmcgowan marked this conversation as resolved.
|
||
| LDFLAGS: '-s -w' | ||
| GO_LDFLAGS: '-ldflags "{{.LDFLAGS}}"' | ||
| # Map Go's GOARCH to the kernel arch naming convention (amd64 → x86_64). | ||
| KERNEL_ARCH: | ||
| sh: 'a=$(go env GOARCH); case "$a" in amd64) echo x86_64;; *) echo "$a";; esac' | ||
|
|
||
| tasks: | ||
| default: | ||
| desc: Build all outputs via Docker Buildx Bake | ||
| deps: [build] | ||
|
|
||
| # | ||
| # Build tasks | ||
| # | ||
| build: | ||
| desc: Build all outputs via Docker Buildx Bake | ||
| cmds: | ||
| - HOST_OS={{OS}} KERNEL_ARCH={{.KERNEL_ARCH}} docker buildx bake | ||
|
|
||
| build:shim: | ||
| desc: Build containerd-shim-nerdbox-v1 for the current platform | ||
| cmds: | ||
| - mkdir -p {{.OUTPUT_DIR}} | ||
| - go build {{.GO_TAGS}} {{.GO_LDFLAGS}} -o {{.OUTPUT_DIR}}/containerd-shim-nerdbox-v1{{if eq OS "windows"}}.exe{{end}} ./cmd/containerd-shim-nerdbox-v1 | ||
| - cmd: codesign --entitlements cmd/containerd-shim-nerdbox-v1/containerd-shim-nerdbox-v1.entitlements --force -s - {{.OUTPUT_DIR}}/containerd-shim-nerdbox-v1 | ||
| platforms: [darwin] | ||
|
|
||
| build:guest: | ||
| desc: Build guest artifacts (kernel and initrd) via Docker Buildx Bake | ||
| cmds: | ||
| - KERNEL_ARCH={{.KERNEL_ARCH}} docker buildx bake kernel initrd | ||
|
|
||
| build:initrd: | ||
| desc: Build the nerdbox initrd via Docker Buildx Bake | ||
| cmds: | ||
| - KERNEL_ARCH={{.KERNEL_ARCH}} docker buildx bake initrd | ||
|
|
||
| build:integration: | ||
| desc: Build the integration test binary | ||
| cmds: | ||
| - mkdir -p {{.OUTPUT_DIR}} | ||
| - go test -c -o {{.OUTPUT_DIR}}/integration.test{{if eq OS "windows"}}.exe{{end}} {{.GO_LDFLAGS}} {{.GO_TAGS}} ./integration | ||
| - cmd: codesign --entitlements cmd/containerd-shim-nerdbox-v1/containerd-shim-nerdbox-v1.entitlements --force -s - {{.OUTPUT_DIR}}/integration.test | ||
|
dmcgowan marked this conversation as resolved.
|
||
| platforms: [darwin] | ||
|
|
||
| # | ||
| # Test tasks | ||
| # | ||
| test:unit: | ||
| desc: Run unit tests (excludes integration package) | ||
| cmds: | ||
| - go test -count=1 ./api/... ./cmd/... ./internal/... ./pkg/... ./plugins/... | ||
|
dmcgowan marked this conversation as resolved.
dmcgowan marked this conversation as resolved.
dmcgowan marked this conversation as resolved.
|
||
|
|
||
| test:integration: | ||
| desc: "Run integration tests (each test in its own process). Extra flags are forwarded to the test binary: task test:integration -- -run TestSystemInfo -v" | ||
| deps: [build:integration] | ||
| vars: | ||
| # When -v is in the extra flags, switch gotestsum to standard-verbose so | ||
| # t.Log() output is shown; otherwise testname format suppresses it. | ||
| GOTESTSUM_FORMAT: | ||
| sh: | | ||
| case " {{.CLI_ARGS}} " in *" -v "*|*" -v") echo standard-verbose ;; *) echo testname ;; esac | ||
| env: | ||
| TESTFLAGS: '{{.CLI_ARGS}}' | ||
| cmds: | ||
| - cmd: gotestsum -f {{.GOTESTSUM_FORMAT}} --raw-command bash integration/test.sh | ||
| platforms: [darwin, linux] | ||
| - cmd: gotestsum -f {{.GOTESTSUM_FORMAT}} --raw-command powershell -ExecutionPolicy Bypass -File integration/test.ps1 | ||
| platforms: [windows] | ||
|
|
||
| # | ||
| # Code quality tasks | ||
| # | ||
| validate: | ||
| desc: Validate via Docker Buildx Bake | ||
| cmds: | ||
| - docker buildx bake validate | ||
|
|
||
| lint: | ||
| desc: Run linters via Docker Buildx Bake | ||
| cmds: | ||
| - docker buildx bake lint | ||
|
|
||
| protos: | ||
| desc: Regenerate protobuf bindings | ||
| dir: api | ||
| cmds: | ||
| - buf generate | ||
|
dmcgowan marked this conversation as resolved.
|
||
| - buf build --exclude-imports -o next.txtpb | ||
| - go-fix-acronym -w -a '^Os' $(find . -name '*.pb.go') | ||
| - go-fix-acronym -w -a '(Id|Io|Uuid|Os)$' $(find . -name '*.pb.go') | ||
|
|
||
| generate: | ||
| desc: Regenerate all derived artifacts (protobuf) | ||
| deps: [protos] | ||
|
|
||
| check-protos: | ||
| desc: Verify protobuf bindings are up to date | ||
| deps: [protos] | ||
| cmds: | ||
| - cmd: | | ||
| if [ -n "$(git status --short | grep ".pb.go")" ]; then | ||
| git diff | cat | ||
| echo "please run 'task protos' when making changes to proto files" | ||
| exit 1 | ||
| fi | ||
|
|
||
| check-api-descriptors: | ||
| desc: Verify protobuf descriptor files are up to date | ||
| deps: [protos] | ||
| cmds: | ||
| - cmd: | | ||
| if [ -n "$(git status --short | grep ".txtpb")" ]; then | ||
| git diff $(find . -name '*.txtpb') | cat | ||
| echo "please run 'task protos' when making changes to proto files and check-in the generated descriptor file changes" | ||
| exit 1 | ||
| fi | ||
|
|
||
| proto-fmt: | ||
| desc: Check proto files use tabs (not spaces) for indentation | ||
| cmds: | ||
| - cmd: | | ||
| if [ -n "$(find . -name '*.proto' -type f -exec grep -Hn -e "^ " {} \;)" ]; then | ||
| echo "please indent proto files with tabs only" | ||
| exit 1 | ||
| fi | ||
|
|
||
| verify-vendor: | ||
| desc: Verify go.mod/go.sum and vendor directory are up to date | ||
| cmds: | ||
| - cmd: | | ||
| tmpdir=$(mktemp -d) | ||
| cp -R . "$tmpdir/nerdbox" | ||
| (cd "$tmpdir/nerdbox" && go mod tidy && go mod verify) | ||
| diff -r -u . "$tmpdir/nerdbox" || (rm -rf "$tmpdir" && exit 1) | ||
| rm -rf "$tmpdir" | ||
|
|
||
| # | ||
| # Clean | ||
| # | ||
| clean: | ||
| desc: Remove all build outputs | ||
| cmds: | ||
| - rm -rf {{.OUTPUT_DIR}} | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.