diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e04f11d53..0cf8703bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 }} @@ -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 @@ -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 @@ -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) @@ -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-* \ No newline at end of file diff --git a/hack/cluster.sh b/hack/cluster.sh index 63c0108fb..1a1ab904b 100755 --- a/hack/cluster.sh +++ b/hack/cluster.sh @@ -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) @@ -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 @@ -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() { @@ -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 diff --git a/hack/clustertemplete/kindconfig b/hack/clustertemplete/kindconfig index c0f612fa2..7cae75941 100644 --- a/hack/clustertemplete/kindconfig +++ b/hack/clustertemplete/kindconfig @@ -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__ \ No newline at end of file diff --git a/hack/rune2e.sh b/hack/rune2e.sh index aed252651..38671b87b 100755 --- a/hack/rune2e.sh +++ b/hack/rune2e.sh @@ -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" \ @@ -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 \ No newline at end of file diff --git a/hack/verify-staticcheck.sh b/hack/verify-staticcheck.sh new file mode 100755 index 000000000..04bb30d76 --- /dev/null +++ b/hack/verify-staticcheck.sh @@ -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