Skip to content

Commit

Permalink
fix: linux/arm64 support (#562)
Browse files Browse the repository at this point in the history
Adds everything necessary to not only ensure OTF runs on linux/arm64 but
can be tested on linux/arm64 too.

Fixes #311
  • Loading branch information
leg100 authored Aug 5, 2023
1 parent c7596fe commit 01a2112
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 15 deletions.
59 changes: 55 additions & 4 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,70 @@ dockers:
ids:
- otfd
image_templates:
- "leg100/otfd:latest"
- "leg100/otfd:{{ .Version }}"
- "leg100/otfd:latest-amd64"
- "leg100/otfd:{{ .Version }}-amd64"
skip_push: auto
dockerfile: Dockerfile
use: buildx
build_flag_templates:
- "--pull"
- "--platform=linux/amd64"
- goos: linux
goarch: arm64
ids:
- otfd
image_templates:
- "leg100/otfd:latest-arm64"
- "leg100/otfd:{{ .Version }}-arm64"
skip_push: auto
dockerfile: Dockerfile
use: buildx
build_flag_templates:
- "--pull"
- "--platform=linux/arm64"
- goos: linux
goarch: amd64
ids:
- otf-agent
image_templates:
- "leg100/otf-agent:latest"
- "leg100/otf-agent:{{ .Version }}"
- "leg100/otf-agent:latest-amd64"
- "leg100/otf-agent:{{ .Version }}-amd64"
skip_push: auto
dockerfile: Dockerfile.agent
use: buildx
build_flag_templates:
- "--pull"
- "--platform=linux/amd64"
- goos: linux
goarch: arm64
ids:
- otf-agent
image_templates:
- "leg100/otf-agent:latest-arm64"
- "leg100/otf-agent:{{ .Version }}-arm64"
skip_push: auto
dockerfile: Dockerfile.agent
use: buildx
build_flag_templates:
- "--pull"
- "--platform=linux/arm64"
docker_manifests:
- name_template: 'leg100/otfd:latest'
image_templates:
- "leg100/otfd:latest-amd64"
- "leg100/otfd:latest-arm64"
- name_template: 'leg100/otfd:{{ .Version }}'
image_templates:
- "leg100/otfd:{{ .Version }}-amd64"
- "leg100/otfd:{{ .Version }}-arm64"
- name_template: 'leg100/otf-agent:latest'
image_templates:
- "leg100/otf-agent:latest-amd64"
- "leg100/otf-agent:latest-arm64"
- name_template: 'leg100/otf-agent:{{ .Version }}'
image_templates:
- "leg100/otf-agent:{{ .Version }}-amd64"
- "leg100/otf-agent:{{ .Version }}-arm64"
release:
footer: |
## Docker images
Expand Down
Binary file not shown.
21 changes: 13 additions & 8 deletions internal/integration/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"path"
"path/filepath"
"runtime"
"testing"

"github.com/leg100/otf/internal"
Expand Down Expand Up @@ -72,15 +73,19 @@ func doMain(m *testing.M) (int, error) {
defer unset()

// get pubsub emulator host and set environment variable
pubsub, err := testcompose.GetHost(testcompose.PubSub)
if err != nil {
return 0, fmt.Errorf("getting squid host: %w", err)
}
unset, err = setenv("PUBSUB_EMULATOR_HOST", pubsub)
if err != nil {
return 0, err
//
// NOTE: gcp pub sub emulator only runs on amd64
if runtime.GOARCH == "amd64" {
pubsub, err := testcompose.GetHost(testcompose.PubSub)
if err != nil {
return 0, fmt.Errorf("getting pub sub emulator host: %w", err)
}
unset, err = setenv("PUBSUB_EMULATOR_HOST", pubsub)
if err != nil {
return 0, err
}
defer unset()
}
defer unset()

// The otfd daemon spawned in an integration test uses a self-signed cert.
// The following environment variable instructs any Go program spawned in a
Expand Down
4 changes: 4 additions & 0 deletions internal/integration/notification_gcppubsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package integration
import (
"context"
"encoding/json"
"runtime"
"testing"

"cloud.google.com/go/pubsub"
Expand All @@ -18,6 +19,9 @@ import (
// TestIntegration_NotificationGCPPubSub demonstrates run events triggering the
// sending of notifications to a GCP pub-sub topic.
func TestIntegration_NotificationGCPPubSub(t *testing.T) {
if runtime.GOARCH != "amd64" {
t.Skip("gcp pubsub emulator only runs on amd64")
}
testutils.SkipIfEnvUnspecified(t, "PUBSUB_EMULATOR_HOST")

integrationTest(t)
Expand Down
5 changes: 3 additions & 2 deletions internal/notifications/client_gcppubsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"testing"

"github.com/leg100/otf/internal"
"github.com/leg100/otf/internal/testutils"
"github.com/stretchr/testify/require"
)

func TestPubSubClient_New(t *testing.T) {
testutils.SkipIfEnvUnspecified(t, "PUBSUB_EMULATOR_HOST")
// PUBSUB_EMULATOR_HOST is not actually used but ensures the check for valid
// google credentials is skipped.
t.Setenv("PUBSUB_EMULATOR_HOST", "foobar")

tests := []struct {
name string
Expand Down
7 changes: 6 additions & 1 deletion internal/testcompose/testcompose.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"bytes"
"fmt"
"os/exec"
"runtime"
"strconv"
"strings"
)
Expand All @@ -27,7 +28,11 @@ var ports = map[Service]int{
func Up() error {
// --wait implies -d, which detaches the containers
args := []string{"compose", "-p", "otf", "up", "--wait", "--wait-timeout", "60"}
args = append(args, string(Postgres), string(Squid), string(PubSub))
args = append(args, string(Postgres), string(Squid))
// gcp pub sub emulator only runs on amd64
if runtime.GOARCH == "amd64" {
args = append(args, string(PubSub))
}
cmd := exec.Command("docker", args...)

var buferr bytes.Buffer
Expand Down

0 comments on commit 01a2112

Please sign in to comment.