Skip to content

Commit a50b550

Browse files
⭐️ alpine binary support (#23)
* Add alpine linux coverage * ⭐️ alpine binary support Co-authored-by: Fergus Strange <fergus@sitehive.co>
1 parent 1825a12 commit a50b550

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

.github/workflows/build.yml

+13
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,19 @@ jobs:
5353
env:
5454
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5555
run: GO111MODULE=off go get github.com/mattn/goveralls && $(go env GOPATH)/bin/goveralls -v -coverprofile=coverage.out -service=github
56+
alpine_tests:
57+
name: Alpine Linux Platform Tests
58+
runs-on: ubuntu-latest
59+
container:
60+
image: golang:1.13-alpine
61+
steps:
62+
- uses: actions/checkout@v1
63+
- name: Set Up
64+
run: |
65+
apk add --upgrade gcc g++ && \
66+
adduser testuser -D
67+
- name: All Tests
68+
run: su - testuser -c 'export PATH=$PATH:/usr/local/go/bin; cd /__w/embedded-postgres/embedded-postgres && go test -v ./... && cd platform-test && go test -v ./...'
5669
platform_tests:
5770
name: Platform tests
5871
strategy:

version_strategy.go

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
11
package embeddedpostgres
22

3-
import "runtime"
3+
import (
4+
"os"
5+
"runtime"
6+
)
47

58
// VersionStrategy provides a strategy that can be used to determine which version of Postgres should be used based on
69
// the operating system, architecture and desired Postgres version.
710
type VersionStrategy func() (operatingSystem string, architecture string, postgresVersion PostgresVersion)
811

912
func defaultVersionStrategy(config Config) VersionStrategy {
1013
return func() (operatingSystem, architecture string, version PostgresVersion) {
11-
return runtime.GOOS, runtime.GOARCH, config.version
14+
goos := runtime.GOOS
15+
arch := runtime.GOARCH
16+
17+
// use alpine specific build
18+
if goos == "linux" {
19+
if _, err := os.Stat("/etc/alpine-release"); err == nil {
20+
arch += "-alpine"
21+
}
22+
}
23+
24+
return goos, arch, config.version
1225
}
1326
}

0 commit comments

Comments
 (0)