From 69ee777fe04af54e86fe56015505a21783d9208c Mon Sep 17 00:00:00 2001 From: Ilya Date: Thu, 8 Aug 2024 19:39:01 +0200 Subject: [PATCH 1/5] add build and push pipeline for dev tag (#17) add build and push pipeline for dev tag --- .github/workflows/e2e.yaml | 2 + .github/workflows/publis-container-dev.yaml | 77 +++++++++ .github/workflows/push-container.yaml | 8 +- .../http_nameservice.postman_collection.json | 150 ++++++++++++++---- 4 files changed, 207 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/publis-container-dev.yaml diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 7ac73b2..4feb86b 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -58,6 +58,8 @@ jobs: newman run tests/e2e/http_nameservice.postman_collection.json \ -g ./tests/e2e/dev_env.json \ --global-var issuer_server=${{ secrets.ISSUER_URL }} \ + --global-var username=${{ secrets.ISSUER_NODE_USER }} \ + --global-var password=${{ secrets.ISSUER_NODE_PASSWROD }} \ --bail --verbose - name: Run state tests diff --git a/.github/workflows/publis-container-dev.yaml b/.github/workflows/publis-container-dev.yaml new file mode 100644 index 0000000..0e7bdac --- /dev/null +++ b/.github/workflows/publis-container-dev.yaml @@ -0,0 +1,77 @@ +name: Publish driver-did-iden3 to Privado AWS ECR +on: + push: + tags: + - 'v*.*.*-dev' + workflow_dispatch: + +env: + AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID_PRIVADO_ID }} + AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION_PRIVADO_ID }} + ECR_REPOSITORY: driver-did-iden3 + +jobs: + build_driver: + env: + STATE_CONTRACT_ADDRESS_MAIN: "0x624ce98D2d27b20b8f8d521723Df8fC4db71D79D" + STATE_CONTRACT_ADDRESS_AMOY: "0x1a4cC30f2aA0377b0c3bc9848766D90cb4404124" + STATE_CONTRACT_ADDRESS_PRIVADO_MAIN: "0x0DDd8701C91d8d1Ba35c9DbA98A45fe5bA8A877E" + STATE_CONTRACT_ADDRESS_PRIVADO_TEST: "0xE5BfD683F1Ca574B5be881b7DbbcFDCE9DDBAb90" + 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: Build file with supported networks + run: | + cd driver-did-iden3 + echo -e "polygon:" > resolvers.settings.yaml + echo -e " amoy:" >> resolvers.settings.yaml + echo -e " contractAddress: ${{ env.STATE_CONTRACT_ADDRESS_AMOY }}" >> resolvers.settings.yaml + echo -e " networkURL: ${{ secrets.POLYGON_AMOY_NODE_URL }}" >> resolvers.settings.yaml + echo -e " walletKey: ${{ secrets.SIGNER_PRIVATE_KEY }}" >> resolvers.settings.yaml + echo -e " main:" >> resolvers.settings.yaml + echo -e " contractAddress: ${{ env.STATE_CONTRACT_ADDRESS_MAIN }}" >> resolvers.settings.yaml + echo -e " networkURL: ${{ secrets.POLYGON_MAIN_NODE_URL }}" >> resolvers.settings.yaml + echo -e " walletKey: ${{ secrets.SIGNER_PRIVATE_KEY }}" >> resolvers.settings.yaml + echo -e "privado:" >> resolvers.settings.yaml + echo -e " main:" >> resolvers.settings.yaml + echo -e " contractAddress: ${{ env.STATE_CONTRACT_ADDRESS_PRIVADO_MAIN }}" >> resolvers.settings.yaml + echo -e " networkURL: ${{ secrets.PRIVADO_MAIN_NODE_URL }}" >> resolvers.settings.yaml + echo -e " walletKey: ${{ secrets.SIGNER_PRIVATE_KEY }}" >> resolvers.settings.yaml + echo -e " test:" >> resolvers.settings.yaml + echo -e " contractAddress: ${{ env.STATE_CONTRACT_ADDRESS_PRIVADO_TEST }}" >> resolvers.settings.yaml + echo -e " networkURL: ${{ secrets.PRIVADO_TEST_NODE_URL }}" >> resolvers.settings.yaml + echo -e " walletKey: ${{ secrets.SIGNER_PRIVATE_KEY }}" >> resolvers.settings.yaml + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + + - name: build and deploy to DockerHub + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: ${{ env.ECR_REPOSITORY }} + run: | + cd driver-did-iden3 && \ + docker buildx build --push \ + --platform linux/amd64,linux/arm64 \ + -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ github.ref_name }} \ diff --git a/.github/workflows/push-container.yaml b/.github/workflows/push-container.yaml index 826254f..5d9e524 100644 --- a/.github/workflows/push-container.yaml +++ b/.github/workflows/push-container.yaml @@ -1,7 +1,11 @@ +# This workflow builds a docker image and pushes it to GitHub Container Registry +# We need to have this image in public registry for compatibility with universal resolver name: Publish driver-did-iden3 on: - release: - types: [published] + push: + tags: + - '!v*.*.*-dev' + - 'v*' workflow_dispatch: jobs: diff --git a/tests/e2e/http_nameservice.postman_collection.json b/tests/e2e/http_nameservice.postman_collection.json index b0e9d67..796cf00 100644 --- a/tests/e2e/http_nameservice.postman_collection.json +++ b/tests/e2e/http_nameservice.postman_collection.json @@ -1,8 +1,9 @@ { "info": { - "_postman_id": "301f6d89-ec5b-42a4-b00f-d3005d9988e6", + "_postman_id": "aefc13c9-2239-409c-ba32-b0c10b4ad7c9", "name": "Nameservice e2e Iden3", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "37022085" }, "item": [ { @@ -12,11 +13,11 @@ "listen": "test", "script": { "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 201\", function () {", + " pm.response.to.have.status(201);", "});", "pm.test(\"Content-Type header is application/json\", () => {", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json; charset=utf-8');", + " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');", "});", "", "pm.test(\"Identifier is not empty\", () => {", @@ -27,16 +28,32 @@ "pm.collectionVariables.set(\"issuer_identity\", pm.response.json().identifier);", "pm.collectionVariables.set(\"issuer_genesis_state\", pm.response.json().state.state)" ], - "type": "text/javascript" + "type": "text/javascript", + "packages": {} } } ], "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "{{password}}", + "type": "string" + }, + { + "key": "username", + "value": "{{username}}", + "type": "string" + } + ] + }, "method": "POST", "header": [], "body": { "mode": "raw", - "raw": "{\n \"did_metadata\":{\n \"method\": \"iden3\",\n \"blockchain\":\"polygon\",\n \"network\": \"amoy\",\n \"type\": \"BJJ\"\n }\n}", + "raw": "{\n \"didMetadata\": {\n \"method\": \"polygonid\",\n \"blockchain\": \"polygon\",\n \"network\": \"amoy\",\n \"type\": \"BJJ\"\n }\n}", "options": { "raw": { "language": "json" @@ -44,12 +61,11 @@ } }, "url": { - "raw": "{{issuer_server}}/api/v1/identities", + "raw": "{{issuer_server}}/v1/identities", "host": [ "{{issuer_server}}" ], "path": [ - "api", "v1", "identities" ] @@ -64,11 +80,11 @@ "listen": "test", "script": { "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 201\", function () {", + " pm.response.to.have.status(201);", "});", "pm.test(\"Content-Type header is application/json\", () => {", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json; charset=utf-8');", + " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');", "});", "", "pm.test(\"Identifier is not empty\", () => {", @@ -78,16 +94,32 @@ "", "pm.collectionVariables.set(\"user_identity\", pm.response.json().identifier);" ], - "type": "text/javascript" + "type": "text/javascript", + "packages": {} } } ], "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "{{password}}", + "type": "string" + }, + { + "key": "username", + "value": "{{username}}", + "type": "string" + } + ] + }, "method": "POST", "header": [], "body": { "mode": "raw", - "raw": "{\n \"did_metadata\":{\n \"method\": \"iden3\",\n \"blockchain\":\"polygon\",\n \"network\": \"amoy\",\n \"type\": \"BJJ\"\n }\n}", + "raw": "{\n \"didMetadata\": {\n \"method\": \"polygonid\",\n \"blockchain\": \"polygon\",\n \"network\": \"amoy\",\n \"type\": \"BJJ\"\n }\n}", "options": { "raw": { "language": "json" @@ -95,12 +127,11 @@ } }, "url": { - "raw": "{{issuer_server}}/api/v1/identities", + "raw": "{{issuer_server}}/v1/identities", "host": [ "{{issuer_server}}" ], "path": [ - "api", "v1", "identities" ] @@ -312,21 +343,37 @@ "listen": "test", "script": { "exec": [ - "pm.test(\"Status code is 202\", function () {", - " pm.response.to.have.status(202);", + "pm.test(\"Status code is 201\", function () {", + " pm.response.to.have.status(201);", "});", "pm.test(\"Content-Type header is application/json\", () => {", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json; charset=utf-8');", + " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');", "});", "", "pm.collectionVariables.set(\"age_claim_non_merklized_id\", pm.response.json().id);", "" ], - "type": "text/javascript" + "type": "text/javascript", + "packages": {} } } ], "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "{{password}}", + "type": "string" + }, + { + "key": "username", + "value": "{{username}}", + "type": "string" + } + ] + }, "method": "POST", "header": [], "body": { @@ -339,14 +386,12 @@ } }, "url": { - "raw": "{{issuer_server}}/api/v1/identities/{{issuer_identity}}/claims", + "raw": "{{issuer_server}}/v1/{{issuer_identity}}/claims", "host": [ "{{issuer_server}}" ], "path": [ - "api", "v1", - "identities", "{{issuer_identity}}", "claims" ] @@ -354,6 +399,41 @@ }, "response": [] }, + { + "name": "Publish issuer state", + "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "{{password}}", + "type": "string" + }, + { + "key": "username", + "value": "{{username}}", + "type": "string" + } + ] + }, + "method": "POST", + "header": [], + "url": { + "raw": "{{issuer_server}}/v1/{{issuer_identity}}/state/publish", + "host": [ + "{{issuer_server}}" + ], + "path": [ + "v1", + "{{issuer_identity}}", + "state", + "publish" + ] + } + }, + "response": [] + }, { "name": "KYCAgeCredential(Non merklized) wait for MTP", "event": [ @@ -369,7 +449,7 @@ " pm.response.to.have.status(200);", "});", "pm.test(\"Content-Type header is application/json\", () => {", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json; charset=utf-8');", + " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');", "});", "", "pm.test(\"Proof section is NOT empty\", function () {", @@ -392,7 +472,8 @@ " postman.setNextRequest(pm.info.requestId); // retry the current request", "}" ], - "type": "text/javascript" + "type": "text/javascript", + "packages": {} } } ], @@ -400,6 +481,21 @@ "disableBodyPruning": true }, "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "{{password}}", + "type": "string" + }, + { + "key": "username", + "value": "{{username}}", + "type": "string" + } + ] + }, "method": "GET", "header": [], "body": { @@ -412,14 +508,12 @@ } }, "url": { - "raw": "{{issuer_server}}/api/v1/identities/{{issuer_identity}}/claims/{{age_claim_non_merklized_id}}", + "raw": "{{issuer_server}}/v1/{{issuer_identity}}/claims/{{age_claim_non_merklized_id}}", "host": [ "{{issuer_server}}" ], "path": [ - "api", "v1", - "identities", "{{issuer_identity}}", "claims", "{{age_claim_non_merklized_id}}" From cc6b14856d27ac2890dada9df7d597f54b01691c Mon Sep 17 00:00:00 2001 From: Ilya Date: Thu, 8 Aug 2024 20:34:49 +0200 Subject: [PATCH 2/5] fix build (#18) --- .github/workflows/publis-container-dev.yaml | 1 - .github/workflows/push-container.yaml | 3 --- 2 files changed, 4 deletions(-) diff --git a/.github/workflows/publis-container-dev.yaml b/.github/workflows/publis-container-dev.yaml index 0e7bdac..81cb2d5 100644 --- a/.github/workflows/publis-container-dev.yaml +++ b/.github/workflows/publis-container-dev.yaml @@ -71,7 +71,6 @@ jobs: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} ECR_REPOSITORY: ${{ env.ECR_REPOSITORY }} run: | - cd driver-did-iden3 && \ docker buildx build --push \ --platform linux/amd64,linux/arm64 \ -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ github.ref_name }} \ diff --git a/.github/workflows/push-container.yaml b/.github/workflows/push-container.yaml index 5d9e524..fadaced 100644 --- a/.github/workflows/push-container.yaml +++ b/.github/workflows/push-container.yaml @@ -18,8 +18,6 @@ jobs: steps: - name: Checkout driver-did-iden3 uses: actions/checkout@v3 - with: - path: driver-did-iden3 - name: Login to GitHub Container Registry uses: docker/login-action@v1 @@ -52,7 +50,6 @@ jobs: - name: build and deploy to DockerHub run: | - cd driver-did-iden3 && \ docker buildx build --push \ --platform linux/amd64,linux/arm64 \ -t ghcr.io/iden3/driver-did-iden3:${{ github.ref_name }} \ From 994d355d4ff5bdfc6a96bfd0245c3e9d18aa23cb Mon Sep 17 00:00:00 2001 From: ilya-korotya Date: Thu, 8 Aug 2024 20:43:56 +0200 Subject: [PATCH 3/5] build image in dir --- .github/workflows/publis-container-dev.yaml | 3 +++ .github/workflows/push-container.yaml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/publis-container-dev.yaml b/.github/workflows/publis-container-dev.yaml index 81cb2d5..6186f4a 100644 --- a/.github/workflows/publis-container-dev.yaml +++ b/.github/workflows/publis-container-dev.yaml @@ -24,6 +24,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + path: driver-did-iden3 - uses: actions/setup-node@v4 with: @@ -71,6 +73,7 @@ jobs: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} ECR_REPOSITORY: ${{ env.ECR_REPOSITORY }} run: | + cd driver-did-iden3 && \ docker buildx build --push \ --platform linux/amd64,linux/arm64 \ -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ github.ref_name }} \ diff --git a/.github/workflows/push-container.yaml b/.github/workflows/push-container.yaml index fadaced..5d9e524 100644 --- a/.github/workflows/push-container.yaml +++ b/.github/workflows/push-container.yaml @@ -18,6 +18,8 @@ jobs: steps: - name: Checkout driver-did-iden3 uses: actions/checkout@v3 + with: + path: driver-did-iden3 - name: Login to GitHub Container Registry uses: docker/login-action@v1 @@ -50,6 +52,7 @@ jobs: - name: build and deploy to DockerHub run: | + cd driver-did-iden3 && \ docker buildx build --push \ --platform linux/amd64,linux/arm64 \ -t ghcr.io/iden3/driver-did-iden3:${{ github.ref_name }} \ From 25055d15e48275ef733f80faeb578d0e578a52c4 Mon Sep 17 00:00:00 2001 From: ilya-korotya Date: Thu, 8 Aug 2024 20:47:37 +0200 Subject: [PATCH 4/5] fix docker command --- .github/workflows/publis-container-dev.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publis-container-dev.yaml b/.github/workflows/publis-container-dev.yaml index 6186f4a..fb707fe 100644 --- a/.github/workflows/publis-container-dev.yaml +++ b/.github/workflows/publis-container-dev.yaml @@ -76,4 +76,4 @@ jobs: cd driver-did-iden3 && \ docker buildx build --push \ --platform linux/amd64,linux/arm64 \ - -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ github.ref_name }} \ + -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ github.ref_name }} . From 6a3655eebcd6debfbd79bd662446b2a261e869a8 Mon Sep 17 00:00:00 2001 From: ilya-korotya Date: Mon, 12 Aug 2024 17:18:51 +0200 Subject: [PATCH 5/5] add envs variables --- .github/workflows/publis-container-dev.yaml | 12 ++++++------ .github/workflows/push-container.yaml | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/publis-container-dev.yaml b/.github/workflows/publis-container-dev.yaml index fb707fe..ae8ace3 100644 --- a/.github/workflows/publis-container-dev.yaml +++ b/.github/workflows/publis-container-dev.yaml @@ -13,10 +13,10 @@ env: jobs: build_driver: env: - STATE_CONTRACT_ADDRESS_MAIN: "0x624ce98D2d27b20b8f8d521723Df8fC4db71D79D" - STATE_CONTRACT_ADDRESS_AMOY: "0x1a4cC30f2aA0377b0c3bc9848766D90cb4404124" - STATE_CONTRACT_ADDRESS_PRIVADO_MAIN: "0x0DDd8701C91d8d1Ba35c9DbA98A45fe5bA8A877E" - STATE_CONTRACT_ADDRESS_PRIVADO_TEST: "0xE5BfD683F1Ca574B5be881b7DbbcFDCE9DDBAb90" + STATE_CONTRACT_ADDRESS_POLYGON_MAIN: "0x624ce98D2d27b20b8f8d521723Df8fC4db71D79D" + STATE_CONTRACT_ADDRESS_POLYGON_AMOY: "0x1a4cC30f2aA0377b0c3bc9848766D90cb4404124" + STATE_CONTRACT_ADDRESS_PRIVADO_MAIN: "0x975556428F077dB5877Ea2474D783D6C69233742" + STATE_CONTRACT_ADDRESS_PRIVADO_TEST: "0x975556428F077dB5877Ea2474D783D6C69233742" runs-on: ubuntu-latest permissions: id-token: write @@ -47,11 +47,11 @@ jobs: cd driver-did-iden3 echo -e "polygon:" > resolvers.settings.yaml echo -e " amoy:" >> resolvers.settings.yaml - echo -e " contractAddress: ${{ env.STATE_CONTRACT_ADDRESS_AMOY }}" >> resolvers.settings.yaml + echo -e " contractAddress: ${{ env.STATE_CONTRACT_ADDRESS_POLYGON_AMOY }}" >> resolvers.settings.yaml echo -e " networkURL: ${{ secrets.POLYGON_AMOY_NODE_URL }}" >> resolvers.settings.yaml echo -e " walletKey: ${{ secrets.SIGNER_PRIVATE_KEY }}" >> resolvers.settings.yaml echo -e " main:" >> resolvers.settings.yaml - echo -e " contractAddress: ${{ env.STATE_CONTRACT_ADDRESS_MAIN }}" >> resolvers.settings.yaml + echo -e " contractAddress: ${{ env.STATE_CONTRACT_ADDRESS_POLYGON_MAIN }}" >> resolvers.settings.yaml echo -e " networkURL: ${{ secrets.POLYGON_MAIN_NODE_URL }}" >> resolvers.settings.yaml echo -e " walletKey: ${{ secrets.SIGNER_PRIVATE_KEY }}" >> resolvers.settings.yaml echo -e "privado:" >> resolvers.settings.yaml diff --git a/.github/workflows/push-container.yaml b/.github/workflows/push-container.yaml index 5d9e524..3c2e55f 100644 --- a/.github/workflows/push-container.yaml +++ b/.github/workflows/push-container.yaml @@ -11,8 +11,8 @@ on: jobs: build_driver: env: - STATE_CONTRACT_ADDRESS_MAIN: "0x624ce98D2d27b20b8f8d521723Df8fC4db71D79D" - STATE_CONTRACT_ADDRESS_AMOY: "0x1a4cC30f2aA0377b0c3bc9848766D90cb4404124" + STATE_CONTRACT_ADDRESS_POLYGON_MAIN: "0x624ce98D2d27b20b8f8d521723Df8fC4db71D79D" + STATE_CONTRACT_ADDRESS_POLYGON_AMOY: "0x1a4cC30f2aA0377b0c3bc9848766D90cb4404124" STATE_CONTRACT_ADDRESS_PRIVADO: "0x975556428F077dB5877Ea2474D783D6C69233742" runs-on: ubuntu-latest steps: @@ -33,10 +33,10 @@ jobs: cd driver-did-iden3 echo -e "polygon:" > resolvers.settings.yaml echo -e " amoy:" >> resolvers.settings.yaml - echo -e " contractAddress: ${{ env.STATE_CONTRACT_ADDRESS_AMOY }}" >> resolvers.settings.yaml + echo -e " contractAddress: ${{ env.STATE_CONTRACT_ADDRESS_POLYGON_AMOY }}" >> resolvers.settings.yaml echo -e " networkURL: ${{ secrets.POLYGON_AMOY_NODE_URL }}" >> resolvers.settings.yaml echo -e " main:" >> resolvers.settings.yaml - echo -e " contractAddress: ${{ env.STATE_CONTRACT_ADDRESS_MAIN }}" >> resolvers.settings.yaml + echo -e " contractAddress: ${{ env.STATE_CONTRACT_ADDRESS_POLYGON_MAIN }}" >> resolvers.settings.yaml echo -e " networkURL: ${{ secrets.POLYGON_MAIN_NODE_URL }}" >> resolvers.settings.yaml echo -e "privado:" >> resolvers.settings.yaml echo -e " main:" >> resolvers.settings.yaml