diff --git a/.github/workflows/e2e-tests.yaml b/.github/workflows/e2e-tests.yaml deleted file mode 100644 index 24145b8..0000000 --- a/.github/workflows/e2e-tests.yaml +++ /dev/null @@ -1,46 +0,0 @@ -name: e2e hardhat tests - -on: - push: - branches: - - master - - develop - pull_request: - workflow_dispatch: - -jobs: - run_e2e: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v3 - - - name: Build docker container - uses: docker/build-push-action@v5 - with: - context: . - file: build/Dockerfile - load: true - tags: onchain-merklized-issuer-demo:latest - cache-from: type=gha - cache-to: type=gha - - - name: Run container - run: | - docker run -d -p 8080:8080 \ - --name onchain-merklized-issuer-demo onchain-merklized-issuer-demo:latest - - - name: Run Newman - run: | - newman run tests/e2e/e2e.postman_collection.json diff --git a/.github/workflows/publish-backend-erc.yaml b/.github/workflows/publish-backend-erc.yaml new file mode 100644 index 0000000..eca660e --- /dev/null +++ b/.github/workflows/publish-backend-erc.yaml @@ -0,0 +1,58 @@ +name: Deploy onchain merklized backend to AWS ECR + +on: + workflow_dispatch: + push: + branches: + - master + +env: + AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID_PRIVADO_ID }} + AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION_PRIVADO_ID }} + ECR_REPOSITORY: onchain_merklized_issuer_backend_demo + +jobs: + deploy: + environment: + name: ${{ github.ref_name }} + name: Build and deploy ochain merklized issuer backend to AWS ECR + runs-on: ubuntu-latest + permissions: + id-token: write + contents: write + steps: + - name: Checkout + uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 16 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-region: ${{ env.AWS_DEFAULT_REGION }} + role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/PolygonIDActionsRole + role-session-name: GitHubActionsSession + + - name: Login to Amazon ECR + uses: aws-actions/amazon-ecr-login@v2 + id: login-ecr + + - name: Get version + run: echo "::set-output name=VERSION::$(git rev-parse --short HEAD)" + id: version + + - name: Build with tag and push image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: ${{ env.ECR_REPOSITORY }} + IMAGE_TAG: ${{ steps.version.outputs.VERSION }} + run: | + docker build \ + -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest \ + -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} \ + -f client/Dockerfile client + + docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} + docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest diff --git a/.github/workflows/publish-frontend-erc.yaml b/.github/workflows/publish-frontend-erc.yaml new file mode 100644 index 0000000..c1c2a18 --- /dev/null +++ b/.github/workflows/publish-frontend-erc.yaml @@ -0,0 +1,59 @@ +name: Deploy onchain merklized frontend to AWS ECR + +on: + workflow_dispatch: + push: + branches: + - master + +env: + AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID_PRIVADO_ID }} + AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION_PRIVADO_ID }} + ECR_REPOSITORY: onchain_merklized_issuer_frontend_demo + +jobs: + deploy: + environment: + name: ${{ github.ref_name }} + name: Build and deploy ochain merklized issuer frontend to AWS ECR + runs-on: ubuntu-latest + permissions: + id-token: write + contents: write + steps: + - name: Checkout + uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 16 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-region: ${{ env.AWS_DEFAULT_REGION }} + role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/PolygonIDActionsRole + role-session-name: GitHubActionsSession + + - name: Login to Amazon ECR + uses: aws-actions/amazon-ecr-login@v2 + id: login-ecr + + - name: Get version + run: echo "::set-output name=VERSION::$(git rev-parse --short HEAD)" + id: version + + - name: Build with tag and push image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: ${{ env.ECR_REPOSITORY }} + IMAGE_TAG: ${{ steps.version.outputs.VERSION }} + run: | + docker build \ + -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest \ + -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} \ + --build-arg="NEXT_PUBLIC_ISSUER_URL={{ env.NEXT_PUBLIC_ISSUER_URL }}" \ + -f client/Dockerfile client + + docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} + docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml deleted file mode 100644 index 74a7687..0000000 --- a/.github/workflows/publish.yaml +++ /dev/null @@ -1,42 +0,0 @@ -name: Publish -on: - workflow_dispatch: - -jobs: - publish_onchain-merklized-issuer-demo: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v3 - - - name: Determine tag - id: tag - run: | - ref=$(echo ${{ github.ref }} | cut -d'/' -f3) - echo "Original ref: $ref" - if [[ "$ref" == "master" ]]; then - echo "::set-output name=tag::latest" - elif [[ "$ref" == "develop" ]]; then - echo "::set-output name=tag::develop" - else - echo "::set-output name=tag::$ref" - fi - - - name: Build and Deploy to ghcr.io - run: | - tag=${{ steps.tag.outputs.tag }} - echo "Using tag: $tag" - docker buildx build -f build/Dockerfile --push \ - --platform linux/amd64,linux/arm64 \ - -t ghcr.io/${{ github.repository }}:${tag} . diff --git a/main.go b/main.go index 844aa60..3500224 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( "reflect" "strconv" "strings" + "time" "github.com/ethereum/go-ethereum/ethclient" auth "github.com/iden3/go-iden3-auth/v2" @@ -69,10 +70,12 @@ func main() { logger.WithError(err).Fatal("error creating package manager") } + //nolint:govet //resource leak is handled by shutdown manager + mongoConnectTimeout, _ := context.WithTimeout(context.Background(), time.Second*20) reg := bson.NewRegistry() reg.RegisterTypeMapEntry(bson.TypeEmbeddedDocument, reflect.TypeOf(bson.M{})) opts := options.Client().ApplyURI(cfg.MongoDBConnectionString).SetRegistry(reg) - mongoClient, err := mongo.Connect(context.Background(), opts) + mongoClient, err := mongo.Connect(mongoConnectTimeout, opts) if err != nil { logger.WithError(err).Fatal("error connecting to mongodb") } diff --git a/tests/e2e/README.md b/tests/e2e/README.md deleted file mode 100644 index 3dfad28..0000000 --- a/tests/e2e/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# E2E test -Use postman collections and newman to run e2e tests. \ No newline at end of file diff --git a/tests/e2e/e2e.postman_collection.json b/tests/e2e/e2e.postman_collection.json deleted file mode 100644 index 7d25be9..0000000 --- a/tests/e2e/e2e.postman_collection.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "info": { - "_postman_id": "ce04e736-5653-4bbe-8b92-c4d3b221ff5c", - "name": "Golang template", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" - }, - "item": [ - { - "name": "Readiness", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "http://localhost:8080/readiness", - "protocol": "http", - "host": [ - "localhost" - ], - "port": "8080", - "path": [ - "readiness" - ] - } - }, - "response": [] - }, - { - "name": "Liveness", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "http://localhost:8080/liveness", - "protocol": "http", - "host": [ - "localhost" - ], - "port": "8080", - "path": [ - "liveness" - ] - } - }, - "response": [] - } - ] -} \ No newline at end of file