From 83ed68511cfe44b2aaf5835f5465c33a7204ebfb Mon Sep 17 00:00:00 2001 From: intercepted16 <162676516+intercepted16@users.noreply.github.com> Date: Thu, 15 Aug 2024 19:35:34 +1000 Subject: [PATCH] chore: create separate CI files for `dev` and `master` This commit creates separate CI files for `dev` and `master`, enhancing efficiency. --- .github/workflows/dev-ci.yml | 52 +++++++++++++++++++++ .github/workflows/{ci.yml => master-ci.yml} | 35 +++++--------- 2 files changed, 64 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/dev-ci.yml rename .github/workflows/{ci.yml => master-ci.yml} (83%) diff --git a/.github/workflows/dev-ci.yml b/.github/workflows/dev-ci.yml new file mode 100644 index 0000000..528bc27 --- /dev/null +++ b/.github/workflows/dev-ci.yml @@ -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 ./... \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/master-ci.yml similarity index 83% rename from .github/workflows/ci.yml rename to .github/workflows/master-ci.yml index 5288607..693435f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/master-ci.yml @@ -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: @@ -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: