Skip to content

Commit

Permalink
Merge pull request kosmos-io#425 from village-way/main
Browse files Browse the repository at this point in the history
update github ci workflow fix e2e run failed
  • Loading branch information
kosmos-robot authored Mar 4, 2024
2 parents be9af7d + 32855b3 commit 31d82f6
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 29 deletions.
45 changes: 22 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,19 @@ name: CI
on:
push:
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.actor }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
golangci:
name: lint
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
- name: golint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54.1
verify:
name: verify
runs-on: ubuntu-22.04
runs-on: self-hosted
if: ${{ always() }}
env:
GOPATH: ${{ github.workspace }}
#GOPATH: ${{ github.workspace }}
WORKSPACE: ${{ github.workspace }}/src/github.com/kosmos-io/kosmos
GOPROXY: "https://goproxy.cn,direct"
defaults:
run:
working-directory: ${{ env.WORKSPACE }}
Expand All @@ -35,13 +27,18 @@ jobs:
uses: actions/setup-go@v4
with:
go-version: '1.20'
- run: hack/verify-vendor.sh
- run: hack/verify-codegen.sh
- run: hack/verify-crds.sh
- name: lint
run: hack/verify-staticcheck.sh
- name: vendor
run: hack/verify-vendor.sh
- name: codegen
run: hack/verify-codegen.sh
- name: crds
run: hack/verify-crds.sh
build:
name: build
needs: verify
runs-on: ubuntu-22.04
runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -57,7 +54,7 @@ jobs:
test:
name: Unit test
needs: build
runs-on: ubuntu-22.04
runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -69,7 +66,9 @@ jobs:
e2e:
name: E2e test
needs: build
runs-on: ubuntu-22.04
env:
GOPROXY: "https://goproxy.cn,direct"
runs-on: self-hosted
steps:
# Free up disk space on Ubuntu
- name: Free Disk Space (Ubuntu)
Expand Down Expand Up @@ -101,4 +100,4 @@ jobs:
if: failure()
with:
name: kosmos-e2e-logs-${{ github.run_id }}
path: ${{ github.workspace }}/e2e-test/logs-*
path: ${{ github.workspace }}/e2e-test/logs-*
14 changes: 10 additions & 4 deletions hack/cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ set -o pipefail
HOST_CLUSTER_NAME="cluster-host"
CURRENT="$(dirname "${BASH_SOURCE[0]}")"
ROOT=$(dirname "${BASH_SOURCE[0]}")/..
KIND_IMAGE="ghcr.io/kosmos-io/node:v1.25.3"
#KIND_IMAGE="ghcr.io/kosmos-io/node:v1.25.3"
KIND_IMAGE="kindest/node:v1.27.2"
# true: when cluster is exist, reuse exist one!
REUSE=${REUSE:-false}
VERSION=${VERSION:-latest}
#VERSION=${VERSION:-latest}
VERSION="v0.2.0"

# default cert and key for node server https
CERT=$(cat ${ROOT}/pkg/cert/crt.pem | base64 -w 0)
Expand All @@ -34,6 +36,10 @@ function create_cluster() {

CLUSTER_DIR="${ROOT}/environments/${clustername}"
mkdir -p "${CLUSTER_DIR}"

echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
echo "$CLUSTER_DIR"

ipFamily=ipv4
if [ "$isDual" == true ]; then
ipFamily=dual
Expand Down Expand Up @@ -197,7 +203,7 @@ function join_cluster_by_ctl() {
local member_cluster=$2
HOST_CLUSTER_DIR="${ROOT}/environments/${host_cluster}"
MEMBER_CLUSTER_DIR="${ROOT}/environments/${member_cluster}"
kosmosctl join cluster --name $member_cluster --host-kubeconfig $HOST_CLUSTER_DIR/kubeconfig --kubeconfig $MEMBER_CLUSTER_DIR/kubeconfig --enable-all --version latest
kosmosctl join cluster --name $member_cluster --host-kubeconfig $HOST_CLUSTER_DIR/kubeconfig --kubeconfig $MEMBER_CLUSTER_DIR/kubeconfig --enable-all --version ${VERSION}
}

function addTaint() {
Expand All @@ -215,7 +221,7 @@ function deploy_cluster_by_ctl() {
local -r clustername=$1
CLUSTER_DIR="${ROOT}/environments/${clustername}"
load_cluster_images "$clustername"
kosmosctl install --version latest --kubeconfig $CLUSTER_DIR/kubeconfig
kosmosctl install --version ${VERSION} --kubeconfig $CLUSTER_DIR/kubeconfig

kubectl --context="kind-${clustername}" apply -f "$ROOT"/deploy/crds

Expand Down
12 changes: 11 additions & 1 deletion hack/clustertemplete/kindconfig
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
containerdConfigPatches:
- |
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
SystemdCgroup = false
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.test-handler.options]
SystemdCgroup = false
nodes:
- role: control-plane
kubeadmConfigPatches:
- |
kind: KubeletConfiguration
cgroupDriver: cgroupfs
#- role: worker
networking:
ipFamily: __IP_FAMILY__
disableDefaultCNI: true # disable kindnet
podSubnet: __POD_CIDR__
serviceSubnet: __SERVICE_CIDR__
serviceSubnet: __SERVICE_CIDR__
3 changes: 2 additions & 1 deletion hack/rune2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ MEMBER3_CLUSTER_NAME="cluster-member3"
ROOT="$(dirname "${BASH_SOURCE[0]}")"
source "${ROOT}/util.sh"


# e2e for nginx and mcs
kubectl --context="kind-${HOST_CLUSTER_NAME}" apply -f "${ROOT}"/../test/e2e/deploy/nginx
util::wait_for_condition "nginx are ready" \
Expand Down Expand Up @@ -84,4 +85,4 @@ kind export logs --name="$MEMBER3_CLUSTER_NAME" "$LOG_PATH/$MEMBER3_CLUSTER_NAME

#TODO delete cluster

exit $TESTING_RESULT
exit $TESTING_RESULT
29 changes: 29 additions & 0 deletions hack/verify-staticcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
GOLANGCI_LINT_VER="v1.52.2"

cd "${REPO_ROOT}"
source "hack/util.sh"

if util::cmd_exist golangci-lint ; then
echo "Using golangci-lint version:"
golangci-lint version
else
echo "Installing golangci-lint ${GOLANGCI_LINT_VER}"
# https://golangci-lint.run/usage/install/#other-ci
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VER}
fi

if golangci-lint run; then
echo 'Congratulations! All Go source files have passed staticcheck.'
else
echo # print one empty line, separate from warning messages.
echo 'Please review the above warnings.'
echo 'If the above warnings do not make sense, feel free to file an issue.'
exit 1
fi

0 comments on commit 31d82f6

Please sign in to comment.