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:
...
@@ -47,14 +47,6 @@ steps:
-
name
:
docker
-
name
:
docker
path
:
/var/run/docker.sock
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
-
name
:
fossa
image
:
rancher/drone-fossa:latest
image
:
rancher/drone-fossa:latest
failure
:
ignore
failure
:
ignore
...
...
.github/workflows/build-k3s.yaml
View file @
5c8f2364
...
@@ -7,10 +7,6 @@ on:
...
@@ -7,10 +7,6 @@ on:
type
:
string
type
:
string
description
:
'
Architecture
to
build'
description
:
'
Architecture
to
build'
default
:
'
ubuntu-latest'
default
:
'
ubuntu-latest'
upload-repo
:
type
:
boolean
required
:
false
default
:
false
upload-image
:
upload-image
:
type
:
boolean
type
:
boolean
required
:
false
required
:
false
...
@@ -23,7 +19,7 @@ jobs:
...
@@ -23,7 +19,7 @@ jobs:
build
:
build
:
name
:
Build
name
:
Build
runs-on
:
${{ inputs.arch }}
# defaults to ubuntu-latest, for arm64 use ubuntu-24.04-arm
runs-on
:
${{ inputs.arch }}
# defaults to ubuntu-latest, for arm64 use ubuntu-24.04-arm
timeout-minutes
:
2
0
timeout-minutes
:
3
0
steps
:
steps
:
-
name
:
Checkout K3s
-
name
:
Checkout K3s
uses
:
actions/checkout@v4
uses
:
actions/checkout@v4
...
@@ -31,25 +27,19 @@ jobs:
...
@@ -31,25 +27,19 @@ jobs:
run
:
|
run
:
|
DOCKER_BUILDKIT=1 SKIP_IMAGE=1 SKIP_AIRGAP=1 SKIP_VALIDATE=1 GOCOVER=1 make
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
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
-
name
:
Build K3s image
if
:
inputs.upload-image ==
true
if
:
inputs.upload-image ==
true
run
:
make package-image
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"
-
name
:
"
Save
K3s
image"
if
:
inputs.upload-image ==
true
if
:
inputs.upload-image ==
true
run
:
docker image save rancher/k3s -o ./dist/artifacts/k3s-image.tar
run
:
docker image save rancher/k3s -o ./dist/artifacts/k3s-image.tar
-
name
:
"
Upload
K3s
Artifacts"
-
name
:
"
Upload
K3s
Artifacts"
if
:
inputs.
upload-repo ==
false
&& inputs.
arch == 'ubuntu-latest'
if
:
inputs.arch == 'ubuntu-latest'
uses
:
actions/upload-artifact@v4
uses
:
actions/upload-artifact@v4
with
:
with
:
name
:
k3s
name
:
k3s
...
@@ -59,4 +49,4 @@ jobs:
...
@@ -59,4 +49,4 @@ jobs:
uses
:
actions/upload-artifact@v4
uses
:
actions/upload-artifact@v4
with
:
with
:
name
:
k3s-arm64
name
:
k3s-arm64
path
:
dist/artifacts/k3s*
path
:
dist/artifacts/k3s*
\ No newline at end of file
.github/workflows/unitcoverage.yaml
View file @
5c8f2364
...
@@ -38,8 +38,8 @@ jobs:
...
@@ -38,8 +38,8 @@ jobs:
-
name
:
Install Go
-
name
:
Install Go
uses
:
./.github/actions/setup-go
uses
:
./.github/actions/setup-go
-
name
:
Run Unit Tests
-
name
:
Run Unit Tests
run
:
|
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
go tool cover -func coverage.out
-
name
:
On Failure, Launch Debug Session
-
name
:
On Failure, Launch Debug Session
if
:
${{ failure() }}
if
:
${{ failure() }}
...
@@ -53,3 +53,26 @@ jobs:
...
@@ -53,3 +53,26 @@ jobs:
files
:
./coverage.out
files
:
./coverage.out
flags
:
unittests
# optional
flags
:
unittests
# optional
verbose
:
true
# optional (default = false)
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}
...
@@ -52,7 +52,7 @@ ENV SELINUX=${SELINUX}
# Set Dapper configuration variables
# 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" \
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_SOURCE="/go/src/github.com/k3s-io/k3s/" \
DAPPER_OUTPUT="./bin ./dist ./build/out ./build/static ./pkg/static ./pkg/deploy" \
DAPPER_OUTPUT="./bin ./dist ./build/out ./build/static ./pkg/static ./pkg/deploy" \
DAPPER_DOCKER_SOCKET=true \
DAPPER_DOCKER_SOCKET=true \
...
...
scripts/build
View file @
5c8f2364
...
@@ -60,29 +60,42 @@ else
...
@@ -60,29 +60,42 @@ else
LDFLAGS
=
"-w -s"
LDFLAGS
=
"-w -s"
fi
fi
STATIC
=
"
STATIC
=
""
-extldflags '-static -lm -ldl -lz -lpthread'
TAGS
=
"ctrd netcgo osusergo providerless urfave_cli_no_docs sqlite_omit_load_extension"
"
RUNC_STATIC
=
""
TAGS
=
"ctrd apparmor seccomp netcgo osusergo providerless urfave_cli_no_docs"
RUNC_TAGS
=
""
RUNC_TAGS
=
"apparmor seccomp"
RUNC_STATIC
=
"static"
if
[
${
OS
}
=
windows
]
;
then
case
${
OS
}
in
TAGS
=
"ctrd netcgo osusergo providerless"
linux
)
fi
TAGS
=
"
$TAGS
apparmor seccomp"
RUNC_TAGS
=
"
$RUNC_TAGS
apparmor seccomp"
if
[
"
$SELINUX
"
=
"true"
]
;
then
if
[
"
$STATIC_BUILD
"
==
"true"
]
;
then
TAGS
=
"
$TAGS
selinux"
STATIC
=
$'
\n
-extldflags
\'
-static -lm -ldl -lz -lpthread
\'\n
'
RUNC_TAGS
=
"
$RUNC_TAGS
selinux"
TAGS
=
"static_build libsqlite3
$TAGS
"
fi
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
if
[
"
$STATIC_BUILD
"
==
"true"
]
;
then
STATIC
=
"
STATIC
=
$'
\n
-extldflags
\'
-static -lpthread
\'\n
'
"
TAGS
=
"static_build
$TAGS
"
RUNC_STATIC
=
""
fi
else
TAGS
=
"static_build libsqlite3
$TAGS
"
export
CXX
=
"x86_64-w64-mingw32-g++"
fi
export
CC
=
"x86_64-w64-mingw32-gcc"
;;
*
)
echo
"[ERROR] unrecognized opertaing system:
${
OS
}
"
exit
1
;;
esac
if
[
-n
"
${
GOCOVER
}
"
]
;
then
if
[
-n
"
${
GOCOVER
}
"
]
;
then
BLDFLAGS
=
"-cover"
BLDFLAGS
=
"-cover"
...
...
scripts/package
View file @
5c8f2364
...
@@ -8,6 +8,7 @@ if [ ! -e ../bin/containerd ]; then
...
@@ -8,6 +8,7 @@ if [ ! -e ../bin/containerd ]; then
fi
fi
./package-cli
./package-cli
if
[
-z
"
$SKIP_IMAGE
"
]
;
then
if
[
-z
"
$SKIP_IMAGE
"
]
;
then
./package-image
./package-image
fi
fi
...
...
scripts/package-airgap
View file @
5c8f2364
...
@@ -5,6 +5,10 @@ cd $(dirname $0)/..
...
@@ -5,6 +5,10 @@ cd $(dirname $0)/..
.
./scripts/version.sh
.
./scripts/version.sh
if
[
"
${
OS
}
"
!=
"linux"
]
;
then
exit
fi
airgap_image_file
=
'scripts/airgap/image-list.txt'
airgap_image_file
=
'scripts/airgap/image-list.txt'
images
=
$(
cat
"
${
airgap_image_file
}
"
)
images
=
$(
cat
"
${
airgap_image_file
}
"
)
xargs
-n1
docker pull
<<<
"
${
images
}
"
xargs
-n1
docker pull
<<<
"
${
images
}
"
...
...
scripts/package-image
View file @
5c8f2364
...
@@ -5,6 +5,10 @@ cd $(dirname $0)/..
...
@@ -5,6 +5,10 @@ cd $(dirname $0)/..
.
./scripts/version.sh
.
./scripts/version.sh
if
[
"
${
OS
}
"
!=
"linux"
]
;
then
exit
fi
TAG
=
${
TAG
:-${
VERSION_TAG
}${
SUFFIX
}}
TAG
=
${
TAG
:-${
VERSION_TAG
}${
SUFFIX
}}
REPO
=
${
REPO
:-
rancher
}
REPO
=
${
REPO
:-
rancher
}
IMAGE_NAME
=
${
IMAGE_NAME
:-
k3s
}
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