Skip to content

Commit

Permalink
split ci workflow into two workflows for short (#3069)
Browse files Browse the repository at this point in the history
  • Loading branch information
gqcn committed Oct 23, 2023
1 parent b2bd12a commit f8462b5
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 6 deletions.
File renamed without changes.
8 changes: 3 additions & 5 deletions .github/workflows/gf.yml → .github/workflows/ci-main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# The main codes build and unit testing running workflow.
name: GoFrame Main CI


Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/ci-sub.sh
Original file line number Diff line number Diff line change
@@ -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
67 changes: 67 additions & 0 deletions .github/workflows/ci-sub.yml
Original file line number Diff line number Diff line change
@@ -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


Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: GoFrame CLI Build Release
name: GoFrame Release

on:
push:
Expand Down

0 comments on commit f8462b5

Please sign in to comment.