test: Add basic Github Actions config (#63)

* test: Add basic Github Actions config

* fix(e2e-tests): handle asynchronous port publishing for ucind container

* fix(e2e-tests): increase machine ready wait timeout 1->10s

* fix: Pin GHA versions

---------

Co-authored-by: Pavel Sviderski <me@psviderski.name>
This commit is contained in:
Anton Ovchinnikov
2025-05-20 23:59:02 +02:00
committed by GitHub
co-authored by Pavel Sviderski
parent 365a5fc0b5
commit 69ebce57e9
4 changed files with 51 additions and 6 deletions
+36
View File
@@ -0,0 +1,36 @@
name: Go Tests
on:
push:
branches:
- "main"
- "test/**"
- "release/**"
pull_request:
branches:
- main
paths:
- ".github/**"
- "**.go"
- "go.*"
- "Makefile"
- "scripts/**"
- "test/**"
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version: "1.23.2"
- name: Install dependencies
run: go mod tidy
- name: Run tests
run: make test
timeout-minutes: 10
+12
View File
@@ -57,6 +57,18 @@ corrosion-multiarch-image-push:
ucind-image:
docker build -t "$(UCIND_IMAGE)" --target ucind .
.PHONY: ucind-image-push
ucind-image-push: ucind-image
docker push "$(UCIND_IMAGE)"
.PHONY: ucind-multiarch-image-push
ucind-multiarch-image-push:
docker buildx build --push --platform linux/amd64,linux/arm64 -t "$(UCIND_IMAGE)" --target ucind .
.PHONY: test
test:
go test -v ./...
.PHONY: vet
vet:
go vet ./...
+2 -5
View File
@@ -160,10 +160,7 @@ func (p *Provisioner) waitPortPublished(ctx context.Context, containerID string,
}
binding, ok := c.NetworkSettings.Ports[port]
if !ok {
return nil, fmt.Errorf("port '%s' not published", port)
}
if len(binding) > 0 {
if ok && len(binding) > 0 {
return binding, nil
}
@@ -196,7 +193,7 @@ func WaitMachineReady(ctx context.Context, m Machine, timeout time.Duration) err
boff := backoff.WithContext(backoff.NewExponentialBackOff(
backoff.WithInitialInterval(100*time.Millisecond),
backoff.WithMaxInterval(1*time.Second),
backoff.WithMaxInterval(10*time.Second),
backoff.WithMaxElapsedTime(timeout),
), ctx)
+1 -1
View File
@@ -6,7 +6,7 @@ cleanup() {
echo "Terminating container processes..."
# Terminate the main process if it has been started.
if [ -n "$MAIN_PID" ]; then
if [ -n "${MAIN_PID:-}" ]; then
kill "$MAIN_PID" 2>/dev/null || true
fi