Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
5c8f2364
Commit
5c8f2364
authored
Feb 05, 2025
by
Brad Davidson
Committed by
Brad Davidson
Feb 07, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Windows compilation test to GH Actions and enable integration/coverage
Signed-off-by:
Brad Davidson
<
brad.davidson@rancher.com
>
parent
34ae4da5
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
76 additions
and
108 deletions
+76
-108
.drone.yml
.drone.yml
+0
-8
build-k3s.yaml
.github/workflows/build-k3s.yaml
+8
-19
unitcoverage.yaml
.github/workflows/unitcoverage.yaml
+25
-2
Dockerfile.dapper
Dockerfile.dapper
+1
-1
build
scripts/build
+33
-20
package
scripts/package
+1
-0
package-airgap
scripts/package-airgap
+4
-0
package-image
scripts/package-image
+4
-0
validate-cross-compilation
scripts/validate-cross-compilation
+0
-58
No files found.
.drone.yml
View file @
5c8f2364
...
...
@@ -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
...
...
.github/workflows/build-k3s.yaml
View file @
5c8f2364
...
...
@@ -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
:
2
0
timeout-minutes
:
3
0
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*
\ No newline at end of file
path
:
dist/artifacts/k3s*
.github/workflows/unitcoverage.yaml
View file @
5c8f2364
...
...
@@ -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)
Dockerfile.dapper
View file @
5c8f2364
...
...
@@ -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 \
...
...
scripts/build
View file @
5c8f2364
...
...
@@ -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"
...
...
scripts/package
View file @
5c8f2364
...
...
@@ -8,6 +8,7 @@ if [ ! -e ../bin/containerd ]; then
fi
./package-cli
if
[
-z
"
$SKIP_IMAGE
"
]
;
then
./package-image
fi
...
...
scripts/package-airgap
View file @
5c8f2364
...
...
@@ -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
}
"
...
...
scripts/package-image
View file @
5c8f2364
...
...
@@ -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
}
...
...
scripts/validate-cross-compilation
deleted
100755 → 0
View file @
34ae4da5
#!/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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment