mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-28 03:53:33 +00:00
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:
co-authored by
Pavel Sviderski
parent
365a5fc0b5
commit
69ebce57e9
@@ -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
|
||||||
@@ -57,6 +57,18 @@ corrosion-multiarch-image-push:
|
|||||||
ucind-image:
|
ucind-image:
|
||||||
docker build -t "$(UCIND_IMAGE)" --target ucind .
|
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
|
.PHONY: ucind-multiarch-image-push
|
||||||
ucind-multiarch-image-push:
|
ucind-multiarch-image-push:
|
||||||
docker buildx build --push --platform linux/amd64,linux/arm64 -t "$(UCIND_IMAGE)" --target ucind .
|
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 ./...
|
||||||
|
|||||||
@@ -160,10 +160,7 @@ func (p *Provisioner) waitPortPublished(ctx context.Context, containerID string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
binding, ok := c.NetworkSettings.Ports[port]
|
binding, ok := c.NetworkSettings.Ports[port]
|
||||||
if !ok {
|
if ok && len(binding) > 0 {
|
||||||
return nil, fmt.Errorf("port '%s' not published", port)
|
|
||||||
}
|
|
||||||
if len(binding) > 0 {
|
|
||||||
return binding, nil
|
return binding, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,7 +193,7 @@ func WaitMachineReady(ctx context.Context, m Machine, timeout time.Duration) err
|
|||||||
|
|
||||||
boff := backoff.WithContext(backoff.NewExponentialBackOff(
|
boff := backoff.WithContext(backoff.NewExponentialBackOff(
|
||||||
backoff.WithInitialInterval(100*time.Millisecond),
|
backoff.WithInitialInterval(100*time.Millisecond),
|
||||||
backoff.WithMaxInterval(1*time.Second),
|
backoff.WithMaxInterval(10*time.Second),
|
||||||
backoff.WithMaxElapsedTime(timeout),
|
backoff.WithMaxElapsedTime(timeout),
|
||||||
), ctx)
|
), ctx)
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ cleanup() {
|
|||||||
echo "Terminating container processes..."
|
echo "Terminating container processes..."
|
||||||
|
|
||||||
# Terminate the main process if it has been started.
|
# 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
|
kill "$MAIN_PID" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user