-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from isd-sgcu/feature/ci-workflow
[Feature] CI Workflow
- Loading branch information
Showing
7 changed files
with
168 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: "Build and Deploy" | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- beta | ||
- dev | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.21 | ||
check-latest: true | ||
cache: true | ||
|
||
- name: Download dependencies | ||
run: go mod download | ||
|
||
- name: Vet | ||
run: | | ||
go vet ./... | ||
- name: Test | ||
run: | | ||
go test -v -coverpkg ./src/internal/... -coverprofile coverage.out -covermode count ./src/internal/... | ||
go tool cover -func="./coverage.out" | ||
build: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- test | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Build Docker image | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
push: false | ||
tags: test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: "Pull request: Run unit test" | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
- beta | ||
- dev | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.21 | ||
check-latest: true | ||
cache: true | ||
|
||
- name: Download dependencies | ||
run: go mod download | ||
|
||
- name: Vet | ||
run: | | ||
go vet ./... | ||
- name: Test | ||
run: | | ||
go test -v -coverpkg ./src/internal/... -coverprofile coverage.out -covermode count ./src/internal/... | ||
go tool cover -func="./coverage.out" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: "Pull request: Build test" | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
- beta | ||
- dev | ||
|
||
jobs: | ||
docker-build: | ||
name: "Docker build and create an image" | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Build Docker image | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
push: false | ||
tags: test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Base Image | ||
FROM golang:1.21.4-alpine3.18 as base | ||
|
||
# Working directory | ||
WORKDIR /app | ||
|
||
# Copy go.mod and go.sum files | ||
COPY go.mod go.sum ./ | ||
|
||
# Download dependencies | ||
RUN go mod download | ||
|
||
# Copy the source code | ||
COPY ./src ./src | ||
|
||
# Build the application | ||
RUN go build -o server ./src/. | ||
|
||
# Copy config files | ||
COPY ./config ./config | ||
|
||
# Adding the grpc_health_probe | ||
RUN GRPC_HEALTH_PROBE_VERSION=v0.3.1 && \ | ||
wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ | ||
chmod +x /bin/grpc_health_probe | ||
|
||
# Create master image | ||
FROM alpine AS master | ||
|
||
# Working directory | ||
WORKDIR /app | ||
|
||
# Copy grpc_heath_prob | ||
COPY --from=base /bin/grpc_health_probe ./ | ||
|
||
# Copy execute file | ||
COPY --from=base /app/server ./ | ||
|
||
# Copy config files | ||
COPY --from=base /app/config ./config | ||
|
||
# Set ENV to production | ||
ENV GO_ENV production | ||
|
||
# Expose port 3002 | ||
EXPOSE 3002 | ||
|
||
# Run the application | ||
CMD ["./server"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters