From f8462b52186dcfec6219f8d66649be79337faf2a Mon Sep 17 00:00:00 2001 From: John Guo Date: Mon, 23 Oct 2023 19:28:26 +0800 Subject: [PATCH] split ci workflow into two workflows for short (#3069) --- .../{build_and_test.sh => ci-main.sh} | 0 .github/workflows/{gf.yml => ci-main.yml} | 8 +-- .github/workflows/ci-sub.sh | 27 ++++++++ .github/workflows/ci-sub.yml | 67 +++++++++++++++++++ .github/workflows/{cli.yml => release.yml} | 2 +- 5 files changed, 98 insertions(+), 6 deletions(-) rename .github/workflows/{build_and_test.sh => ci-main.sh} (100%) mode change 100755 => 100644 rename .github/workflows/{gf.yml => ci-main.yml} (97%) create mode 100644 .github/workflows/ci-sub.sh create mode 100644 .github/workflows/ci-sub.yml rename .github/workflows/{cli.yml => release.yml} (98%) diff --git a/.github/workflows/build_and_test.sh b/.github/workflows/ci-main.sh old mode 100755 new mode 100644 similarity index 100% rename from .github/workflows/build_and_test.sh rename to .github/workflows/ci-main.sh diff --git a/.github/workflows/gf.yml b/.github/workflows/ci-main.yml similarity index 97% rename from .github/workflows/gf.yml rename to .github/workflows/ci-main.yml index aab1a12bc..cc15c639b 100644 --- a/.github/workflows/gf.yml +++ b/.github/workflows/ci-main.yml @@ -1,3 +1,4 @@ +# The main codes build and unit testing running workflow. name: GoFrame Main CI @@ -183,9 +184,6 @@ jobs: - name: Start Consul Containers run: docker-compose -f ".github/workflows/consul/docker-compose.yml" up -d --build - # - name: Start Minikube - # uses: medyagh/setup-minikube@master - - name: Setup Golang ${{ matrix.go-version }} uses: actions/setup-go@v4 with: @@ -197,11 +195,11 @@ jobs: - name: Build & Test if: ${{ (github.event_name == 'push' && github.ref != 'refs/heads/master') || github.event_name == 'pull_request' }} - run: bash .github/workflows/build_and_test.sh + run: bash .github/workflows/ci-main.sh - name: Build & Test & Coverage if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} - run: bash .github/workflows/build_and_test.sh coverage + run: bash .github/workflows/ci-main.sh coverage - name: Stop Redis Cluster Containers run: docker-compose -f ".github/workflows/redis/docker-compose.yml" down diff --git a/.github/workflows/ci-sub.sh b/.github/workflows/ci-sub.sh new file mode 100644 index 000000000..28dbcf980 --- /dev/null +++ b/.github/workflows/ci-sub.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +coverage=$1 + +# find all path that contains go.mod. +for file in `find . -name go.mod`; do + dirpath=$(dirname $file) + echo $dirpath + + # package kuhecm needs golang >= v1.19 + if [ "kubecm" = $(basename $dirpath) ]; then + if ! go version|grep -qE "go1.19|go1.[2-9][0-9]"; then + echo "ignore kubecm as go version: $(go version)" + continue 1 + fi + else + continue 1 + fi + + cd $dirpath + + go mod tidy + go build ./... + go test ./... -race || exit 1 + + cd - +done diff --git a/.github/workflows/ci-sub.yml b/.github/workflows/ci-sub.yml new file mode 100644 index 000000000..ad1622441 --- /dev/null +++ b/.github/workflows/ci-sub.yml @@ -0,0 +1,67 @@ +# The sub codes build and unit testing running workflow. +# It maintains the ci of unimportant packages. +name: GoFrame Sub CI + + +on: + push: + branches: + - master + - develop + - personal/** + - feature/** + - enhance/** + - fix/** + + pull_request: + branches: + - master + - develop + - personal/** + - feature/** + - enhance/** + - fix/** + +# This allows a subsequently queued workflow run to interrupt previous runs +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: true + +env: + TZ: "Asia/Shanghai" + + +jobs: + code-test: + runs-on: ubuntu-latest + + strategy: + matrix: + go-version: [ "1.18", "1.19", "1.20", "1.21" ] + goarch: [ "386", "amd64" ] + + steps: + - name: Setup Timezone + uses: szenius/set-timezone@v1.1 + with: + timezoneLinux: "Asia/Shanghai" + + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Start Minikube + uses: medyagh/setup-minikube@master + + - name: Setup Golang ${{ matrix.go-version }} + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go-version }} + cache-dependency-path: '**/go.sum' + + - name: Before Script + run: bash .github/workflows/before_script.sh + + - name: Build & Test + run: bash .github/workflows/ci-sub.sh + + diff --git a/.github/workflows/cli.yml b/.github/workflows/release.yml similarity index 98% rename from .github/workflows/cli.yml rename to .github/workflows/release.yml index 4431a7957..fdef81879 100644 --- a/.github/workflows/cli.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: GoFrame CLI Build Release +name: GoFrame Release on: push: