Skip to content

Add taskfile for building and running tests#192

Open
dmcgowan wants to merge 6 commits into
containerd:mainfrom
dmcgowan:use-taskfile
Open

Add taskfile for building and running tests#192
dmcgowan wants to merge 6 commits into
containerd:mainfrom
dmcgowan:use-taskfile

Conversation

@dmcgowan
Copy link
Copy Markdown
Member

Taskfile is better for cross platform building and provides a cleaner interface for defining build functionality.

This cleans up the integration test runners

For example

task test:integration -- -v -run TestStream

Copilot AI review requested due to automatic review settings May 16, 2026 00:03
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a Taskfile.yml to provide a cross-platform task runner interface for building artifacts and running tests, and refactors the integration test runners to support per-test execution with forwarded flags (including a Windows PowerShell runner).

Changes:

  • Add Taskfile.yml with build/test/lint/proto/clean tasks, including integration test support via gotestsum.
  • Update integration/test.sh to discover tests dynamically and forward selected flags.
  • Add integration/test.ps1 for running integration tests on Windows; ignore Task’s .task/ state directory.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 6 comments.

File Description
Taskfile.yml Adds task-based build/test/lint/proto workflows intended to replace/augment Make targets
integration/test.sh Switches integration runner to dynamic test discovery + flag parsing, runs tests one-by-one
integration/test.ps1 New Windows integration runner with per-test process execution and flag parsing
.gitignore Ignores .task/ directory created by Task
Comments suppressed due to low confidence (4)

integration/test.sh:33

  • If test discovery fails or produces zero tests, the script currently exits successfully (loop runs zero times) and also may terminate early because grep returns exit code 1 when there are no matches. It would be safer to handle the -test.list pipeline explicitly (|| true) and then fail with a clear message when tests is empty.
# Discover tests from the binary (respects build tags).
readarray -t tests < <(../_output/integration.test -test.list '.*' 2>/dev/null | grep '^Test')

integration/test.sh:60

  • The -run filtering uses Bash regex matching ([[ ... =~ ... ]]), which doesn’t match Go’s -run/-test.list regexp semantics (RE2). To keep behavior consistent with go test -run, consider passing the pattern to integration.test -test.list <pattern> and using that output as the filtered test list instead of re-implementing matching in Bash.
if [ -n "$run_pattern" ]; then
    filtered=()
    for test in "${tests[@]}"; do
        [[ "$test" =~ $run_pattern ]] && filtered+=("$test")
    done
    tests=("${filtered[@]}")

integration/test.ps1:29

  • When the test binary can’t be executed or -test.list returns nothing, $tests becomes empty and the script will currently report success (no loop iterations). Consider treating an empty test list as an error with a helpful message so CI/local runs don’t silently skip integration tests.
# Discover tests from the binary (respects build tags).
# Pass flags as an array to prevent PowerShell splitting on dots.
$tests = & $testBin @('-test.list', '.*') 2>$null | Where-Object { $_ -match '^Test' }

integration/test.ps1:52

  • The -run filtering uses PowerShell/.NET regex via -match, which can differ from Go’s -run regexp semantics (RE2). For consistency with go test -run, consider discovering tests with -test.list <pattern> (using the provided pattern) instead of filtering the full list with a different regex engine.
# Parse TESTFLAGS forwarded from the task invocation.
#   -run <pattern>  filters which discovered tests to run (not passed to binary)
#   -v              changes gotestsum output format (handled in Taskfile; skip here)
#   anything else   is normalised to -test.<flag> and forwarded to the binary
$runPattern = $null
$binaryFlags = @()
if ($env:TESTFLAGS) {
    $tokens = ($env:TESTFLAGS -split '\s+') | Where-Object { $_ }
    for ($i = 0; $i -lt $tokens.Count; $i++) {
        switch -Regex ($tokens[$i]) {
            '^-run$'     { $runPattern = $tokens[++$i]; break }
            '^-run=(.+)' { $runPattern = $Matches[1];  break }
            '^-v$'       { break } # handled by gotestsum format in Taskfile
            '^-test\.'   { $binaryFlags += $tokens[$i]; break }
            '^-(.+)'     { $binaryFlags += "-test.$($Matches[1])"; break }
        }
    }
}
if ($runPattern) { $tests = $tests | Where-Object { $_ -match $runPattern } }


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Taskfile.yml
Comment thread Taskfile.yml Outdated
Comment thread Taskfile.yml
test:unit:
desc: Run unit tests (excludes integration package)
cmds:
- go test -count=1 ./api/... ./cmd/... ./internal/... ./pkg/... ./plugins/...
Comment thread Taskfile.yml
Comment thread integration/test.sh Outdated
Comment thread integration/test.ps1 Outdated
dmcgowan added 6 commits May 15, 2026 18:42
Add powershell version

Signed-off-by: Derek McGowan <derek@mcg.dev>
Signed-off-by: Derek McGowan <derek@mcg.dev>
Support passing arguments to test binaries

Signed-off-by: Derek McGowan <derek@mcg.dev>
Signed-off-by: Derek McGowan <derek@mcg.dev>
Signed-off-by: Derek McGowan <derek@mcg.dev>
Signed-off-by: Derek McGowan <derek@mcg.dev>
Copilot AI review requested due to automatic review settings May 16, 2026 02:16
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 9 comments.

Comments suppressed due to low confidence (4)

.github/workflows/ci.yml:68

  • GitHub Actions best practice is to pin third-party actions to a full commit SHA for supply-chain safety. arduino/setup-task@v2 is referenced by tag here; consider pinning it to a specific commit SHA.
      - uses: arduino/setup-task@v2
        with:
          version: 3.x
          repo-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/ci.yml:103

  • GitHub Actions best practice is to pin third-party actions to a full commit SHA for supply-chain safety. arduino/setup-task@v2 is referenced by tag here; consider pinning it to a specific commit SHA.
      - uses: arduino/setup-task@v2
        with:
          version: 3.x
          repo-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/ci.yml:144

  • GitHub Actions best practice is to pin third-party actions to a full commit SHA for supply-chain safety. arduino/setup-task@v2 is referenced by tag here; consider pinning it to a specific commit SHA.
      - uses: arduino/setup-task@v2
        with:
          version: 3.x
          repo-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/ci.yml:283

  • GitHub Actions best practice is to pin third-party actions to a full commit SHA for supply-chain safety. arduino/setup-task@v2 is referenced by tag here; consider pinning it to a specific commit SHA.
      - uses: arduino/setup-task@v2
        with:
          version: 3.x
          repo-token: ${{ secrets.GITHUB_TOKEN }}

Comment on lines +36 to +45
func dlClose(_ uintptr) error {
// On Windows, krun_start_enter may still be executing inside the library
// when Shutdown is called — krun_free_ctx initiates the VM stop but does
// not synchronously join the calling goroutine. Calling FreeLibrary while
// a goroutine is still inside the DLL causes an access violation.
//
// Since nerdbox runs exactly one VM per process (the shim model), the
// library handle is released naturally when the process exits. There is
// no need to call FreeLibrary explicitly.
return nil
Comment thread Taskfile.yml
desc: Regenerate protobuf bindings
dir: api
cmds:
- buf generate
Comment thread Taskfile.yml
test:unit:
desc: Run unit tests (excludes integration package)
cmds:
- go test -count=1 ./api/... ./cmd/... ./internal/... ./pkg/... ./plugins/...
Comment thread Taskfile.yml
vars:
OUTPUT_DIR: '_output'
GO_BUILDTAGS: 'no_grpc'
GO_TAGS: '-tags "no_grpc"'
Comment thread integration/test.sh
Comment on lines +46 to +47
-test.*) binary_flags+=("$tok") ;;
-*) binary_flags+=("-test.${tok#-}") ;;
Comment thread integration/test.ps1
'^-run=(.+)' { $runPattern = $Matches[1]; break }
'^-v$' { break } # handled by gotestsum format in Taskfile
'^-test\.' { $binaryFlags += $tokens[$i]; break }
'^-(.+)' { $binaryFlags += "-test.$($Matches[1])"; break }
Comment thread Makefile
Comment on lines 60 to +64
build:
@echo "$(WHALE) $@"
HOST_OS=$(shell uname -s | tr '[:upper:]' '[:lower:]') KERNEL_ARCH=$(ARCH) $(BUILDX) bake
@task build

_output/containerd-shim-nerdbox-v1: cmd/containerd-shim-nerdbox-v1 FORCE
@echo "$(WHALE) $@"
$(GO) build ${DEBUG_GO_GCFLAGS} ${GO_GCFLAGS} ${GO_BUILD_FLAGS} -o $@ ${GO_LDFLAGS} ${GO_TAGS} ./$<
ifeq ($(OS),Darwin)
codesign --entitlements cmd/containerd-shim-nerdbox-v1/containerd-shim-nerdbox-v1.entitlements --force -s - $@
endif
@task build:shim
Comment thread .github/workflows/ci.yml
Comment on lines +40 to +43
- uses: arduino/setup-task@v2
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
Comment on lines 320 to 324
}
}()

v.shutdownCallbacks = []func(context.Context) error{
func(context.Context) error {
cerr := v.vmc.Shutdown()
select {
case err := <-errC:
if err != nil {
return fmt.Errorf("failure running vm: %w", err)
}
default:
}
return cerr
},
}

// Accept a single connection from vminitd connecting back via vsock.
type acceptResult struct {
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