mirror of https://github.com/k3s-io/k3s.git
Move Windows compilation test to GH Actions and enable integration/coverage
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>pull/11773/head
parent
34ae4da57e
commit
5c8f2364c4
|
@ -47,14 +47,6 @@ steps:
|
|||
- name: docker
|
||||
path: /var/run/docker.sock
|
||||
|
||||
- name: validate-cross-compilation
|
||||
image: rancher/dapper:v0.6.0
|
||||
commands:
|
||||
- dapper validate-cross-compilation
|
||||
volumes:
|
||||
- name: docker
|
||||
path: /var/run/docker.sock
|
||||
|
||||
- name: fossa
|
||||
image: rancher/drone-fossa:latest
|
||||
failure: ignore
|
||||
|
|
|
@ -7,10 +7,6 @@ on:
|
|||
type: string
|
||||
description: 'Architecture to build'
|
||||
default: 'ubuntu-latest'
|
||||
upload-repo:
|
||||
type: boolean
|
||||
required: false
|
||||
default: false
|
||||
upload-image:
|
||||
type: boolean
|
||||
required: false
|
||||
|
@ -23,7 +19,7 @@ jobs:
|
|||
build:
|
||||
name: Build
|
||||
runs-on: ${{ inputs.arch }} # defaults to ubuntu-latest, for arm64 use ubuntu-24.04-arm
|
||||
timeout-minutes: 20
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Checkout K3s
|
||||
uses: actions/checkout@v4
|
||||
|
@ -31,25 +27,19 @@ jobs:
|
|||
run: |
|
||||
DOCKER_BUILDKIT=1 SKIP_IMAGE=1 SKIP_AIRGAP=1 SKIP_VALIDATE=1 GOCOVER=1 make
|
||||
sha256sum dist/artifacts/k3s | sed 's|dist/artifacts/||' > dist/artifacts/k3s.sha256sum
|
||||
- name: Build K3s binary (windows)
|
||||
if: inputs.arch == 'ubuntu-latest'
|
||||
run: |
|
||||
DOCKER_BUILDKIT=1 SKIP_IMAGE=1 SKIP_AIRGAP=1 SKIP_VALIDATE=1 GOCOVER=1 GOOS=windows make
|
||||
sha256sum dist/artifacts/k3s.exe | sed 's|dist/artifacts/||' > dist/artifacts/k3s.exe.sha256sum
|
||||
- name: Build K3s image
|
||||
if: inputs.upload-image == true
|
||||
run: make package-image
|
||||
- name: bundle repo
|
||||
if: inputs.upload-repo == true
|
||||
run: |
|
||||
tar -czvf ../k3s-repo.tar.gz .
|
||||
mv ../k3s-repo.tar.gz .
|
||||
- name: "Upload K3s directory"
|
||||
if: inputs.upload-repo == true
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: k3s-repo.tar.gz
|
||||
path: k3s-repo.tar.gz
|
||||
- name: "Save K3s image"
|
||||
if: inputs.upload-image == true
|
||||
run: docker image save rancher/k3s -o ./dist/artifacts/k3s-image.tar
|
||||
- name: "Upload K3s Artifacts"
|
||||
if: inputs.upload-repo == false && inputs.arch == 'ubuntu-latest'
|
||||
if: inputs.arch == 'ubuntu-latest'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: k3s
|
||||
|
@ -59,4 +49,4 @@ jobs:
|
|||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: k3s-arm64
|
||||
path: dist/artifacts/k3s*
|
||||
path: dist/artifacts/k3s*
|
||||
|
|
|
@ -38,8 +38,8 @@ jobs:
|
|||
- name: Install Go
|
||||
uses: ./.github/actions/setup-go
|
||||
- name: Run Unit Tests
|
||||
run: |
|
||||
go test -coverpkg=./... -coverprofile=coverage.out ./pkg/... -run Unit
|
||||
run: |
|
||||
go test -coverpkg ./pkg/... -coverprofile coverage.out ./pkg/... -run Unit
|
||||
go tool cover -func coverage.out
|
||||
- name: On Failure, Launch Debug Session
|
||||
if: ${{ failure() }}
|
||||
|
@ -53,3 +53,26 @@ jobs:
|
|||
files: ./coverage.out
|
||||
flags: unittests # optional
|
||||
verbose: true # optional (default = false)
|
||||
wtest:
|
||||
name: Unit Tests (Windows 2022)
|
||||
runs-on: windows-2022
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v5
|
||||
- name: Run Unit Tests
|
||||
run: |
|
||||
go test -coverpkg ./pkg/... -coverprofile coverage.out ./pkg/... -run Unit
|
||||
go tool cover -func coverage.out
|
||||
- name: Upload Results To Codecov
|
||||
uses: codecov/codecov-action@v5
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
files: ./coverage.out
|
||||
flags: unittests # optional
|
||||
verbose: true # optional (default = false)
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ ENV SELINUX=${SELINUX}
|
|||
|
||||
# Set Dapper configuration variables
|
||||
ENV DAPPER_RUN_ARGS="--privileged -v k3s-cache:/go/src/github.com/k3s-io/k3s/.cache -v trivy-cache:/root/.cache/trivy" \
|
||||
DAPPER_ENV="REPO TAG DRONE_TAG IMAGE_NAME SKIP_VALIDATE SKIP_IMAGE SKIP_AIRGAP AWS_SECRET_ACCESS_KEY AWS_ACCESS_KEY_ID GITHUB_TOKEN GOLANG GOCOVER DEBUG" \
|
||||
DAPPER_ENV="REPO TAG DRONE_TAG IMAGE_NAME SKIP_VALIDATE SKIP_IMAGE SKIP_AIRGAP AWS_SECRET_ACCESS_KEY AWS_ACCESS_KEY_ID GITHUB_TOKEN GOLANG GOCOVER GOOS DEBUG" \
|
||||
DAPPER_SOURCE="/go/src/github.com/k3s-io/k3s/" \
|
||||
DAPPER_OUTPUT="./bin ./dist ./build/out ./build/static ./pkg/static ./pkg/deploy" \
|
||||
DAPPER_DOCKER_SOCKET=true \
|
||||
|
|
|
@ -60,29 +60,42 @@ else
|
|||
LDFLAGS="-w -s"
|
||||
fi
|
||||
|
||||
STATIC="
|
||||
-extldflags '-static -lm -ldl -lz -lpthread'
|
||||
"
|
||||
TAGS="ctrd apparmor seccomp netcgo osusergo providerless urfave_cli_no_docs"
|
||||
RUNC_TAGS="apparmor seccomp"
|
||||
RUNC_STATIC="static"
|
||||
STATIC=""
|
||||
TAGS="ctrd netcgo osusergo providerless urfave_cli_no_docs sqlite_omit_load_extension"
|
||||
RUNC_STATIC=""
|
||||
RUNC_TAGS=""
|
||||
|
||||
if [ ${OS} = windows ]; then
|
||||
TAGS="ctrd netcgo osusergo providerless"
|
||||
fi
|
||||
case ${OS} in
|
||||
linux)
|
||||
TAGS="$TAGS apparmor seccomp"
|
||||
RUNC_TAGS="$RUNC_TAGS apparmor seccomp"
|
||||
|
||||
if [ "$SELINUX" = "true" ]; then
|
||||
TAGS="$TAGS selinux"
|
||||
RUNC_TAGS="$RUNC_TAGS selinux"
|
||||
fi
|
||||
if [ "$STATIC_BUILD" == "true" ]; then
|
||||
STATIC=$'\n-extldflags \'-static -lm -ldl -lz -lpthread\'\n'
|
||||
TAGS="static_build libsqlite3 $TAGS"
|
||||
RUNC_STATIC="static"
|
||||
fi
|
||||
if [ "$SELINUX" = "true" ]; then
|
||||
TAGS="$TAGS selinux"
|
||||
RUNC_TAGS="$RUNC_TAGS selinux"
|
||||
fi
|
||||
;;
|
||||
windows)
|
||||
TAGS="$TAGS no_cri_dockerd"
|
||||
|
||||
if [ "$STATIC_BUILD" != "true" ]; then
|
||||
STATIC="
|
||||
"
|
||||
RUNC_STATIC=""
|
||||
else
|
||||
TAGS="static_build libsqlite3 $TAGS"
|
||||
fi
|
||||
if [ "$STATIC_BUILD" == "true" ]; then
|
||||
STATIC=$'\n-extldflags \'-static -lpthread\'\n'
|
||||
TAGS="static_build $TAGS"
|
||||
fi
|
||||
|
||||
export CXX="x86_64-w64-mingw32-g++"
|
||||
export CC="x86_64-w64-mingw32-gcc"
|
||||
;;
|
||||
*)
|
||||
echo "[ERROR] unrecognized opertaing system: ${OS}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -n "${GOCOVER}" ]; then
|
||||
BLDFLAGS="-cover"
|
||||
|
|
|
@ -8,6 +8,7 @@ if [ ! -e ../bin/containerd ]; then
|
|||
fi
|
||||
|
||||
./package-cli
|
||||
|
||||
if [ -z "$SKIP_IMAGE" ]; then
|
||||
./package-image
|
||||
fi
|
||||
|
|
|
@ -5,6 +5,10 @@ cd $(dirname $0)/..
|
|||
|
||||
. ./scripts/version.sh
|
||||
|
||||
if [ "${OS}" != "linux" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
airgap_image_file='scripts/airgap/image-list.txt'
|
||||
images=$(cat "${airgap_image_file}")
|
||||
xargs -n1 docker pull <<< "${images}"
|
||||
|
|
|
@ -5,6 +5,10 @@ cd $(dirname $0)/..
|
|||
|
||||
. ./scripts/version.sh
|
||||
|
||||
if [ "${OS}" != "linux" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
TAG=${TAG:-${VERSION_TAG}${SUFFIX}}
|
||||
REPO=${REPO:-rancher}
|
||||
IMAGE_NAME=${IMAGE_NAME:-k3s}
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
#!/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="sigs.k8s.io/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