From ed1e4f0cc230b1fcc7c9079e9b02aebc4b65699d Mon Sep 17 00:00:00 2001 From: Idhibhat Pankam Date: Wed, 26 Jun 2024 00:39:55 +0700 Subject: [PATCH] workflow --- .../pull_request_template.md | 14 ++++++ .github/workflows/build-deploy.yml | 43 +++++++++++++++++++ .github/workflows/run-unit-test.yml | 38 ++++++++++++++++ .github/workflows/test-build.yml | 32 ++++++++++++++ 4 files changed, 127 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE/pull_request_template.md create mode 100644 .github/workflows/build-deploy.yml create mode 100644 .github/workflows/run-unit-test.yml create mode 100644 .github/workflows/test-build.yml diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md new file mode 100644 index 0000000..4e3db6c --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md @@ -0,0 +1,14 @@ +## Change made + +- [ ]  New features +- [ ]  Bug fixes +- [ ]  Breaking changes +- [ ] Refactor +## Describe what you have done +- +### New Features +- +### Fix +- +### Others +- \ No newline at end of file diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml new file mode 100644 index 0000000..0987ec6 --- /dev/null +++ b/.github/workflows/build-deploy.yml @@ -0,0 +1,43 @@ +name: Build + +on: + workflow_dispatch: + push: + branches: + - main + - dev + tags: + - v* + +env: + IMAGE_NAME: ghcr.io/${{ github.repository }} + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to the Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ github.token }} + + - name: Build and Push Docker Image + uses: docker/build-push-action@v3 + with: + push: true + tags: ${{ env.IMAGE_NAME }}:${{ github.ref_type == 'tag' && github.ref_name || github.sha }} + cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache + cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max + +# docker pull --platform linux/x86_64 \ No newline at end of file diff --git a/.github/workflows/run-unit-test.yml b/.github/workflows/run-unit-test.yml new file mode 100644 index 0000000..4c266a9 --- /dev/null +++ b/.github/workflows/run-unit-test.yml @@ -0,0 +1,38 @@ +name: 'Pull request/Push: Run unit test' + +on: + pull_request: + branches: + - dev + - master + - main + - beta + push: + branches: + - dev + - master + - main + - beta + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.22 + + - name: Download dependencies + run: go mod download + + - name: Vet + run: | + go vet ./... + + - name: Test + run: | + go test -v -coverpkg ./internal/... -coverprofile coverage.out -covermode count ./internal/... + go tool cover -func="./coverage.out" diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml new file mode 100644 index 0000000..7d24ab2 --- /dev/null +++ b/.github/workflows/test-build.yml @@ -0,0 +1,32 @@ +name: Lint + +on: + push: + branches: + - main + - dev + tags: + - v* + pull_request: + +permissions: + contents: read + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: '1.22.4' + cache: false + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: v1.55