Skip to content

Commit

Permalink
fix: rpm on arm
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Nov 13, 2021
1 parent 2a86957 commit e009224
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Expand Up @@ -62,7 +62,7 @@ jobs:
matrix:
go-version: [ 1.17 ]
pkgFormat: [ deb, rpm, apk ]
pkgPlatform: [ amd64, arm64, 386, ppc64le ]
pkgPlatform: [ amd64, arm64, 386, ppc64le, armv6, armv7 ]
runs-on: ubuntu-latest
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
Expand Down
3 changes: 2 additions & 1 deletion Taskfile.yml
Expand Up @@ -45,9 +45,10 @@ tasks:
env:
LC_ALL: C
vars:
TEST_OPTIONS: '{{default "" .TEST_OPTIONS}}'
TEST_PATTERN: '{{default "." .TEST_PATTERN}}'
cmds:
- go test -tags=acceptance -p 4 -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt acceptance_test.go -run {{.TEST_PATTERN}} -timeout=1h
- go test {{.TEST_OPTIONS}} -tags=acceptance -p 4 -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt acceptance_test.go -run {{.TEST_PATTERN}} -timeout=1h

test:
desc: Run unit tests
Expand Down
13 changes: 8 additions & 5 deletions acceptance_test.go
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"os/exec"
"path/filepath"
"strings"
"testing"

"github.com/goreleaser/nfpm/v2"
Expand All @@ -19,9 +20,9 @@ import (

// nolint: gochecknoglobals
var formatArchs = map[string][]string{
"apk": {"amd64", "arm64", "386", "ppc64le"},
"deb": {"amd64", "arm64", "ppc64le"},
"rpm": {"amd64", "arm64", "ppc64le"},
"apk": {"amd64", "arm64", "386", "ppc64le", "armv6", "armv7"},
"deb": {"amd64", "arm64", "ppc64le", "armv6", "armv7"},
"rpm": {"amd64", "arm64", "ppc64le", "armv6", "armv7"},
}

func TestCore(t *testing.T) {
Expand Down Expand Up @@ -272,6 +273,8 @@ func (t testWriter) Write(p []byte) (n int, err error) {

func accept(t *testing.T, params acceptParms) {
t.Helper()

arch := strings.Replace(params.Docker.Arch, "armv", "arm/", 1)
configFile := filepath.Join("./testdata/acceptance/", params.Conf)
tmp, err := filepath.Abs("./testdata/acceptance/tmp")
require.NoError(t, err)
Expand All @@ -284,7 +287,7 @@ func accept(t *testing.T, params acceptParms) {
envFunc := func(s string) string {
switch s {
case "BUILD_ARCH":
return params.Docker.Arch
return strings.Replace(arch, "/", "", 1)
case "SEMVER":
return "v1.0.0-0.1.b1+git.abcdefgh"
default:
Expand All @@ -303,7 +306,7 @@ func accept(t *testing.T, params acceptParms) {

cmdArgs := []string{
"build", "--rm", "--force-rm",
"--platform", fmt.Sprintf("linux/%s", params.Docker.Arch),
"--platform", fmt.Sprintf("linux/%s", arch),
"-f", params.Docker.File,
"--target", params.Docker.Target,
"--build-arg", "package=" + filepath.Join("tmp", packageName),
Expand Down
4 changes: 2 additions & 2 deletions rpm/rpm.go
Expand Up @@ -61,8 +61,8 @@ var archToRPM = map[string]string{
"amd64": "x86_64",
"386": "i386",
"arm64": "aarch64",
"arm6": "arm6l",
"arm7": "arm7l",
"arm6": "armv6hl",
"arm7": "armv7hl",
"mips": "mips",
"mipsle": "mipsel",
// TODO: other arches
Expand Down

0 comments on commit e009224

Please sign in to comment.