mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Add cross-compilation as sanity check (#5255)
This commit is contained in:
parent
078da46532
commit
de889a0078
@ -22,6 +22,14 @@ steps:
|
||||
- name: docker
|
||||
path: /var/run/docker.sock
|
||||
|
||||
- name: validate-cross-compilation
|
||||
image: rancher/dapper:v0.5.0
|
||||
commands:
|
||||
- dapper validate-cross-compilation
|
||||
volumes:
|
||||
- name: docker
|
||||
path: /var/run/docker.sock
|
||||
|
||||
- name: fossa
|
||||
image: rancher/drone-fossa:latest
|
||||
failure: ignore
|
||||
|
@ -11,7 +11,12 @@ ENV no_proxy=$no_proxy
|
||||
RUN apk -U --no-cache add bash git gcc musl-dev docker vim less file curl wget ca-certificates jq linux-headers \
|
||||
zlib-dev tar zip squashfs-tools npm coreutils python3 openssl-dev libffi-dev libseccomp libseccomp-dev \
|
||||
libseccomp-static make libuv-static sqlite-dev sqlite-static libselinux libselinux-dev zlib-dev zlib-static \
|
||||
zstd pigz alpine-sdk binutils-gold btrfs-progs-dev btrfs-progs-static gawk
|
||||
zstd pigz alpine-sdk binutils-gold btrfs-progs-dev btrfs-progs-static gawk \
|
||||
&& \
|
||||
if [ "$(go env GOARCH)" = "amd64" ]; then \
|
||||
apk -U --no-cache add mingw-w64-gcc; \
|
||||
fi
|
||||
|
||||
RUN if [ "$(go env GOARCH)" = "arm64" ]; then \
|
||||
wget https://github.com/aquasecurity/trivy/releases/download/v0.16.0/trivy_0.16.0_Linux-ARM64.tar.gz && \
|
||||
tar -zxvf trivy_0.16.0_Linux-ARM64.tar.gz && \
|
||||
|
58
scripts/validate-cross-compilation
Executable file
58
scripts/validate-cross-compilation
Executable file
@ -0,0 +1,58 @@
|
||||
#!/bin/bash
|
||||
set -e -x
|
||||
|
||||
cd $(dirname $0)/..
|
||||
|
||||
. ./scripts/version.sh
|
||||
|
||||
GO=${GO-go}
|
||||
|
||||
PKG="github.com/k3s-io/k3s"
|
||||
PKG_CONTAINERD="github.com/containerd/containerd"
|
||||
PKG_K3S_CONTAINERD="github.com/k3s-io/containerd"
|
||||
PKG_CRICTL="github.com/kubernetes-sigs/cri-tools/pkg"
|
||||
PKG_K8S_BASE="k8s.io/component-base"
|
||||
PKG_K8S_CLIENT="k8s.io/client-go/pkg"
|
||||
|
||||
buildDate=$(date -u '+%Y-%m-%dT%H:%M:%SZ')
|
||||
|
||||
VERSIONFLAGS="
|
||||
-X ${PKG}/pkg/version.Version=${VERSION}
|
||||
-X ${PKG}/pkg/version.GitCommit=${COMMIT:0:8}
|
||||
|
||||
-X ${PKG_K8S_CLIENT}/version.gitVersion=${VERSION}
|
||||
-X ${PKG_K8S_CLIENT}/version.gitCommit=${COMMIT}
|
||||
-X ${PKG_K8S_CLIENT}/version.gitTreeState=${TREE_STATE}
|
||||
-X ${PKG_K8S_CLIENT}/version.buildDate=${buildDate}
|
||||
|
||||
-X ${PKG_K8S_BASE}/version.gitVersion=${VERSION}
|
||||
-X ${PKG_K8S_BASE}/version.gitCommit=${COMMIT}
|
||||
-X ${PKG_K8S_BASE}/version.gitTreeState=${TREE_STATE}
|
||||
-X ${PKG_K8S_BASE}/version.buildDate=${buildDate}
|
||||
|
||||
-X ${PKG_CRICTL}/version.Version=${VERSION_CRICTL}
|
||||
|
||||
-X ${PKG_CONTAINERD}/version.Version=${VERSION_CONTAINERD}
|
||||
-X ${PKG_CONTAINERD}/version.Package=${PKG_K3S_CONTAINERD}
|
||||
|
||||
-X ${PKG_CONTAINERD}/version.Version=${VERSION_CONTAINERD}
|
||||
-X ${PKG_CONTAINERD}/version.Package=${PKG_K3S_CONTAINERD}
|
||||
"
|
||||
|
||||
LDFLAGS="
|
||||
-w -s"
|
||||
|
||||
STATIC=""
|
||||
|
||||
TAGS="netcgo osusergo providerless"
|
||||
|
||||
mkdir -p bin
|
||||
|
||||
# Sanity check for downstream dependencies
|
||||
echo 'Validate K3s cross-compilation on Windows x86_64'
|
||||
GOOS=windows CGO_ENABLED=1 CXX=x86_64-w64-mingw32-g++ CC=x86_64-w64-mingw32-gcc \
|
||||
"${GO}" build -tags "${TAGS}" -ldflags "${VERSIONFLAGS} ${LDFLAGS} ${STATIC}" -o bin/k3s.exe ./cmd/server/main.go
|
||||
|
||||
if [ "${KEEP_WINDOWS_BIN}" != 'true' ]; then
|
||||
rm -rf bin/k3s.exe
|
||||
fi
|
Loading…
Reference in New Issue
Block a user