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..7748e23 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md @@ -0,0 +1,13 @@ +## Change made + +- [ ]  New features +- [ ]  Bug fixes +- [ ]  Breaking changes +## 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 diff --git a/internal/user/user.repository.go b/internal/user/user.repository.go deleted file mode 100644 index 7e72506..0000000 --- a/internal/user/user.repository.go +++ /dev/null @@ -1,22 +0,0 @@ -package user - -import ( - "github.com/isd-sgcu/rpkm67-model/model" - "gorm.io/gorm" -) - -type Repository interface { - FindByEmail(email string, user *model.User) error -} - -type repositoryImpl struct { - Db *gorm.DB -} - -func NewRepository(db *gorm.DB) Repository { - return &repositoryImpl{Db: db} -} - -func (r *repositoryImpl) FindByEmail(email string, user *model.User) error { - return r.Db.First(user, "email = ?", email).Error -} diff --git a/internal/user/user.service.go b/internal/user/user.service.go deleted file mode 100644 index a00006b..0000000 --- a/internal/user/user.service.go +++ /dev/null @@ -1 +0,0 @@ -package user