From 9c6bbc1305cec96dc273a3888f791f6d03d0140a Mon Sep 17 00:00:00 2001 From: Brad Davidson Date: Wed, 5 Feb 2025 00:27:26 +0000 Subject: [PATCH] Move Windows compilation test to GH Actions and enable integration/coverage Signed-off-by: Brad Davidson --- .drone.yml | 8 ---- .github/workflows/unitcoverage.yaml | 25 ++++++++++++- scripts/validate-cross-compilation | 58 ----------------------------- 3 files changed, 24 insertions(+), 67 deletions(-) delete mode 100755 scripts/validate-cross-compilation diff --git a/.drone.yml b/.drone.yml index 54482bcaafc6..66a602db9a69 100644 --- a/.drone.yml +++ b/.drone.yml @@ -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 diff --git a/.github/workflows/unitcoverage.yaml b/.github/workflows/unitcoverage.yaml index bad46ec24999..275fa3a704c4 100644 --- a/.github/workflows/unitcoverage.yaml +++ b/.github/workflows/unitcoverage.yaml @@ -39,7 +39,7 @@ jobs: uses: ./.github/actions/setup-go - name: Run Unit Tests run: | - go test -coverpkg=./... -coverprofile=coverage.out ./pkg/... -run Unit + 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) + diff --git a/scripts/validate-cross-compilation b/scripts/validate-cross-compilation deleted file mode 100755 index a3cabae08d0e..000000000000 --- a/scripts/validate-cross-compilation +++ /dev/null @@ -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