Add s390x build support (#720)

Co-authored-by: Christopher Phillips <christopher.phillips@anchore.com>
This commit is contained in:
skuethe 2022-08-18 22:28:10 +02:00 committed by GitHub
parent d67b3e64aa
commit ae37eb4a05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 7 deletions

View file

@ -14,6 +14,7 @@ builds:
goarch:
- amd64
- arm64
- s390x
# set the modified timestamp on the output binary to the git timestamp to ensure a reproducible build
mod_timestamp: &build-timestamp '{{ .CommitTimestamp }}'
env: &build-env

View file

@ -15,6 +15,7 @@ builds:
goarch:
- amd64
- arm64
= s390x
# set the modified timestamp on the output binary to the git timestamp to ensure a reproducible build
mod_timestamp: &build-timestamp '{{ .CommitTimestamp }}'
env: &build-env
@ -60,6 +61,21 @@ dockers:
- "--build-arg=VCS_REF={{.FullCommit}}"
- "--build-arg=VCS_URL={{.GitURL}}"
- image_templates:
- anchore/grype:debug-arm64v8
- anchore/grype:{{.Tag}}-debug-arm64v8
- ghcr.io/anchore/grype:debug-arm64v8
- ghcr.io/anchore/grype:{{.Tag}}-debug-arm64v8
goarch: s390x
dockerfile: Dockerfile.debug
use: buildx
build_flag_templates:
- "--platform=linux/arm64/v8"
- "--build-arg=BUILD_DATE={{.Date}}"
- "--build-arg=BUILD_VERSION={{.Version}}"
- "--build-arg=VCS_REF={{.FullCommit}}"
- "--build-arg=VCS_URL={{.GitURL}}"
- image_templates:
- anchore/grype:latest
- anchore/grype:{{.Tag}}
@ -88,33 +104,52 @@ dockers:
- "--build-arg=VCS_REF={{.FullCommit}}"
- "--build-arg=VCS_URL={{.GitURL}}"
- image_templates:
- anchore/grype:{{.Tag}}-arm64v8
- ghcr.io/anchore/grype:{{.Tag}}-arm64v8
goarch: s390x
dockerfile: Dockerfile
use: buildx
build_flag_templates:
- "--platform=linux/arm64/v8"
- "--build-arg=BUILD_DATE={{.Date}}"
- "--build-arg=BUILD_VERSION={{.Version}}"
- "--build-arg=VCS_REF={{.FullCommit}}"
- "--build-arg=VCS_URL={{.GitURL}}"
docker_manifests:
- name_template: anchore/grype:latest
image_templates:
- anchore/grype:{{.Tag}}
- anchore/grype:{{.Tag}}-arm64v8
- anchore/grype:{{.Tag}}-s390x
- name_template: anchore/grype:debug
- anchore/grype:{{.Tag}}-debug
- anchore/grype:{{.Tag}}-debug-arm64v8
- anchore/grype:{{.Tag}}-debug-s390x
- name_template: anchore/grype:{{.Tag}}
image_templates:
- anchore/grype:{{.Tag}}
- anchore/grype:{{.Tag}}-arm64v8
- anchore/grype:{{.Tag}}-s390x
- name_template: ghcr.io/anchore/grype:latest
image_templates:
- ghcr.io/anchore/grype:{{.Tag}}
- ghcr.io/anchore/grype:{{.Tag}}-arm64v8
- ghcr.io/anchore/grype:{{.Tag}}-s390x
- name_template: ghcr.io/anchore/grype:debug
image_templates:
- ghcr.io/anchore/grype:{{.Tag}}-debug
- ghcr.io/anchore/grype:{{.Tag}}-debug-arm64v8
- ghcr.io/anchore/grype:{{.Tag}}-debug-s390x
- name_template: ghcr.io/anchore/grype:{{.Tag}}
image_templates:
- ghcr.io/anchore/grype:{{.Tag}}
- ghcr.io/anchore/grype:{{.Tag}}-arm64v8
- ghcr.io/anchore/grype:{{.Tag}}-s390x

View file

@ -49,12 +49,10 @@ func getGrypeSnapshotLocation(tb testing.TB, goOS string) string {
if runtime.GOARCH == "amd64" {
archPath = fmt.Sprintf("%s_v1", archPath)
}
// note: there is a subtle - vs _ difference between these versions
switch goOS {
case "darwin":
return path.Join(repoRoot(tb), fmt.Sprintf("snapshot/darwin-build_darwin_%s/grype", runtime.GOARCH))
case "linux":
return path.Join(repoRoot(tb), fmt.Sprintf("snapshot/linux-build_linux_%s/grype", runtime.GOARCH))
case "darwin", "linux":
return path.Join(repoRoot(tb), fmt.Sprintf("snapshot/%s-build_%s_%s/grype", goOS, goOS, archPath))
default:
tb.Fatalf("unsupported OS: %s", runtime.GOOS)
}

View file

@ -71,6 +71,9 @@ run_test_case test_positive_snapshot_download_asset "linux" "amd64" "deb"
run_test_case test_positive_snapshot_download_asset "linux" "arm64" "tar.gz"
run_test_case test_positive_snapshot_download_asset "linux" "arm64" "rpm"
run_test_case test_positive_snapshot_download_asset "linux" "arm64" "deb"
run_test_case test_positive_snapshot_download_asset "linux" "s390x" "tar.gz"
run_test_case test_positive_snapshot_download_asset "linux" "s390x" "rpm"
run_test_case test_positive_snapshot_download_asset "linux" "s390x" "deb"
run_test_case test_positive_snapshot_download_asset "darwin" "amd64" "tar.gz"
run_test_case test_positive_snapshot_download_asset "darwin" "arm64" "tar.gz"
run_test_case test_positive_snapshot_download_asset "windows" "amd64" "zip"

View file

@ -26,7 +26,7 @@ test_positive_snapshot_install_asset() {
expected_path="${install_dir}/${binary}"
assertFileExists "${expected_path}" "install_asset os=${os} arch=${arch} format=${format}"
# directory structure for arch has been updated as of go 1.18
# directory structure for arch has been updated as of go 1.18
# https://goreleaser.com/customization/build/#why-is-there-a-_v1-suffix-on-amd64-buildsjk
if [ $arch == "amd64" ]; then
arch="amd64_v1"
@ -82,6 +82,7 @@ trap 'teardown_snapshot_server ${worker_pid}' EXIT
# exercise all possible archive assets (not rpm/deb/dmg) against a snapshot build
run_test_case test_positive_snapshot_install_asset "linux" "amd64" "tar.gz"
run_test_case test_positive_snapshot_install_asset "linux" "arm64" "tar.gz"
run_test_case test_positive_snapshot_install_asset "linux" "s390x" "tar.gz"
run_test_case test_positive_snapshot_install_asset "darwin" "amd64" "tar.gz"
run_test_case test_positive_snapshot_install_asset "darwin" "arm64" "tar.gz"
run_test_case test_positive_snapshot_install_asset "windows" "amd64" "zip"