Skip to content

Commit 06efa36

Browse files
version strategy: zonkio's arm arch name are different from GOOARCH (#25)
* Add CircleCI build for arm64 * version strategy: zonkio's arm arch name are different from GOOARCH on arm (32bit), use 'uname -m' to get the excact arm version Co-authored-by: Fergus Strange <[email protected]>
1 parent f2d83ab commit 06efa36

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

.circleci/config.yml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,27 @@
11
version: 2.1
22
executors:
3-
linux:
4-
machine:
5-
image: ubuntu-2004:202104-01
6-
working_directory: /go/src/github.com/fergusstrange/embedded-postgres
73
linux-arm64:
84
machine:
95
image: ubuntu-2004:202104-01
106
resource_class: arm.medium
11-
working_directory: /go/src/github.com/fergusstrange/embedded-postgres
12-
osx:
13-
macos:
14-
xcode: 11.4
15-
working_directory: /go/src/github.com/fergusstrange/embedded-postgres
7+
working_directory: /home/circleci/go/src/github.com/fergusstrange/embedded-postgres
168

179
jobs:
1810
platform_test:
1911
parameters:
20-
os:
12+
executor:
2113
type: executor
2214
executor: << parameters.executor >>
2315
steps:
2416
- checkout
2517
- restore_cache:
2618
keys:
27-
- embedded-postgres-{{ checksum "/go/src/github.com/fergusstrange/embedded-postgres/go.mod" }}
19+
- embedded-postgres-{{ checksum "/home/circleci/go/src/github.com/fergusstrange/embedded-postgres/go.mod" }}
2820
- run: cd platform-test && go test -v -race ./...
2921
- save_cache:
30-
key: embedded-postgres-{{ checksum "/go/src/github.com/fergusstrange/embedded-postgres/go.mod" }}
22+
key: embedded-postgres-{{ checksum "/home/circleci/go/src/github.com/fergusstrange/embedded-postgres/go.mod" }}
3123
paths:
32-
- /go/pkg
24+
- /home/circleci/go/pkg
3325

3426
workflows:
3527
version: 2
@@ -38,4 +30,4 @@ workflows:
3830
- platform_test:
3931
matrix:
4032
parameters:
41-
executor: [ linux, linux-arm64, osx ]
33+
executor: [ linux-arm64 ]

version_strategy.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package embeddedpostgres
22

33
import (
44
"os"
5+
"os/exec"
56
"runtime"
7+
"strings"
68
)
79

810
// VersionStrategy provides a strategy that can be used to determine which version of Postgres should be used based on
@@ -14,8 +16,24 @@ func defaultVersionStrategy(config Config) VersionStrategy {
1416
goos := runtime.GOOS
1517
arch := runtime.GOARCH
1618

17-
// use alpine specific build
1819
if goos == "linux" {
20+
// the zonkyio/embedded-postgres-binaries project produces
21+
// arm binaries with the following name schema:
22+
// 32bit: arm32v6 / arm32v7
23+
// 64bit (aarch64): arm64v8
24+
if arch == "arm64" {
25+
arch += "v8"
26+
} else if arch == "arm" {
27+
if out, err := exec.Command("uname", "-m").Output(); err == nil {
28+
s := string(out)
29+
if strings.HasPrefix(s, "armv7") {
30+
arch += "32v7"
31+
} else if strings.HasPrefix(s, "armv6") {
32+
arch += "32v6"
33+
}
34+
}
35+
}
36+
// check alpine specific build
1937
if _, err := os.Stat("/etc/alpine-release"); err == nil {
2038
arch += "-alpine"
2139
}

0 commit comments

Comments
 (0)