From 7d43e9cd64932634016df8cf6c97e597aa9a2e94 Mon Sep 17 00:00:00 2001 From: roman_harazha Date: Mon, 13 Nov 2023 17:31:33 +0200 Subject: [PATCH] add CI; fix module name --- .github/workflows/actions.yml | 32 ++++++++++++++++ .github/workflows/actions_onlymain.yml | 37 +++++++++++++++++++ .github/workflows/tag.yml | 34 +++++++++++++++++ Dockerfile | 4 +- README.md | 6 +-- generate.sh | 4 +- go.mod | 4 +- internal/cli/main.go | 7 ++-- internal/cli/migrate.go | 4 +- internal/data/pg/main.go | 2 +- internal/data/pg/verify_requests.go | 2 +- internal/service/api/handlers/ctx.go | 5 +-- .../api/handlers/verification_callback.go | 4 +- .../api/handlers/verification_request.go | 2 +- .../api/handlers/verification_response.go | 4 +- internal/service/api/main.go | 9 ++--- internal/service/api/middleware/main.go | 8 ++-- internal/service/api/responses/jwz.go | 2 +- .../api/responses/verification_request.go | 4 +- internal/service/api/router.go | 6 +-- internal/service/core/db_cleaner/main.go | 6 +-- internal/service/core/handlers.go | 4 +- internal/service/core/main.go | 8 ++-- main.go | 2 +- werf.yaml | 8 ++-- 25 files changed, 154 insertions(+), 54 deletions(-) create mode 100644 .github/workflows/actions.yml create mode 100644 .github/workflows/actions_onlymain.yml create mode 100644 .github/workflows/tag.yml diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml new file mode 100644 index 0000000..164fc2e --- /dev/null +++ b/.github/workflows/actions.yml @@ -0,0 +1,32 @@ +name: Build verify proxy docker image +on: + workflow_dispatch: + +jobs: + converge: + name: Converge + runs-on: ubuntu-latest + steps: + + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install werf + uses: werf/actions/install@v1.2 + + - name: Log in to registry + # This is where you will update the personal access token to GITHUB_TOKEN + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin + + - name: Run echo + run: | + werf version + docker version + echo $GITHUB_REPOSITORY + echo $GITHUB_SHA + - name: Run Build + run: | + . $(werf ci-env github --as-file) + werf export service --tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA \ No newline at end of file diff --git a/.github/workflows/actions_onlymain.yml b/.github/workflows/actions_onlymain.yml new file mode 100644 index 0000000..68b3ffa --- /dev/null +++ b/.github/workflows/actions_onlymain.yml @@ -0,0 +1,37 @@ +name: Build verify proxy docker image +on: + push: + branches: + - 'main' + - 'master' + - 'chains/mainnet' + - 'chains/mainnet-beta' + +jobs: + converge: + name: Converge + runs-on: ubuntu-latest + steps: + + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install werf + uses: werf/actions/install@v1.2 + + - name: Log in to registry + # This is where you will update the personal access token to GITHUB_TOKEN + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin + + - name: Run echo + run: | + werf version + docker version + echo $GITHUB_REPOSITORY + echo $GITHUB_SHA + - name: Run Build + run: | + . $(werf ci-env github --as-file) + werf export service --tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA \ No newline at end of file diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml new file mode 100644 index 0000000..dd2fe67 --- /dev/null +++ b/.github/workflows/tag.yml @@ -0,0 +1,34 @@ +name: Build verify proxy docker image +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + +jobs: + converge: + name: Converge + runs-on: ubuntu-latest + steps: + + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install werf + uses: werf/actions/install@v1.2 + + - name: Log in to registry + # This is where you will update the personal access token to GITHUB_TOKEN + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin + + - name: Run echo + run: | + werf version + docker version + echo $GITHUB_REPOSITORY + echo $GITHUB_REF_NAME + - name: Run Build + run: | + . $(werf ci-env github --as-file) + werf export service --tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_REF_NAME \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 424cdab..8116375 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ FROM golang:1.19 as buildbase -WORKDIR /go/src/gitlab.com/rarimo/identity/verify-proxy +WORKDIR /go/src/github.com/rarimo/verify-proxy COPY . . -RUN CGO_ENABLED=1 GOOS=linux go build -o /usr/local/bin/verify-proxy /go/src/gitlab.com/rarimo/identity/verify-proxy +RUN CGO_ENABLED=1 GOOS=linux go build -o /usr/local/bin/verify-proxy /go/src/github.com/rarimo/verify-proxy FROM alpine:3.18.2 diff --git a/README.md b/README.md index 8eb97ca..e8d1fed 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ The service is designed to receive callbacks from PolygonID Wallet application. ## Install ``` - git clone gitlab.com/rarimo/polygonid/verify-proxy + git clone github.com/rarimo/verify-proxy cd verify-proxy go build main.go export KV_VIPER_FILE=./config.yaml @@ -39,8 +39,8 @@ Make sure that docker installed. use `docker run ` with `-p 8080:80` to expose port 80 to 8080 ``` - docker build -t gitlab.com/rarimo/polygonid/verify-proxy . - docker run -e KV_VIPER_FILE=/config.yaml gitlab.com/rarimo/polygonid/verify-proxy + docker build -t github.com/rarimo/verify-proxy . + docker run -e KV_VIPER_FILE=/config.yaml github.com/rarimo/verify-proxy ``` ## Running from Source diff --git a/generate.sh b/generate.sh index 38e26e3..6c651ac 100755 --- a/generate.sh +++ b/generate.sh @@ -3,8 +3,8 @@ GENERATOR_IMAGE=registry.gitlab.com/tokend/openapi-go-generator:69f004b58152c83f007b593cc13e94b81d7200da -GENERATED="${GOPATH}/src/gitlab.com/rarimo/polygonid/verify-proxy/resources" -OPENAPI_DIR="${GOPATH}/src/gitlab.com/rarimo/polygonid/verify-proxy/docs/web_deploy" +GENERATED="${GOPATH}/src/github.com/rarimo/verify-proxy/resources" +OPENAPI_DIR="${GOPATH}/src/github.com/rarimo/verify-proxy/docs/web_deploy" PACKAGE_NAME=resources function printHelp { diff --git a/go.mod b/go.mod index fb3faf5..3ffa50f 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module gitlab.com/rarimo/polygonid/verify-proxy +module github.com/rarimo/verify-proxy go 1.19 @@ -17,6 +17,7 @@ require ( gitlab.com/distributed_lab/figure v2.1.0+incompatible gitlab.com/distributed_lab/kit v1.11.2 gitlab.com/distributed_lab/logan v3.8.1+incompatible + gitlab.com/distributed_lab/running v0.0.0-20200706131153-4af0e83eb96c ) require ( @@ -55,7 +56,6 @@ require ( github.com/spf13/viper v1.3.2 // indirect github.com/stretchr/testify v1.8.4 // indirect gitlab.com/distributed_lab/lorem v0.2.0 // indirect - gitlab.com/distributed_lab/running v0.0.0-20200706131153-4af0e83eb96c // indirect golang.org/x/crypto v0.9.0 // indirect golang.org/x/sys v0.10.0 // indirect golang.org/x/text v0.9.0 // indirect diff --git a/internal/cli/main.go b/internal/cli/main.go index fb43d02..f216af5 100644 --- a/internal/cli/main.go +++ b/internal/cli/main.go @@ -2,17 +2,16 @@ package cli import ( "context" + "gitlab.com/distributed_lab/logan/v3" "os" "os/signal" "sync" "syscall" "github.com/alecthomas/kingpin" + "github.com/rarimo/verify-proxy/internal/config" + "github.com/rarimo/verify-proxy/internal/service/api" "gitlab.com/distributed_lab/kit/kv" - "gitlab.com/distributed_lab/logan/v3" - - "gitlab.com/rarimo/polygonid/verify-proxy/internal/config" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/service/api" ) func Run(args []string) bool { diff --git a/internal/cli/migrate.go b/internal/cli/migrate.go index 0658148..69aac0f 100644 --- a/internal/cli/migrate.go +++ b/internal/cli/migrate.go @@ -4,8 +4,8 @@ import ( migrate "github.com/rubenv/sql-migrate" "gitlab.com/distributed_lab/logan/v3/errors" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/assets" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/config" + "github.com/rarimo/verify-proxy/internal/assets" + "github.com/rarimo/verify-proxy/internal/config" ) var migrations = &migrate.EmbedFileSystemMigrationSource{ diff --git a/internal/data/pg/main.go b/internal/data/pg/main.go index e824112..14f01ea 100644 --- a/internal/data/pg/main.go +++ b/internal/data/pg/main.go @@ -3,7 +3,7 @@ package pg import ( "gitlab.com/distributed_lab/kit/pgdb" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/data" + "github.com/rarimo/verify-proxy/internal/data" ) const ( diff --git a/internal/data/pg/verify_requests.go b/internal/data/pg/verify_requests.go index 85b9476..faa605d 100644 --- a/internal/data/pg/verify_requests.go +++ b/internal/data/pg/verify_requests.go @@ -11,7 +11,7 @@ import ( sq "github.com/Masterminds/squirrel" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/data" + "github.com/rarimo/verify-proxy/internal/data" ) type verifyRequestsQ struct { diff --git a/internal/service/api/handlers/ctx.go b/internal/service/api/handlers/ctx.go index d900fbe..8efe9dd 100644 --- a/internal/service/api/handlers/ctx.go +++ b/internal/service/api/handlers/ctx.go @@ -2,11 +2,10 @@ package handlers import ( "context" - "net/http" - "gitlab.com/distributed_lab/logan/v3" + "net/http" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/service/core" + "github.com/rarimo/verify-proxy/internal/service/core" ) type ctxKey int diff --git a/internal/service/api/handlers/verification_callback.go b/internal/service/api/handlers/verification_callback.go index 84eb129..e3efc08 100644 --- a/internal/service/api/handlers/verification_callback.go +++ b/internal/service/api/handlers/verification_callback.go @@ -7,8 +7,8 @@ import ( "gitlab.com/distributed_lab/ape" "gitlab.com/distributed_lab/ape/problems" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/service/api/requests" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/service/core" + "github.com/rarimo/verify-proxy/internal/service/api/requests" + "github.com/rarimo/verify-proxy/internal/service/core" ) func VerificationCallback(w http.ResponseWriter, r *http.Request) { diff --git a/internal/service/api/handlers/verification_request.go b/internal/service/api/handlers/verification_request.go index c845b3e..cf7aac6 100644 --- a/internal/service/api/handlers/verification_request.go +++ b/internal/service/api/handlers/verification_request.go @@ -6,7 +6,7 @@ import ( "gitlab.com/distributed_lab/ape" "gitlab.com/distributed_lab/ape/problems" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/service/api/responses" + "github.com/rarimo/verify-proxy/internal/service/api/responses" ) func VerificationRequest(w http.ResponseWriter, r *http.Request) { diff --git a/internal/service/api/handlers/verification_response.go b/internal/service/api/handlers/verification_response.go index eb6df62..c0b72f3 100644 --- a/internal/service/api/handlers/verification_response.go +++ b/internal/service/api/handlers/verification_response.go @@ -7,8 +7,8 @@ import ( "gitlab.com/distributed_lab/ape" "gitlab.com/distributed_lab/ape/problems" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/service/api/responses" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/service/core" + "github.com/rarimo/verify-proxy/internal/service/api/responses" + "github.com/rarimo/verify-proxy/internal/service/core" ) func VerificationResponse(w http.ResponseWriter, r *http.Request) { diff --git a/internal/service/api/main.go b/internal/service/api/main.go index f96e68a..0a34247 100644 --- a/internal/service/api/main.go +++ b/internal/service/api/main.go @@ -2,15 +2,14 @@ package api import ( "context" + "gitlab.com/distributed_lab/logan/v3" "net" + "github.com/rarimo/verify-proxy/internal/config" + "github.com/rarimo/verify-proxy/internal/service/core" + dbcleaner "github.com/rarimo/verify-proxy/internal/service/core/db_cleaner" "gitlab.com/distributed_lab/ape" "gitlab.com/distributed_lab/kit/copus/types" - "gitlab.com/distributed_lab/logan/v3" - - "gitlab.com/rarimo/polygonid/verify-proxy/internal/config" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/service/core" - dbcleaner "gitlab.com/rarimo/polygonid/verify-proxy/internal/service/core/db_cleaner" ) type service struct { diff --git a/internal/service/api/middleware/main.go b/internal/service/api/middleware/main.go index 251a7cb..77c0691 100644 --- a/internal/service/api/middleware/main.go +++ b/internal/service/api/middleware/main.go @@ -3,17 +3,17 @@ package middleware import ( "context" "encoding/json" + "github.com/golang-jwt/jwt/v4" "net/http" "strings" "time" "github.com/fatih/structs" - "github.com/golang-jwt/jwt/v4" "github.com/pkg/errors" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/config" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/service/api/handlers" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/service/core" + "github.com/rarimo/verify-proxy/internal/config" + "github.com/rarimo/verify-proxy/internal/service/api/handlers" + "github.com/rarimo/verify-proxy/internal/service/core" ) func AuthMiddleware(cfg *config.JWT) func(http.Handler) http.Handler { diff --git a/internal/service/api/responses/jwz.go b/internal/service/api/responses/jwz.go index 470252e..9241c5c 100644 --- a/internal/service/api/responses/jwz.go +++ b/internal/service/api/responses/jwz.go @@ -1,6 +1,6 @@ package responses -import "gitlab.com/rarimo/polygonid/verify-proxy/resources" +import "github.com/rarimo/verify-proxy/resources" func NewJWZ(jwz string) *resources.JwzResponse { return &resources.JwzResponse{ diff --git a/internal/service/api/responses/verification_request.go b/internal/service/api/responses/verification_request.go index d4af59c..d6ef09a 100644 --- a/internal/service/api/responses/verification_request.go +++ b/internal/service/api/responses/verification_request.go @@ -1,11 +1,11 @@ package responses import ( - //"gitlab.com/rarimo/polygonid/verify-proxy/resources" + //"github.com/rarimo/verify-proxy/resources" "github.com/google/uuid" - "gitlab.com/rarimo/polygonid/verify-proxy/resources" + "github.com/rarimo/verify-proxy/resources" ) func NewVerificationID(requestID *uuid.UUID, jwt string) *resources.VerifyIdResponse { diff --git a/internal/service/api/router.go b/internal/service/api/router.go index 7dd5ee8..f13d743 100644 --- a/internal/service/api/router.go +++ b/internal/service/api/router.go @@ -6,9 +6,9 @@ import ( "github.com/go-chi/chi" "gitlab.com/distributed_lab/ape" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/service/api/handlers" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/service/api/middleware" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/service/api/requests" + "github.com/rarimo/verify-proxy/internal/service/api/handlers" + "github.com/rarimo/verify-proxy/internal/service/api/middleware" + "github.com/rarimo/verify-proxy/internal/service/api/requests" ) func (s *service) router() chi.Router { diff --git a/internal/service/core/db_cleaner/main.go b/internal/service/core/db_cleaner/main.go index 0210af0..dc21b23 100644 --- a/internal/service/core/db_cleaner/main.go +++ b/internal/service/core/db_cleaner/main.go @@ -8,9 +8,9 @@ import ( "gitlab.com/distributed_lab/logan/v3" "gitlab.com/distributed_lab/running" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/config" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/data" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/data/pg" + "github.com/rarimo/verify-proxy/internal/config" + "github.com/rarimo/verify-proxy/internal/data" + "github.com/rarimo/verify-proxy/internal/data/pg" ) type Cleaner interface { diff --git a/internal/service/core/handlers.go b/internal/service/core/handlers.go index 0d28cc1..4233864 100644 --- a/internal/service/core/handlers.go +++ b/internal/service/core/handlers.go @@ -6,8 +6,8 @@ import ( "github.com/google/uuid" "github.com/pkg/errors" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/data" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/service/api/requests" + "github.com/rarimo/verify-proxy/internal/data" + "github.com/rarimo/verify-proxy/internal/service/api/requests" ) func (v *verifyProxy) NewVerificationRequest() (*uuid.UUID, string, error) { diff --git a/internal/service/core/main.go b/internal/service/core/main.go index 3f04b01..069ab89 100644 --- a/internal/service/core/main.go +++ b/internal/service/core/main.go @@ -5,10 +5,10 @@ import ( "github.com/google/uuid" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/config" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/data" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/data/pg" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/service/api/requests" + "github.com/rarimo/verify-proxy/internal/config" + "github.com/rarimo/verify-proxy/internal/data" + "github.com/rarimo/verify-proxy/internal/data/pg" + "github.com/rarimo/verify-proxy/internal/service/api/requests" ) type VerifyProxy interface { diff --git a/main.go b/main.go index 7217544..141653d 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,7 @@ package main import ( "os" - "gitlab.com/rarimo/polygonid/verify-proxy/internal/cli" + "github.com/rarimo/verify-proxy/internal/cli" ) func main() { diff --git a/werf.yaml b/werf.yaml index b17ce95..69aa77d 100644 --- a/werf.yaml +++ b/werf.yaml @@ -4,10 +4,10 @@ project: "backend" image: builder # Build image name. from: golang:1.19 # Base image. docker: - WORKDIR: /go/src/gitlab.com/rarimo/rarimoid/verify-proxy + WORKDIR: /go/src/github.com/rarimo/verify-proxy git: # Section with directives for adding source files from a git repository. - add: / # The source path in the repository. - to: /go/src/gitlab.com/rarimo/rarimoid/verify-proxy # The destination path in the image. + to: /go/src/github.com/rarimo/verify-proxy # The destination path in the image. stageDependencies: # Configuring rebuild triggers when specific files in the repository change. install: - go.mod @@ -16,8 +16,8 @@ git: # Section with directives for adding source files from a git repository. - "**/*" shell: # Shell build instructions. setup: # For the Setup stage. - - cd /go/src/gitlab.com/rarimo/rarimoid/verify-proxy - - go build -o /usr/local/bin/verify-proxy /go/src/gitlab.com/rarimo/rarimoid/verify-proxy + - cd /go/src/github.com/rarimo/verify-proxy + - go build -o /usr/local/bin/verify-proxy /go/src/github.com/rarimo/verify-proxy --- image: service # The name of the built image.