From 5dc8106bd679b755de654993fce5dc1ce6d79d6c Mon Sep 17 00:00:00 2001 From: yxscott <2535955902@qq.com> Date: Mon, 18 Jul 2022 22:06:29 +0800 Subject: [PATCH 1/3] add ci flow --- .github/workflows/go-ci.yml | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/go-ci.yml diff --git a/.github/workflows/go-ci.yml b/.github/workflows/go-ci.yml new file mode 100644 index 0000000..8acaabc --- /dev/null +++ b/.github/workflows/go-ci.yml @@ -0,0 +1,40 @@ +name: Run Tests + +on: + push: + branches: [ '*' ] + pull_request: + branches: [ '*' ] + +jobs: +# lint: +# runs-on: ubuntu-latest +# steps: +# - name: Setup go +# uses: actions/setup-go@v2 +# with: +# go-version: '1.18' +# - name: Checkout repository +# uses: actions/checkout@v2 +# - name: Setup golangci-lint +# uses: golangci/golangci-lint-action@v3.2.0 +# with: +# version: v1.45.0 +# args: --verbose + test: + name: build and test + runs-on: ubuntu-latest + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18 + + - name: Checkout Code + uses: actions/checkout@v2 + + - name: Run Tests + run: go test ./... + +# - name: Upload coverage to Codecov +# uses: codecov/codecov-action@v2 From 55a08651a1da52d9ba81a2d78c1dad03beb2f316 Mon Sep 17 00:00:00 2001 From: yxscott <2535955902@qq.com> Date: Mon, 18 Jul 2022 22:42:35 +0800 Subject: [PATCH 2/3] add dockerfile --- Dockerfile | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2f40c71 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM golang:1.18.1-alpine as builder + +WORKDIR /build + +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \ + apk update --no-cache && apk add --no-cache gcc musl-dev + +COPY go.mod . +COPY go.sum . +RUN go env -w GOPROXY=https://goproxy.cn,direct && go mod download +COPY . . +RUN go build -ldflags="-s -w" -o /app/httpserver ./main.go + +FROM alpine + +ENV TZ Asia/Shanghai +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \ + apk update --no-cache && apk add --no-cache ca-certificates + +WORKDIR /app +COPY --from=builder /app/httpserver ./httpserver + +EXPOSE 8000 + +CMD [ "./httpserver", "-ip", "0.0.0.0" ] \ No newline at end of file From ea43183199b293ef3beda1a7dd0002d925ec6584 Mon Sep 17 00:00:00 2001 From: yxscott <2535955902@qq.com> Date: Tue, 19 Jul 2022 19:53:49 +0800 Subject: [PATCH 3/3] add stage download dependencies --- .github/workflows/go-ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/go-ci.yml b/.github/workflows/go-ci.yml index 8acaabc..b092da1 100644 --- a/.github/workflows/go-ci.yml +++ b/.github/workflows/go-ci.yml @@ -33,8 +33,13 @@ jobs: - name: Checkout Code uses: actions/checkout@v2 + - name: download dependencies + run: go get + - name: Run Tests run: go test ./... + + # - name: Upload coverage to Codecov # uses: codecov/codecov-action@v2