Skip to content

Commit

Permalink
chore: create separate CI files for dev and master
Browse files Browse the repository at this point in the history
This commit creates separate CI files for `dev` and `master`, enhancing efficiency.
  • Loading branch information
intercepted16 committed Aug 15, 2024
1 parent 9bddb50 commit 83ed685
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 23 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/dev-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Dev CI
permissions:
contents: read
on:
push:
branches: [dev]
jobs:
test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
matrix:
go: ['stable', 'oldstable']
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Cache Go Modules
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/go/bin
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
- name: Go Format
run: |
gofmt -s -w .
if [ -n "$(git diff --exit-code)" ]; then
echo "::warning::there are uncommitted changes after running go fmt"
fi
- name: Go Vet
run: go vet ./...
- name: Go Tidy
run: go mod tidy
- name: Go Mod Download
run: go mod download
- name: Go Mod Verify
run: go mod verify
- name: Go Generate
run: |
go generate ./...
if [ -n "$(git diff --exit-code)" ]; then
echo "::warning::there are uncommitted changes after running go generate"
fi
- name: Go Test
run: go test -v -count=1 -race -shuffle=on -coverprofile=coverage.txt ./...
35 changes: 12 additions & 23 deletions .github/workflows/ci.yml → .github/workflows/master-ci.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
name: Test and Build
name: Master CI
permissions:
contents: write
on:
push:
branches: [master]
pull_request:

branches: [master]
jobs:
build:
name: Build
test:
name: Test
runs-on: ubuntu-latest
if: github.event_name == 'push'
timeout-minutes: 5
strategy:
matrix:
go: [ 'stable', 'oldstable' ]
go: ['stable']
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Cache Go Modules
uses: actions/cache@v3
with:
Expand All @@ -26,56 +27,44 @@ jobs:
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}

- name: Go Format
run: |
gofmt -s -w .
if [ -n "$(git diff --exit-code)" ]; then
echo "::warning::there are uncommitted changes after running go fmt"
fi
- name: Go Vet
run: go vet ./...

- name: Go Tidy
run: go mod tidy

- name: Go Mod Download
run: go mod download

- name: Go Mod Verify
run: go mod verify

- name: Go Generate
run: |
go generate ./...
if [ -n "$(git diff --exit-code)" ]; then
echo "::warning::there are uncommitted changes after running go generate"
fi
- name: Go Build
run: go build -o mtafoubs ./...

- name: Go Test
if: ${{ inputs.skipTests == 'false' }}
run: go test -v -count=1 -race -shuffle=on -coverprofile=coverage.txt ./...

- name: Go Compile Tests
if: ${{ inputs.skipTests == 'true' }}
run: go test -exec /bin/true ./...

tag_and_upload:
name: Create Tag and Upload Artifact
runs-on: ubuntu-latest
needs: test
steps:
- name: Create and Push Tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git tag "build-$(date +'%Y%m%d%H%M%S')"
git push origin --tags
- name: Upload Compiled File
uses: actions/upload-artifact@v3
with:
Expand Down

0 comments on commit 83ed685

Please sign in to comment.