From 301d43c7e8cfe4ab6d0c4e63931eb9b319f574e9 Mon Sep 17 00:00:00 2001 From: Adam Guderski Date: Fri, 9 Feb 2024 09:12:26 +0100 Subject: [PATCH 01/20] add CSP headers to govtool frontend service --- scripts/govtool/docker-compose.sanchonet.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/govtool/docker-compose.sanchonet.yml b/scripts/govtool/docker-compose.sanchonet.yml index b7f4a4054..88304aaf5 100644 --- a/scripts/govtool/docker-compose.sanchonet.yml +++ b/scripts/govtool/docker-compose.sanchonet.yml @@ -207,6 +207,8 @@ services: - "traefik.http.routers.vva-fe.rule=Host(`${DOMAIN:-$ENVIRONMENT-$CARDANO_NETWORK.govtool.byron.network}`)" - "traefik.http.routers.vva-fe.entrypoints=websecure" - "traefik.http.routers.vva-fe.tls.certresolver=myresolver" + - "traefik.http.middlewares.vva-fe-csp.headers.contentSecurityPolicy=default-src 'self'; img-src *.usersnap.com 'self' data:; script-src *.usersnap.com 'self' 'unsafe-inline' https://www.googletagmanager.com https://browser.sentry-cdn.com; style-src *.usersnap.com *.googleapis.com 'self' 'unsafe-inline' https://fonts.googleapis.com; connect-src *.usersnap.com https://s3.eu-central-1.amazonaws.com/upload.usersnap.com 'self' https://o4506155985141760.ingest.sentry.io/api/4506156032196608/envelope/ *.google-analytics.com; font-src *.usersnap.com *.gstatic.com 'self' 'unsafe-inline' https://fonts.gstatic.com; worker-src blob:" + - "traefik.http.routers.vva-fe.middlewares=vva-fe-csp@docker" - "traefik.http.services.vva-fe.loadbalancer.server.port=80" secrets: From 4ec99aa0f16c8814a1edbd3885c1c1bc41a13b2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Placzy=C5=84ski?= Date: Tue, 13 Feb 2024 13:15:42 +0100 Subject: [PATCH 02/20] Merge pull request #157 from IntersectMBO/chore/97-rebrand-application-in-infrastructure-configuration [#97] Rebrand the application in infrastructure configuration --- ...vva-be-config.json => backend-config.json} | 2 +- .github/workflows/build-and-deploy.yml | 8 ++-- .github/workflows/frontend_sonar_scan.yml | 4 +- .github/workflows/lighthouse.yml | 7 ++- .github/workflows/test_backend.yml | 10 ++-- .../workflows/test_integration_cypress.yml | 9 ++-- README.md | 6 +-- docs/operations/DEPLOY.md | 4 +- govtool/backend/README.md | 8 ++-- govtool/frontend/README.md | 24 +++++----- infra/terraform/.env.example | 5 ++ infra/terraform/main.tf | 48 +++++++++---------- infra/terraform/modules/ecr/variables.tf | 2 +- .../modules/{vva-ec2 => govtool-ec2}/main.tf | 8 ++-- .../terraform/modules/govtool-ec2/outputs.tf | 7 +++ .../{vva-ec2 => govtool-ec2}/user_data.sh | 0 .../{vva-ec2 => govtool-ec2}/variables.tf | 2 +- .../vva_to_govtool_migration_20240212.tf | 15 ++++++ infra/terraform/modules/vva-ec2/outputs.tf | 7 --- infra/terraform/shell.nix | 4 ++ .../vva_to_govtool_migration_20240212.tf | 35 ++++++++++++++ scripts/govtool/.env.example | 26 +++++++--- scripts/govtool/Makefile | 38 +++++++++++---- .../alerting/alerting.yml | 2 +- .../dashboards/{vva.json => govtool.json} | 10 ++-- ...vva-be-config.json => backend-config.json} | 2 +- ...onfig.json.tpl => backend-config.json.tpl} | 0 scripts/govtool/docker-compose.sanchonet.yml | 44 ++++++++--------- scripts/govtool/docker-compose.yml | 36 +++++++------- scripts/govtool/prepare-config.sh | 6 +-- .../{vva-be => govtool-backend}/.env.example | 0 tests/{vva-be => govtool-backend}/.gitignore | 0 tests/{vva-be => govtool-backend}/README.md | 6 +-- tests/{vva-be => govtool-backend}/config.py | 0 .../models/TestData.py | 0 .../models/TestResult.py | 0 .../models/__init__.py | 0 .../requirements.txt | 0 tests/{vva-be => govtool-backend}/setup.py | 0 .../test_cases/__init__.py | 0 .../test_cases/conftest.py | 10 ++-- .../test_cases/fixtures/ada_holder.py | 4 +- .../test_cases/fixtures/drep.py | 0 .../test_cases/govtool_api.py} | 2 +- .../test_cases/test_ada_holder.py | 14 ++++++ .../test_cases/test_drep.py | 14 +++--- .../test_cases/test_proposal.py | 4 +- .../test_data.json | 0 .../{vva-be => govtool-backend}/test_data.py | 0 tests/{vva-fe => govtool-frontend}/.gitignore | 0 tests/{vva-fe => govtool-frontend}/README.md | 4 +- .../currents.config.js | 4 +- .../cypress.config.ts | 6 +-- .../cypress/constants/governanceActions.ts | 0 .../cypress/constants/wallet.ts | 0 .../cypress/e2e/0_bootstrap.cy.ts | 0 .../e2e/1_user_story_wallet_connect.cy.ts | 0 .../e2e/2_user_story_delegate_to_drep.cy.ts | 0 .../e2e/3_user_story_drep_registration.cy.ts | 0 ...r_story_governance_action_visibility.cy.ts | 0 ...tory_governance_action_functionality.cy.ts | 0 .../e2e/6_user_story_miscellaneous.cy.ts | 0 .../cypress/e2e/actions/cleanUpActions.ts | 0 .../cypress/e2e/actions/commonActions.ts | 0 .../cypress/e2e/actions/dRepActions.ts | 0 .../cypress/e2e/actions/delegateActions.ts | 0 .../cypress/e2e/actions/governanceActions.ts | 0 .../7.1_security_overflow_data_headers.cy.ts | 0 .../e2e/security/7.3_security_xss.cy.ts | 0 .../e2e/security/7.4_sql_injection.cy.ts | 0 .../cypress/lib/logger/logger.ts | 0 .../cypress/lib/wallet/blockfrost.ts | 0 .../cypress/lib/wallet/cardanoWallet.ts | 0 .../cypress/lib/wallet/crypto.ts | 0 .../cypress/lib/wallet/mockWallet.ts | 0 .../cypress/lib/wallet/setupWallet.ts | 0 .../cypress/lib/wallet/types.ts | 0 .../cypress/models/types.ts | 0 .../cypress/services/apiService.ts | 0 .../cypress/services/blockfrostService.ts | 0 .../cypress/services/faucetService.ts | 0 .../cypress/services/kuberService.ts | 0 .../cypress/services/types.ts | 0 .../cypress/state/store.ts | 0 .../cypress/state/type.ts | 0 .../cypress/state/walletState.ts | 0 .../cypress/support/command.d.ts | 0 .../cypress/support/commands.ts | 0 .../cypress/support/e2e.ts | 0 .../cypress/support/utils.ts | 0 .../cypress/support/validations.ts | 0 .../{vva-fe => govtool-frontend}/package.json | 2 +- .../tsconfig.json | 0 tests/{vva-fe => govtool-frontend}/yarn.lock | 0 tests/load-testing/pom.xml | 6 +-- .../cardano/{vva => govtool}/ApiService.java | 2 +- .../org/cardano/{vva => govtool}/Engine.java | 2 +- .../{vva => govtool}/IDEPathHelper.java | 4 +- .../cardano/{vva => govtool}/Recorder.java | 2 +- .../cardano/{vva => govtool}/Scenario.java | 10 ++-- .../org/cardano/{vva => govtool}/Test.java | 2 +- .../org/cardano/{vva => govtool}/Utils.java | 2 +- .../{vva => govtool}/actions/Action.java | 4 +- .../actions/AdaHolderAction.java | 8 ++-- .../actions/AuthenticationAction.java | 6 +-- .../{vva => govtool}/actions/DRepAction.java | 6 +-- .../configs/HeaderConfig.java | 2 +- .../feeders/RandomDataFeeder.java | 4 +- .../simulations/VvaSimulation.java | 4 +- .../src/test/resources/gatling.conf | 2 +- .../src/test/resources/recorder.conf | 8 ++-- tests/test-infrastructure/.env.example | 4 +- tests/test-infrastructure/README.md | 12 ++--- tests/test-infrastructure/deploy-swarm.sh | 2 +- .../docker-compose-services.yml | 6 +-- tests/test-infrastructure/docker-compose.yml | 26 +++++----- tests/test-infrastructure/gen-configs.sh | 12 ++--- tests/test-metrics-api/.env.example | 2 +- tests/test-metrics-api/README.md | 2 +- tests/vva-be/test_cases/test_ada_holder.py | 14 ------ 120 files changed, 349 insertions(+), 254 deletions(-) rename .github/{vva-be-config.json => backend-config.json} (92%) create mode 100644 infra/terraform/.env.example rename infra/terraform/modules/{vva-ec2 => govtool-ec2}/main.tf (96%) create mode 100644 infra/terraform/modules/govtool-ec2/outputs.tf rename infra/terraform/modules/{vva-ec2 => govtool-ec2}/user_data.sh (100%) rename infra/terraform/modules/{vva-ec2 => govtool-ec2}/variables.tf (94%) create mode 100644 infra/terraform/modules/govtool-ec2/vva_to_govtool_migration_20240212.tf delete mode 100644 infra/terraform/modules/vva-ec2/outputs.tf create mode 100644 infra/terraform/shell.nix create mode 100644 infra/terraform/vva_to_govtool_migration_20240212.tf rename scripts/govtool/config/grafana-provisioning/dashboards/{vva.json => govtool.json} (98%) rename scripts/govtool/config/secrets/{vva-be-config.json => backend-config.json} (92%) rename scripts/govtool/config/secrets/{vva-be-config.json.tpl => backend-config.json.tpl} (100%) rename tests/{vva-be => govtool-backend}/.env.example (100%) rename tests/{vva-be => govtool-backend}/.gitignore (100%) rename tests/{vva-be => govtool-backend}/README.md (86%) rename tests/{vva-be => govtool-backend}/config.py (100%) rename tests/{vva-be => govtool-backend}/models/TestData.py (100%) rename tests/{vva-be => govtool-backend}/models/TestResult.py (100%) rename tests/{vva-be => govtool-backend}/models/__init__.py (100%) rename tests/{vva-be => govtool-backend}/requirements.txt (100%) rename tests/{vva-be => govtool-backend}/setup.py (100%) rename tests/{vva-be => govtool-backend}/test_cases/__init__.py (100%) rename tests/{vva-be => govtool-backend}/test_cases/conftest.py (93%) rename tests/{vva-be => govtool-backend}/test_cases/fixtures/ada_holder.py (80%) rename tests/{vva-be => govtool-backend}/test_cases/fixtures/drep.py (100%) rename tests/{vva-be/test_cases/vva_api.py => govtool-backend/test_cases/govtool_api.py} (99%) create mode 100644 tests/govtool-backend/test_cases/test_ada_holder.py rename tests/{vva-be => govtool-backend}/test_cases/test_drep.py (81%) rename tests/{vva-be => govtool-backend}/test_cases/test_proposal.py (89%) rename tests/{vva-be => govtool-backend}/test_data.json (100%) rename tests/{vva-be => govtool-backend}/test_data.py (100%) rename tests/{vva-fe => govtool-frontend}/.gitignore (100%) rename tests/{vva-fe => govtool-frontend}/README.md (78%) rename tests/{vva-fe => govtool-frontend}/currents.config.js (84%) rename tests/{vva-fe => govtool-frontend}/cypress.config.ts (89%) rename tests/{vva-fe => govtool-frontend}/cypress/constants/governanceActions.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/constants/wallet.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/e2e/0_bootstrap.cy.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/e2e/1_user_story_wallet_connect.cy.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/e2e/2_user_story_delegate_to_drep.cy.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/e2e/3_user_story_drep_registration.cy.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/e2e/4_user_story_governance_action_visibility.cy.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/e2e/5_user_story_governance_action_functionality.cy.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/e2e/6_user_story_miscellaneous.cy.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/e2e/actions/cleanUpActions.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/e2e/actions/commonActions.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/e2e/actions/dRepActions.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/e2e/actions/delegateActions.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/e2e/actions/governanceActions.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/e2e/security/7.1_security_overflow_data_headers.cy.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/e2e/security/7.3_security_xss.cy.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/e2e/security/7.4_sql_injection.cy.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/lib/logger/logger.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/lib/wallet/blockfrost.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/lib/wallet/cardanoWallet.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/lib/wallet/crypto.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/lib/wallet/mockWallet.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/lib/wallet/setupWallet.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/lib/wallet/types.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/models/types.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/services/apiService.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/services/blockfrostService.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/services/faucetService.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/services/kuberService.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/services/types.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/state/store.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/state/type.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/state/walletState.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/support/command.d.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/support/commands.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/support/e2e.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/support/utils.ts (100%) rename tests/{vva-fe => govtool-frontend}/cypress/support/validations.ts (100%) rename tests/{vva-fe => govtool-frontend}/package.json (95%) rename tests/{vva-fe => govtool-frontend}/tsconfig.json (100%) rename tests/{vva-fe => govtool-frontend}/yarn.lock (100%) rename tests/load-testing/src/test/java/org/cardano/{vva => govtool}/ApiService.java (98%) rename tests/load-testing/src/test/java/org/cardano/{vva => govtool}/Engine.java (94%) rename tests/load-testing/src/test/java/org/cardano/{vva => govtool}/IDEPathHelper.java (95%) rename tests/load-testing/src/test/java/org/cardano/{vva => govtool}/Recorder.java (95%) rename tests/load-testing/src/test/java/org/cardano/{vva => govtool}/Scenario.java (88%) rename tests/load-testing/src/test/java/org/cardano/{vva => govtool}/Test.java (95%) rename tests/load-testing/src/test/java/org/cardano/{vva => govtool}/Utils.java (97%) rename tests/load-testing/src/test/java/org/cardano/{vva => govtool}/actions/Action.java (82%) rename tests/load-testing/src/test/java/org/cardano/{vva => govtool}/actions/AdaHolderAction.java (73%) rename tests/load-testing/src/test/java/org/cardano/{vva => govtool}/actions/AuthenticationAction.java (83%) rename tests/load-testing/src/test/java/org/cardano/{vva => govtool}/actions/DRepAction.java (91%) rename tests/load-testing/src/test/java/org/cardano/{vva => govtool}/configs/HeaderConfig.java (84%) rename tests/load-testing/src/test/java/org/cardano/{vva => govtool}/feeders/RandomDataFeeder.java (95%) rename tests/load-testing/src/test/java/org/cardano/{vva => govtool}/simulations/VvaSimulation.java (98%) delete mode 100644 tests/vva-be/test_cases/test_ada_holder.py diff --git a/.github/vva-be-config.json b/.github/backend-config.json similarity index 92% rename from .github/vva-be-config.json rename to .github/backend-config.json index 9b3329863..d2ffd89d9 100644 --- a/.github/vva-be-config.json +++ b/.github/backend-config.json @@ -8,7 +8,7 @@ }, "fakedbsyncconfig" : { "host" : "localhost", - "dbname" : "vva", + "dbname" : "govtool", "user" : "postgres", "password" : "MTnk8lsuMM41RgAh1y2WTAUdObsb", "port" : 5432 diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index d8bb9a60a..7fef12726 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -117,7 +117,7 @@ jobs: DBSYNC_POSTGRES_DB: "cexplorer" DBSYNC_POSTGRES_USER: "postgres" DBSYNC_POSTGRES_PASSWORD: "pSa8JCpQOACMUdGb" - FAKEDBSYNC_POSTGRES_DB: "vva" + FAKEDBSYNC_POSTGRES_DB: "govtool" FAKEDBSYNC_POSTGRES_USER: "test" FAKEDBSYNC_POSTGRES_PASSWORD: "test" GRAFANA_ADMIN_PASSWORD: ${{ secrets.GRAFANA_ADMIN_PASSWORD }} @@ -125,7 +125,7 @@ jobs: GRAFANA_SLACK_OAUTH_TOKEN: ${{ secrets.GRAFANA_SLACK_OAUTH_TOKEN }} NGINX_BASIC_AUTH: ${{ secrets.NGINX_BASIC_AUTH }} SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }} - TRAEFIK_LE_EMAIL: "admin+vva@binarapps.com" + TRAEFIK_LE_EMAIL: "admin+govtool@binarapps.com" steps: - name: Checkout code uses: actions/checkout@v3 @@ -191,7 +191,7 @@ jobs: DBSYNC_POSTGRES_DB: "cexplorer" DBSYNC_POSTGRES_USER: "postgres" DBSYNC_POSTGRES_PASSWORD: "pSa8JCpQOACMUdGb" - FAKEDBSYNC_POSTGRES_DB: "vva" + FAKEDBSYNC_POSTGRES_DB: "govtool" FAKEDBSYNC_POSTGRES_USER: "test" FAKEDBSYNC_POSTGRES_PASSWORD: "test" GRAFANA_ADMIN_PASSWORD: ${{ secrets.GRAFANA_ADMIN_PASSWORD }} @@ -199,7 +199,7 @@ jobs: GRAFANA_SLACK_OAUTH_TOKEN: ${{ secrets.GRAFANA_SLACK_OAUTH_TOKEN }} NGINX_BASIC_AUTH: ${{ secrets.NGINX_BASIC_AUTH }} SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }} - TRAEFIK_LE_EMAIL: "admin+vva@binarapps.com" + TRAEFIK_LE_EMAIL: "admin+govtool@binarapps.com" steps: - name: Checkout code uses: actions/checkout@v3 diff --git a/.github/workflows/frontend_sonar_scan.yml b/.github/workflows/frontend_sonar_scan.yml index b69841c63..8a4df29ab 100644 --- a/.github/workflows/frontend_sonar_scan.yml +++ b/.github/workflows/frontend_sonar_scan.yml @@ -8,7 +8,7 @@ on: jobs: execute_sonar_scanner: - name: Execute sonar-scanner on vva-fe + name: Execute sonar-scanner on govtool frontend runs-on: ubuntu-latest permissions: read-all steps: @@ -26,4 +26,4 @@ jobs: # - uses: sonarsource/sonarqube-quality-gate-action@master # timeout-minutes: 5 # env: - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/lighthouse.yml b/.github/workflows/lighthouse.yml index 9d39d1707..19c0047e4 100644 --- a/.github/workflows/lighthouse.yml +++ b/.github/workflows/lighthouse.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/setup-node@v3 with: node-version: 16 - + - name: Install dependencies run: npm install working-directory: ./govtool/frontend @@ -27,7 +27,7 @@ jobs: with: path: | ~/.npm - key: ${{ runner.os }}-npm-${{ hashFiles('govtool/frontend/package-lock.json', 'tests/vva-fe/package-lock.json') }} + key: ${{ runner.os }}-npm-${{ hashFiles('govtool/frontend/package-lock.json', 'tests/govtool-frontend/package-lock.json') }} restore-keys: | ${{ runner.os }}-npm- @@ -45,7 +45,6 @@ jobs: run: | lhci assert --preset "lighthouse:recommended" - - name: Publish reports working-directory: ./govtool/frontend if: github.repository_owner == 'IntersectMBO' @@ -56,4 +55,4 @@ jobs: -d "@./lighthouseci/$(ls ./.lighthouseci |grep 'lhr.*\.json' | head -n 1)" \ -H "commit-hash: $(git rev-parse HEAD)" \ -H "secret-token: ${{ secrets.METRICS_SERVER_SECRET_TOKEN }}" \ - -H 'Content-Type: application/json' || echo "Metric Upload error ignored ..." \ No newline at end of file + -H 'Content-Type: application/json' || echo "Metric Upload error ignored ..." diff --git a/.github/workflows/test_backend.yml b/.github/workflows/test_backend.yml index 1a3a198d3..125666f2a 100644 --- a/.github/workflows/test_backend.yml +++ b/.github/workflows/test_backend.yml @@ -4,8 +4,8 @@ on: push: paths: - .github/workflows/test_backend.yml - # - src/vva-be - # - tests/vva-be + # - govtool/backend + # - tests/govtool-backend schedule: - cron: '0 0 * * *' @@ -18,7 +18,7 @@ on: options: - "sanchogov.tools/api" - "staging.govtool.byron.network/api" - - "vva-sanchonet.cardanoapi.io/api" + - "govtool-sanchonet.cardanoapi.io/api" jobs: build: @@ -26,7 +26,7 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - + - name: Set up Python uses: actions/setup-python@v4 with: @@ -34,7 +34,7 @@ jobs: cache: 'pip' - name: Run Backend Test - working-directory: tests/vva-be + working-directory: tests/govtool-backend run: | python -m pip install --upgrade pip pip install -r requirements.txt diff --git a/.github/workflows/test_integration_cypress.yml b/.github/workflows/test_integration_cypress.yml index d2c0b8cfc..a0fbf9011 100644 --- a/.github/workflows/test_integration_cypress.yml +++ b/.github/workflows/test_integration_cypress.yml @@ -22,13 +22,13 @@ on: options: - "sanchogov.tools" - "staging.govtool.byron.network" - - "vva-sanchonet.cardanoapi.io" + - "govtool-sanchonet.cardanoapi.io" jobs: cypress-tests: defaults: run: - working-directory: ./tests/vva-fe + working-directory: ./tests/govtool-frontend runs-on: ubuntu-latest env: NODE_OPTIONS: --max_old_space_size=4096 @@ -50,7 +50,7 @@ jobs: path: | ${{ steps.yarn-cache-dir-path.outputs.dir }} key: - ${{ runner.os }}-yarn-${{hashFiles('tests/vva-fe/yarn.lock') }} + ${{ runner.os }}-yarn-${{hashFiles('tests/govtool-frontend/yarn.lock') }} restore-keys: | ${{ runner.os }}-yarn- @@ -58,7 +58,7 @@ jobs: uses: cypress-io/github-action@v6 with: record: true - working-directory: ./tests/vva-fe + working-directory: ./tests/govtool-frontend env: CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} # pass GitHub token to allow accurately detecting a build vs a re-run build @@ -69,4 +69,3 @@ jobs: CYPRESS_kuberApiKey: ${{secrets.KUBER_API_KEY}} CYPRESS_faucetApiUrl: https://faucet.${{inputs.network || 'sanchonet'}}.world.dev.cardano.org CYPRESS_faucetApiKey: ${{ secrets.FAUCET_API_KEY }} - \ No newline at end of file diff --git a/README.md b/README.md index 02baca95e..ab338a3f3 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,8 @@ The SanchoNet GovTool is currently open for beta testing and can be accessed at Learn more; [docs.sanchogov.tools](https://docs.sanchogov.tools/). ## 📍 Navigation -- [GovTool Backend](./src/vva-be/README.md) -- [GovTool Frontend](./src/vva-fe/README.md) +- [GovTool Backend](./govtool/backend/README.md) +- [GovTool Frontend](./govtool/frontend/README.md) - [Documentation](./docs/) - [Tests](./tests/) @@ -45,4 +45,4 @@ Frontend is able to connect to Cardano wallets over the [CIP-30](https://github. ## 🤝 Contributing Thanks for considering contributing and helping us on creating GovTool! 😎 -Please checkout our [Contributing Documentation](./CONTRIBUTING.md). \ No newline at end of file +Please checkout our [Contributing Documentation](./CONTRIBUTING.md). diff --git a/docs/operations/DEPLOY.md b/docs/operations/DEPLOY.md index 3270ecb19..f0cedf97b 100644 --- a/docs/operations/DEPLOY.md +++ b/docs/operations/DEPLOY.md @@ -20,7 +20,7 @@ AWS is configured with Terraform, but the account needs to be bootstrapped befor This has to be done only once per AWS account. 1. Configure AWS CLI with `aws configure` (if you are using a configuration profile, use `aws --profile MYPROFILE configure` and then `export AWS_PROFILE=MYPROFILE`). -1. Execute `./src/terraform/bootstrap-aws-account.sh` script. +1. Execute `./infra/terraform/bootstrap-aws-account.sh` script. ### Infrastructure setup @@ -29,7 +29,7 @@ This has to be done only once per AWS account. 1. Run `terraform plan` to view changes that would be performed to infrastructure. 1. Take note of the outputs - they contain ECR repo URLs and app domains. -Note: the Terraform code configures the EC2 instance using `src/terraform/modules/vva-ec2/user_data.sh`. This script is only executed on instance creation. +Note: the Terraform code configures the EC2 instance using `infra/terraform/modules/govtool-ec2/user_data.sh`. This script is only executed on instance creation. ## Application deployment diff --git a/govtool/backend/README.md b/govtool/backend/README.md index ae36a75b9..4f6211a41 100644 --- a/govtool/backend/README.md +++ b/govtool/backend/README.md @@ -3,7 +3,7 @@ This is a backend application of GovTool project. ## Prerequisites -In order to run `vva-be` your host machine will need access to the `cardano-db-sync` postgres database. To have this database running locally you'll need: +In order to run `backend` your host machine will need access to the `cardano-db-sync` postgres database. To have this database running locally you'll need: * `cardano-node` * `cardano-db-sync` * PostgreSQL database @@ -24,10 +24,10 @@ Due to problems with openapi3 package it's hard to build this project with plain 1. Get [Nix](https://nixos.org/download). -2. Enter `src/vva-be` directory: +2. Enter `govtool/backend` directory: ```sh - cd src/vva-be + cd govtool/backend ``` 3. Allow broken nix packages @@ -54,3 +54,5 @@ Due to problems with openapi3 package it's hard to build this project with plain ```sh cabal run vva-be -- --config start-app ``` +> [!WARNING] +> In the context of our ongoing project enhancements, it is assumed that the executable previously known as 'vva-be' should be now officially renamed to 'govtool-backend'. This change is necessary for aligning with the updated branding and functional scope of the application and it has to be implemented in the near future as a chore and refactoring ticket. Make sure that the documentation matches the actual name of the executable. diff --git a/govtool/frontend/README.md b/govtool/frontend/README.md index 5d30306e4..d8ace9d3b 100644 --- a/govtool/frontend/README.md +++ b/govtool/frontend/README.md @@ -1,4 +1,4 @@ -# Voltaire GovTool Frontend +# GovTool Frontend Installed on your machine: @@ -16,7 +16,7 @@ Fill .env based on env.example file Go to the project directory ```bash - cd voltaire-era/src/vva-fe + cd voltaire-era/govtool/frontend ``` Install dependencies @@ -47,10 +47,10 @@ yarn dev 1. Get [Nix](https://nixos.org/download). -2. Enter `src/vva-fe` directory: +2. Enter `govtool/frontend` directory: ```sh -cd src/vva-fe +cd govtool/frontend ``` 3. Run `nix-shell` @@ -75,13 +75,13 @@ Install [`direnv`](https://direnv.net/): nix-env -i direnv ``` -Allow direnv configuration in `src/vva-fe`: +Allow direnv configuration in `govtool/frontend`: ```sh -direnv allow src/vva-fe +direnv allow govtool/frontend ``` -From now on, once you enter the `src/vva-fe` the `nix-shell` with proper +From now on, once you enter the `govtool/frontend` the `nix-shell` with proper configuration will be propagated. ## Developing @@ -128,9 +128,9 @@ npm run dev 1. Get [Nix](https://nixos.org/download). -2. Enter `src/vva-fe` directory: +2. Enter `govtool/frontend` directory: ```sh -cd src/vva-fe +cd govtool/frontend ``` 3. Run `nix-shell` @@ -152,12 +152,12 @@ Install [`direnv`](https://direnv.net/): nix-env -i direnv ``` -Allow direnv configuration in `src/vva-fe`: +Allow direnv configuration in `govtool/frontend`: ```sh -direnv allow src/vva-fe +direnv allow govtool/frontend ``` -From now on, once you enter the `src/vva-fe` the `nix-shell` with proper +From now on, once you enter the `govtool/frontend` the `nix-shell` with proper configuration will be propagated. ### Users diff --git a/infra/terraform/.env.example b/infra/terraform/.env.example new file mode 100644 index 000000000..57b5b564e --- /dev/null +++ b/infra/terraform/.env.example @@ -0,0 +1,5 @@ +export export AWS_PROFILE= +export NIXPKGS_ALLOW_UNFREE=1 + +use nix + diff --git a/infra/terraform/main.tf b/infra/terraform/main.tf index 291e66a89..6d46cc5a7 100644 --- a/infra/terraform/main.tf +++ b/infra/terraform/main.tf @@ -11,12 +11,12 @@ resource "aws_route53_zone" "govtool" { name = "govtool.byron.network." } -module "vva-ecr-be" { +module "govtool-ecr-backend" { source = "./modules/ecr" repo_name = "backend" } -module "vva-ecr-fe" { +module "govtool-ecr-frontend" { source = "./modules/ecr" repo_name = "frontend" } @@ -32,8 +32,8 @@ resource "aws_iam_policy" "cicd_ecr" { ] Effect = "Allow" Resource = [ - module.vva-ecr-be.repo_arn, - module.vva-ecr-fe.repo_arn + module.govtool-ecr-backend.repo_arn, + module.govtool-ecr-frontend.repo_arn ] }, { @@ -55,24 +55,24 @@ resource "aws_iam_group_policy_attachment" "cicd" { # duplicate the following block in order to prepare a new environment # make sure that app_env/cardano_network variable pair is unique -module "vva-dev-sanchonet" { - source = "./modules/vva-ec2" +module "govtool-dev-sanchonet" { + source = "./modules/govtool-ec2" app_env = "dev" cardano_network = "sanchonet" instance_type = "t3.large" dns_zone_id = aws_route53_zone.govtool.id } -module "vva-test-sanchonet" { - source = "./modules/vva-ec2" +module "govtool-test-sanchonet" { + source = "./modules/govtool-ec2" app_env = "test" cardano_network = "sanchonet" instance_type = "t3.large" dns_zone_id = aws_route53_zone.govtool.id } -module "vva-staging-sanchonet" { - source = "./modules/vva-ec2" +module "govtool-staging-sanchonet" { + source = "./modules/govtool-ec2" app_env = "staging" cardano_network = "sanchonet" instance_type = "t3.large" @@ -80,33 +80,33 @@ module "vva-staging-sanchonet" { custom_subdomain = "staging" } -module "vva-beta-sanchonet" { - source = "./modules/vva-ec2" +module "govtool-beta-sanchonet" { + source = "./modules/govtool-ec2" app_env = "beta" cardano_network = "sanchonet" instance_type = "t3.large" } -output "vva-ecr-be-url" { - value = module.vva-ecr-be.repo_url +output "govtool-ecr-backend-url" { + value = module.govtool-ecr-backend.repo_url } -output "vva-ecr-fe-url" { - value = module.vva-ecr-fe.repo_url +output "govtool-ecr-frontend-url" { + value = module.govtool-ecr-frontend.repo_url } -output "vva-dev-sanchonet-frontend-domain" { - value = module.vva-dev-sanchonet.frontend_domain +output "govtool-dev-sanchonet-frontend-domain" { + value = module.govtool-dev-sanchonet.frontend_domain } -output "vva-test-sanchonet-frontend-domain" { - value = module.vva-test-sanchonet.frontend_domain +output "govtool-test-sanchonet-frontend-domain" { + value = module.govtool-test-sanchonet.frontend_domain } -output "vva-staging-sanchonet-frontend-domain" { - value = module.vva-staging-sanchonet.frontend_domain +output "govtool-staging-sanchonet-frontend-domain" { + value = module.govtool-staging-sanchonet.frontend_domain } -output "vva-beta-sanchonet-frontend-domain" { - value = module.vva-beta-sanchonet.frontend_domain +output "govtool-beta-sanchonet-frontend-domain" { + value = module.govtool-beta-sanchonet.frontend_domain } diff --git a/infra/terraform/modules/ecr/variables.tf b/infra/terraform/modules/ecr/variables.tf index 4f29a09de..33fcb170f 100644 --- a/infra/terraform/modules/ecr/variables.tf +++ b/infra/terraform/modules/ecr/variables.tf @@ -1,4 +1,4 @@ variable "app_name" { - default = "vva" + default = "govtool" } variable "repo_name" {} diff --git a/infra/terraform/modules/vva-ec2/main.tf b/infra/terraform/modules/govtool-ec2/main.tf similarity index 96% rename from infra/terraform/modules/vva-ec2/main.tf rename to infra/terraform/modules/govtool-ec2/main.tf index e5a5522aa..f71417f05 100644 --- a/infra/terraform/modules/vva-ec2/main.tf +++ b/infra/terraform/modules/govtool-ec2/main.tf @@ -143,7 +143,7 @@ resource "aws_security_group" "web_sg" { } } -resource "aws_instance" "vva" { +resource "aws_instance" "govtool" { ami = var.ami instance_type = var.instance_type @@ -174,8 +174,8 @@ resource "aws_instance" "vva" { } } -resource "aws_eip" "vva" { - instance = aws_instance.vva.id +resource "aws_eip" "govtool" { + instance = aws_instance.govtool.id tags = { Name = "${var.app_name}_${var.app_env}_${var.cardano_network}" @@ -191,5 +191,5 @@ resource "aws_route53_record" "frontend" { name = "${var.custom_subdomain != "" ? "${var.custom_subdomain}" : "${var.app_env}-${var.cardano_network}"}" type = "A" ttl = 180 - records = [aws_eip.vva.public_ip] + records = [aws_eip.govtool.public_ip] } diff --git a/infra/terraform/modules/govtool-ec2/outputs.tf b/infra/terraform/modules/govtool-ec2/outputs.tf new file mode 100644 index 000000000..99a2f8920 --- /dev/null +++ b/infra/terraform/modules/govtool-ec2/outputs.tf @@ -0,0 +1,7 @@ +output "govtool_eip" { + value = aws_eip.govtool.public_ip +} + +output "frontend_domain" { + value = var.app_env == "beta" ? aws_eip.govtool.public_ip : aws_route53_record.frontend[0].fqdn +} diff --git a/infra/terraform/modules/vva-ec2/user_data.sh b/infra/terraform/modules/govtool-ec2/user_data.sh similarity index 100% rename from infra/terraform/modules/vva-ec2/user_data.sh rename to infra/terraform/modules/govtool-ec2/user_data.sh diff --git a/infra/terraform/modules/vva-ec2/variables.tf b/infra/terraform/modules/govtool-ec2/variables.tf similarity index 94% rename from infra/terraform/modules/vva-ec2/variables.tf rename to infra/terraform/modules/govtool-ec2/variables.tf index 7a230a530..0f58d46b4 100644 --- a/infra/terraform/modules/vva-ec2/variables.tf +++ b/infra/terraform/modules/govtool-ec2/variables.tf @@ -3,7 +3,7 @@ variable "ami" { } variable "app_env" {} variable "app_name" { - default = "vva" + default = "govtool" } variable "cardano_network" {} variable "custom_subdomain" { diff --git a/infra/terraform/modules/govtool-ec2/vva_to_govtool_migration_20240212.tf b/infra/terraform/modules/govtool-ec2/vva_to_govtool_migration_20240212.tf new file mode 100644 index 000000000..27673a071 --- /dev/null +++ b/infra/terraform/modules/govtool-ec2/vva_to_govtool_migration_20240212.tf @@ -0,0 +1,15 @@ +# FIXME This Terraform file in question is designed to migrate resource and +# module names, serving as a transitional tool to ensure consistent naming +# conventions across the infrastructure. Once it is confirmed that all users +# have applied this migration, the file can be safely removed in the future to +# maintain clarity and efficiency in the codebase. + +moved { + from = aws_instance.vva + to = aws_instance.govtool +} + +moved { + from = aws_eip.vva + to = aws_eip.govtool +} diff --git a/infra/terraform/modules/vva-ec2/outputs.tf b/infra/terraform/modules/vva-ec2/outputs.tf deleted file mode 100644 index 821684c05..000000000 --- a/infra/terraform/modules/vva-ec2/outputs.tf +++ /dev/null @@ -1,7 +0,0 @@ -output "vva_eip" { - value = aws_eip.vva.public_ip -} - -output "frontend_domain" { - value = var.app_env == "beta" ? aws_eip.vva.public_ip : aws_route53_record.frontend[0].fqdn -} diff --git a/infra/terraform/shell.nix b/infra/terraform/shell.nix new file mode 100644 index 000000000..de8446216 --- /dev/null +++ b/infra/terraform/shell.nix @@ -0,0 +1,4 @@ +{ pkgs ? import {} }: +pkgs.mkShell { + packages = with pkgs; [ awscli2 terraform ]; +} diff --git a/infra/terraform/vva_to_govtool_migration_20240212.tf b/infra/terraform/vva_to_govtool_migration_20240212.tf new file mode 100644 index 000000000..067ea4d77 --- /dev/null +++ b/infra/terraform/vva_to_govtool_migration_20240212.tf @@ -0,0 +1,35 @@ +# FIXME This Terraform file in question is designed to migrate resource and +# module names, serving as a transitional tool to ensure consistent naming +# conventions across the infrastructure. Once it is confirmed that all users +# have applied this migration, the file can be safely removed in the future to +# maintain clarity and efficiency in the codebase. + +moved { + from = module.vva-ecr-be + to = module.govtool-ecr-backend +} + +moved { + from = module.vva-ecr-fe + to = module.govtool-ecr-frontend +} + +moved { + from = module.vva-dev-sanchonet + to = module.govtool-dev-sanchonet +} + +moved { + from = module.vva-test-sanchonet + to = module.govtool-test-sanchonet +} + +moved { + from = module.vva-staging-sanchonet + to = module.govtool-staging-sanchonet +} + +moved { + from = module.vva-beta-sanchonet + to = module.govtool-beta-sanchonet +} diff --git a/scripts/govtool/.env.example b/scripts/govtool/.env.example index 71adc0bf6..47fb60653 100644 --- a/scripts/govtool/.env.example +++ b/scripts/govtool/.env.example @@ -1,15 +1,29 @@ use nix shell.nix -export AWS_PROFILE=vva +export AWS_PROFILE=govtool export ENVIRONMENT="dev" export CARDANO_NETWORK="sanchonet" -export SLACK_WEBHOOK_URL= +export SLACK_WEBHOOK_URL= export DBSYNC_POSTGRES_USER="postgres" -export DBSYNC_POSTGRES_PASSWORD="" +export DBSYNC_POSTGRES_PASSWORD= export DBSYNC_POSTGRES_DB="cexplorer" -export FAKEDBSYNC_POSTGRES_DB="vva" + +export FAKEDBSYNC_POSTGRES_DB="govtool" export FAKEDBSYNC_POSTGRES_USER="test" -export FAKEDBSYNC_POSTGRES_PASSWORD="test" -export TRAEFIK_LE_EMAIL="" +export FAKEDBSYNC_POSTGRES_PASSWORD= + +export TRAEFIK_LE_EMAIL= + +export GTM_ID=blank + +export SENTRY_DSN_BACKEND=blank +export SENTRY_DSN=blank + +export NGINX_BASIC_AUTH= + +export GRAFANA_ADMIN_PASSWORD= +export GRAFANA_SLACK_RECIPIENT= +export GRAFANA_SLACK_WEBHOOK= +export GRAFANA_SLACK_OAUTH_TOKEN= diff --git a/scripts/govtool/Makefile b/scripts/govtool/Makefile index f382cf803..d1840c7cb 100644 --- a/scripts/govtool/Makefile +++ b/scripts/govtool/Makefile @@ -10,11 +10,12 @@ grafana_slack_oauth_token := $(shell echo $${GRAFANA_SLACK_OAUTH_TOKEN}) gtm_id := $(shell echo $${GTM_ID}) sentry_dsn := $(shell echo $${SENTRY_DSN}) +commit := $(shell git rev-parse HEAD) branch := $(shell git rev-parse --abbrev-ref HEAD) docker ?= docker domain := $(shell echo $${DOMAIN:-$(env)-$(cardano_network).govtool.byron.network}) repo_url ?= 733019650473.dkr.ecr.eu-west-1.amazonaws.com -tag := $(branch)-$(env)-$(cardano_network) +tag := $(commit)-$(env)-$(cardano_network) docker_host := $(domain) docker_user := ubuntu @@ -35,7 +36,7 @@ all: docker-login prepare-config upload-config build-backend push-backend build- check-env-defined: @:$(call check_defined, cardano_network) @:$(call check_defined, env) - @grep -q "module \"vva-$(env)-$(cardano_network)\"" ../../infra/terraform/main.tf && \ + @grep -q "module \"govtool-$(env)-$(cardano_network)\"" ../../infra/terraform/main.tf && \ echo "Environment $(env) for network $(cardano_network) is defined in Terraform" || \ { echo "Environment $(env) for network $(cardano_network) is NOT defined in Terraform, cannot deploy there"; exit 1; } @@ -64,7 +65,7 @@ upload-config: prepare-config build-backend: @:$(call check_defined, cardano_network) @:$(call check_defined, env) - $(docker) build --tag $(repo_url)/backend:$(tag) ../../govtool/backend + $(docker) build --tag "$(repo_url)/backend:$(tag)" ../../govtool/backend .PHONY: push-backend push-backend: @@ -79,7 +80,7 @@ build-frontend: @:$(call check_defined, gtm_id) @:$(call check_defined, sentry_dsn) if [[ "$(cardano_network)" = "mainnet" ]]; then NETWORK_FLAG=1; else NETWORK_FLAG=0; fi; \ - $(docker) build --tag $(repo_url)/frontend:$(tag) \ + $(docker) build --tag "$(repo_url)/frontend:$(tag)" \ --build-arg VITE_BASE_URL="https://$(domain)/api" \ --build-arg VITE_GTM_ID="$(gtm_id)" \ --build-arg VITE_NETWORK_FLAG="$$NETWORK_FLAG" \ @@ -103,8 +104,8 @@ deploy-stack: export GRAFANA_ADMIN_PASSWORD=$(grafana_admin_password); \ export TAG=$(tag); \ ssh-keyscan $(docker_host) 2>/dev/null >> ~/.ssh/known_hosts; \ - docker compose -f docker-compose.$(cardano_network).yml -p vva-$(env)-$(cardano_network) pull; \ - docker compose -f docker-compose.$(cardano_network).yml -p vva-$(env)-$(cardano_network) up -d + docker compose -f docker-compose.$(cardano_network).yml -p govtool-$(env)-$(cardano_network) pull; \ + docker compose -f docker-compose.$(cardano_network).yml -p govtool-$(env)-$(cardano_network) up -d .PHONY: destroy-cardano-node-and-dbsync destroy-cardano-node-and-dbsync: @@ -131,8 +132,8 @@ toggle-maintenance: export DOCKER_HOST=ssh://$(ssh_url); \ export TAG=$(tag); \ ssh-keyscan $(docker_host) 2>/dev/null >> ~/.ssh/known_hosts; \ - if [[ "$(maintenance)" = "enable" ]]; then docker compose -f docker-compose.$(cardano_network).yml -p vva-$(env)-$(cardano_network) exec vva-fe touch /var/run/maintenance_enabled; \ - else docker compose -f docker-compose.$(cardano_network).yml -p vva-$(env)-$(cardano_network) exec vva-fe rm /var/run/maintenance_enabled; fi + if [[ "$(maintenance)" = "enable" ]]; then docker compose -f docker-compose.$(cardano_network).yml -p govtool-$(env)-$(cardano_network) exec frontend touch /var/run/maintenance_enabled; \ + else docker compose -f docker-compose.$(cardano_network).yml -p govtool-$(env)-$(cardano_network) exec frontend rm /var/run/maintenance_enabled; fi .DEFAULT_GOAL := info .PHONY: info @@ -155,3 +156,24 @@ notify: @:$(call check_defined, cardano_network) @:$(call check_defined, env) curl -X POST -H 'Content-type: application/json' --data '{"host":"$(docker_host)","branch":"$(branch)","env":"$(env)","commit":"$(shell git rev-parse HEAD)"}' $$SLACK_WEBHOOK_URL + +.PHONY: ssh +ssh: + @:$(call check_defined, cardano_network) + @:$(call check_defined, env) + export TERM=xterm-256color; \ + ssh $(ssh_url) + +.PHONY: docker +docker: + @:$(call check_defined, cardano_network) + @:$(call check_defined, env) + @:$(call check_defined, grafana_admin_password) + @:$(call check_defined, cmd) + export CARDANO_NETWORK=$(cardano_network); \ + export DOCKER_HOST=ssh://$(ssh_url); \ + export ENVIRONMENT=$(env); \ + export GRAFANA_ADMIN_PASSWORD=$(grafana_admin_password); \ + export TAG=$(tag); \ + ssh-keyscan $(docker_host) 2>/dev/null >> ~/.ssh/known_hosts; \ + docker compose -f docker-compose.$(cardano_network).yml -p govtool-$(env)-$(cardano_network) $(cmd) diff --git a/scripts/govtool/config/grafana-provisioning/alerting/alerting.yml b/scripts/govtool/config/grafana-provisioning/alerting/alerting.yml index f5f6249ca..e50e4b6e0 100644 --- a/scripts/govtool/config/grafana-provisioning/alerting/alerting.yml +++ b/scripts/govtool/config/grafana-provisioning/alerting/alerting.yml @@ -299,7 +299,7 @@ groups: type: prometheus uid: PBFA97CFB590B2093 editorMode: builder - expr: sum by(code) (rate(traefik_service_requests_total{service="vva-be@docker", code="502"}[$__rate_interval])) + expr: sum by(code) (rate(traefik_service_requests_total{service="backend@docker", code="502"}[$__rate_interval])) hide: false instant: false interval: "" diff --git a/scripts/govtool/config/grafana-provisioning/dashboards/vva.json b/scripts/govtool/config/grafana-provisioning/dashboards/govtool.json similarity index 98% rename from scripts/govtool/config/grafana-provisioning/dashboards/vva.json rename to scripts/govtool/config/grafana-provisioning/dashboards/govtool.json index 2ac493158..348b8e6c6 100644 --- a/scripts/govtool/config/grafana-provisioning/dashboards/vva.json +++ b/scripts/govtool/config/grafana-provisioning/dashboards/govtool.json @@ -18,7 +18,7 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 0, - "id": 2, + "id": 3, "links": [], "liveNow": false, "panels": [ @@ -81,7 +81,7 @@ }, "editorMode": "builder", "exemplar": true, - "expr": "traefik_service_requests_total{service=\"vva-fe@docker\"}", + "expr": "traefik_service_requests_total{service=\"frontend@docker\"}", "instant": false, "legendFormat": "{{method}} : {{code}}", "range": true, @@ -174,7 +174,7 @@ "uid": "PBFA97CFB590B2093" }, "editorMode": "builder", - "expr": "sum by(code) (rate(traefik_service_requests_total{service=\"vva-fe@docker\"}[$__rate_interval]))", + "expr": "sum by(code) (rate(traefik_service_requests_total{service=\"frontend@docker\"}[$__rate_interval]))", "hide": false, "instant": false, "legendFormat": "{{code}}", @@ -310,7 +310,7 @@ }, "editorMode": "builder", "exemplar": true, - "expr": "traefik_service_requests_total{service=\"vva-be@docker\"}", + "expr": "traefik_service_requests_total{service=\"backend@docker\"}", "instant": false, "legendFormat": "{{method}} : {{code}}", "range": true, @@ -403,7 +403,7 @@ "uid": "PBFA97CFB590B2093" }, "editorMode": "builder", - "expr": "sum by(code) (rate(traefik_service_requests_total{service=\"vva-be@docker\"}[$__rate_interval]))", + "expr": "sum by(code) (rate(traefik_service_requests_total{service=\"backend@docker\"}[$__rate_interval]))", "hide": false, "instant": false, "legendFormat": "{{code}}", diff --git a/scripts/govtool/config/secrets/vva-be-config.json b/scripts/govtool/config/secrets/backend-config.json similarity index 92% rename from scripts/govtool/config/secrets/vva-be-config.json rename to scripts/govtool/config/secrets/backend-config.json index 068a9613f..d60da33f1 100644 --- a/scripts/govtool/config/secrets/vva-be-config.json +++ b/scripts/govtool/config/secrets/backend-config.json @@ -8,7 +8,7 @@ }, "fakedbsyncconfig" : { "host" : "postgres-fakedbsync", - "dbname" : "vva", + "dbname" : "govtool", "user" : "test", "password" : "test", "port" : 5432 diff --git a/scripts/govtool/config/secrets/vva-be-config.json.tpl b/scripts/govtool/config/secrets/backend-config.json.tpl similarity index 100% rename from scripts/govtool/config/secrets/vva-be-config.json.tpl rename to scripts/govtool/config/secrets/backend-config.json.tpl diff --git a/scripts/govtool/docker-compose.sanchonet.yml b/scripts/govtool/docker-compose.sanchonet.yml index 88304aaf5..0a5664263 100644 --- a/scripts/govtool/docker-compose.sanchonet.yml +++ b/scripts/govtool/docker-compose.sanchonet.yml @@ -104,7 +104,7 @@ services: logging: *logging cardano-node: - image: ghcr.io/intersectmbo/cardano-node:8.7.2 + image: ghcr.io/intersectmbo/cardano-node:8.8.0-pre entrypoint: - "cardano-node" - "run" @@ -166,31 +166,31 @@ services: restart: always logging: *logging - vva-be: + backend: image: ${VVA_BE_REPO:-733019650473.dkr.ecr.eu-west-1.amazonaws.com/backend}:${TAG:-main-dev-sanchonet} - command: /usr/local/bin/vva-be -c /run/secrets/vva-be-config.json start-app + command: /usr/local/bin/vva-be -c /run/secrets/backend-config.json start-app depends_on: cardano-node: condition: service_healthy postgres: condition: service_healthy secrets: - - vva-be-config.json + - backend-config.json restart: always logging: *logging labels: - "traefik.enable=true" - - "traefik.http.routers.vva-be.rule=Host(`${DOMAIN:-$ENVIRONMENT-$CARDANO_NETWORK.govtool.byron.network}`) && PathPrefix(`/api`)" - - "traefik.http.middlewares.vva-be-stripprefix.stripprefix.prefixes=/api" - - "traefik.http.middlewares.vva-be-cors.headers.customresponseheaders.Access-Control-Allow-Origin=https://${DOMAIN:-$ENVIRONMENT-$CARDANO_NETWORK.govtool.byron.network}" - - "traefik.http.middlewares.vva-be-cors.headers.customresponseheaders.Access-Control-Allow-Methods=GET,HEAD,OPTIONS" - - "traefik.http.middlewares.vva-be-cors.headers.addvaryheader=true" - - "traefik.http.routers.vva-be.middlewares=vva-be-stripprefix@docker,vva-be-cors@docker" - - "traefik.http.routers.vva-be.entrypoints=websecure" - - "traefik.http.routers.vva-be.tls.certresolver=myresolver" - - "traefik.http.services.vva-be.loadbalancer.server.port=9876" + - "traefik.http.routers.backend.rule=Host(`${DOMAIN:-$ENVIRONMENT-$CARDANO_NETWORK.govtool.byron.network}`) && PathPrefix(`/api`)" + - "traefik.http.middlewares.backend-stripprefix.stripprefix.prefixes=/api" + - "traefik.http.middlewares.backend-cors.headers.customresponseheaders.Access-Control-Allow-Origin=https://${DOMAIN:-$ENVIRONMENT-$CARDANO_NETWORK.govtool.byron.network}" + - "traefik.http.middlewares.backend-cors.headers.customresponseheaders.Access-Control-Allow-Methods=GET,HEAD,OPTIONS" + - "traefik.http.middlewares.backend-cors.headers.addvaryheader=true" + - "traefik.http.routers.backend.middlewares=backend-stripprefix@docker,backend-cors@docker" + - "traefik.http.routers.backend.entrypoints=websecure" + - "traefik.http.routers.backend.tls.certresolver=myresolver" + - "traefik.http.services.backend.loadbalancer.server.port=9876" - vva-fe: + frontend: image: ${VVA_FE_REPO:-733019650473.dkr.ecr.eu-west-1.amazonaws.com/frontend}:${TAG:-main-dev-sanchonet} volumes: - /home/ubuntu/config/nginx/auth.conf:/etc/nginx/conf.d/auth.conf @@ -204,12 +204,12 @@ services: logging: *logging labels: - "traefik.enable=true" - - "traefik.http.routers.vva-fe.rule=Host(`${DOMAIN:-$ENVIRONMENT-$CARDANO_NETWORK.govtool.byron.network}`)" - - "traefik.http.routers.vva-fe.entrypoints=websecure" - - "traefik.http.routers.vva-fe.tls.certresolver=myresolver" - - "traefik.http.middlewares.vva-fe-csp.headers.contentSecurityPolicy=default-src 'self'; img-src *.usersnap.com 'self' data:; script-src *.usersnap.com 'self' 'unsafe-inline' https://www.googletagmanager.com https://browser.sentry-cdn.com; style-src *.usersnap.com *.googleapis.com 'self' 'unsafe-inline' https://fonts.googleapis.com; connect-src *.usersnap.com https://s3.eu-central-1.amazonaws.com/upload.usersnap.com 'self' https://o4506155985141760.ingest.sentry.io/api/4506156032196608/envelope/ *.google-analytics.com; font-src *.usersnap.com *.gstatic.com 'self' 'unsafe-inline' https://fonts.gstatic.com; worker-src blob:" - - "traefik.http.routers.vva-fe.middlewares=vva-fe-csp@docker" - - "traefik.http.services.vva-fe.loadbalancer.server.port=80" + - "traefik.http.routers.frontend.rule=Host(`${DOMAIN:-$ENVIRONMENT-$CARDANO_NETWORK.govtool.byron.network}`)" + - "traefik.http.routers.frontend.entrypoints=websecure" + - "traefik.http.routers.frontend.tls.certresolver=myresolver" + - "traefik.http.middlewares.frontend-csp.headers.contentSecurityPolicy=default-src 'self'; img-src *.usersnap.com 'self' data:; script-src *.usersnap.com 'self' 'unsafe-inline' https://www.googletagmanager.com https://browser.sentry-cdn.com; style-src *.usersnap.com *.googleapis.com 'self' 'unsafe-inline' https://fonts.googleapis.com; connect-src *.usersnap.com https://s3.eu-central-1.amazonaws.com/upload.usersnap.com 'self' https://o4506155985141760.ingest.sentry.io/api/4506156032196608/envelope/ *.google-analytics.com; font-src *.usersnap.com *.gstatic.com 'self' 'unsafe-inline' https://fonts.gstatic.com; worker-src blob:" + - "traefik.http.routers.frontend.middlewares=frontend-csp@docker" + - "traefik.http.services.frontend.loadbalancer.server.port=80" secrets: postgres_db: @@ -218,8 +218,8 @@ secrets: file: /home/ubuntu/config/dbsync-secrets/postgres_password postgres_user: file: /home/ubuntu/config/dbsync-secrets/postgres_user - vva-be-config.json: - file: /home/ubuntu/config/vva-be-config.json + backend-config.json: + file: /home/ubuntu/config/backend-config.json volumes: letsencrypt: diff --git a/scripts/govtool/docker-compose.yml b/scripts/govtool/docker-compose.yml index 417e036d2..6e705023a 100644 --- a/scripts/govtool/docker-compose.yml +++ b/scripts/govtool/docker-compose.yml @@ -96,13 +96,13 @@ services: image: postgres:15-alpine environment: - POSTGRES_LOGGING=true - - POSTGRES_DB=vva + - POSTGRES_DB=govtool - POSTGRES_PASSWORD=test - POSTGRES_USER=postgres volumes: - postgres-fakedbsync:/var/lib/postgresql/data - - ./vva-be/misc/fakedbsync_users.sql:/docker-entrypoint-initdb.d/00_fakedbsync_users.sql - - ./vva-be/misc/schema6.sql:/docker-entrypoint-initdb.d/10_schema6.sql + - ../../govtool/backend/misc/fakedbsync_users.sql:/docker-entrypoint-initdb.d/00_fakedbsync_users.sql + - ../../govtool/backend/misc/schema6.sql:/docker-entrypoint-initdb.d/10_schema6.sql restart: on-failure healthcheck: # Use pg_isready to check postgres is running. Substitute different @@ -114,10 +114,10 @@ services: command: ${POSTGRES_ARGS:--c maintenance_work_mem=1GB -c max_parallel_maintenance_workers=4} logging: *logging - vva-be: + backend: build: - context: vva-be - command: /usr/local/bin/vva-be -c /run/secrets/vva-be-config.json start-app + context: ../../govtool/backend + command: /usr/local/bin/vva-be -c /run/secrets/backend-config.json start-app depends_on: # Depend on both services to be healthy before starting. cardano-node: @@ -130,20 +130,20 @@ services: # ports: # - ${VVA_BE_PORT:-9876}:9876 secrets: - - vva-be-config.json + - backend-config.json restart: on-failure logging: *logging labels: - "traefik.enable=true" - - "traefik.http.routers.vva-be.rule=Host(`${VVA_BE_DOMAIN:-vva-be.localhost}`)" - - "traefik.http.routers.vva-be.entrypoints=web" - - "traefik.http.services.vva-be.loadbalancer.server.port=9876" + - "traefik.http.routers.backend.rule=Host(`${GOVTOOL_BE_DOMAIN:-backend-govtool.localhost}`)" + - "traefik.http.routers.backend.entrypoints=web" + - "traefik.http.services.backend.loadbalancer.server.port=9876" - vva-fe: + frontend: build: - context: vva-fe + context: ../../govtool/frontend args: - - VITE_BASE_URL="https://${VA_BE_DOMAIN:-vva-be.localhost}" + - VITE_BASE_URL="https://${GOVTOOL_BE_DOMAIN:-backend-govtool.localhost}" depends_on: # Depend on both services to be healthy before starting. cardano-node: @@ -157,9 +157,9 @@ services: logging: *logging labels: - "traefik.enable=true" - - "traefik.http.routers.vva-fe.rule=Host(`${VVA_FE_DOMAIN:-vva-fe.localhost}`)" - - "traefik.http.routers.vva-fe.entrypoints=web" - - "traefik.http.services.vva-fe.loadbalancer.server.port=80" + - "traefik.http.routers.frontend.rule=Host(`${GOVTOOL_FE_DOMAIN:-frontend-govtool.localhost}`)" + - "traefik.http.routers.frontend.entrypoints=web" + - "traefik.http.services.frontend.loadbalancer.server.port=80" secrets: postgres_db: @@ -168,8 +168,8 @@ secrets: file: ./config/secrets/postgres_password postgres_user: file: ./config/secrets/postgres_user - vva-be-config.json: - file: ./config/secrets/vva-be-config.json + backend-config.json: + file: ./config/secrets/backend-config.json volumes: # letsencrypt: diff --git a/scripts/govtool/prepare-config.sh b/scripts/govtool/prepare-config.sh index ac271a837..7e072d116 100755 --- a/scripts/govtool/prepare-config.sh +++ b/scripts/govtool/prepare-config.sh @@ -39,8 +39,8 @@ sed -e "s/FAKEDBSYNC_POSTGRES_DB/$FAKEDBSYNC_POSTGRES_DB/" \ -e "s/DBSYNC_POSTGRES_USER/$DBSYNC_POSTGRES_USER/" \ -e "s/DBSYNC_POSTGRES_PASSWORD/$DBSYNC_POSTGRES_PASSWORD/" \ -e "s|SENTRY_DSN|$SENTRY_DSN_BACKEND|" \ - "$config_dir/secrets/vva-be-config.json.tpl" \ - > "$target_config_dir/vva-be-config.json" + "$config_dir/secrets/backend-config.json.tpl" \ + > "$target_config_dir/backend-config.json" # prometheus config file cat >"$target_config_dir/prometheus.yml" <<_EOF_ @@ -48,7 +48,7 @@ global: scrape_interval: 15s evaluation_interval: 15s external_labels: - monitor: 'vva' + monitor: 'govtool' scrape_configs: - job_name: 'traefik' scrape_interval: 5s diff --git a/tests/vva-be/.env.example b/tests/govtool-backend/.env.example similarity index 100% rename from tests/vva-be/.env.example rename to tests/govtool-backend/.env.example diff --git a/tests/vva-be/.gitignore b/tests/govtool-backend/.gitignore similarity index 100% rename from tests/vva-be/.gitignore rename to tests/govtool-backend/.gitignore diff --git a/tests/vva-be/README.md b/tests/govtool-backend/README.md similarity index 86% rename from tests/vva-be/README.md rename to tests/govtool-backend/README.md index bb066b240..33c6f211e 100644 --- a/tests/vva-be/README.md +++ b/tests/govtool-backend/README.md @@ -1,8 +1,8 @@ -VVA-BE PyTest +GovTool backend PyTest ================= This test is responsible for following -- Perform basic tests on VVA backend endpoints. +- Perform basic tests on GovTool backend endpoints. - Publish the reports to metrics server for visualization. ## Installation @@ -31,7 +31,7 @@ This will generate test_data.json that will be used to run tests. ## Run tests -In the root directory of tests/vva-be run the following command +In the root directory of tests/govtool-backend run the following command ```shell export BASE_URL="url" # server's url e.g. https://staging.govtool.byron.network/api" export METRICS_URL="url" # metrics server Url diff --git a/tests/vva-be/config.py b/tests/govtool-backend/config.py similarity index 100% rename from tests/vva-be/config.py rename to tests/govtool-backend/config.py diff --git a/tests/vva-be/models/TestData.py b/tests/govtool-backend/models/TestData.py similarity index 100% rename from tests/vva-be/models/TestData.py rename to tests/govtool-backend/models/TestData.py diff --git a/tests/vva-be/models/TestResult.py b/tests/govtool-backend/models/TestResult.py similarity index 100% rename from tests/vva-be/models/TestResult.py rename to tests/govtool-backend/models/TestResult.py diff --git a/tests/vva-be/models/__init__.py b/tests/govtool-backend/models/__init__.py similarity index 100% rename from tests/vva-be/models/__init__.py rename to tests/govtool-backend/models/__init__.py diff --git a/tests/vva-be/requirements.txt b/tests/govtool-backend/requirements.txt similarity index 100% rename from tests/vva-be/requirements.txt rename to tests/govtool-backend/requirements.txt diff --git a/tests/vva-be/setup.py b/tests/govtool-backend/setup.py similarity index 100% rename from tests/vva-be/setup.py rename to tests/govtool-backend/setup.py diff --git a/tests/vva-be/test_cases/__init__.py b/tests/govtool-backend/test_cases/__init__.py similarity index 100% rename from tests/vva-be/test_cases/__init__.py rename to tests/govtool-backend/test_cases/__init__.py diff --git a/tests/vva-be/test_cases/conftest.py b/tests/govtool-backend/test_cases/conftest.py similarity index 93% rename from tests/vva-be/test_cases/conftest.py rename to tests/govtool-backend/test_cases/conftest.py index 24184f2aa..fe20b385e 100644 --- a/tests/vva-be/test_cases/conftest.py +++ b/tests/govtool-backend/test_cases/conftest.py @@ -8,7 +8,7 @@ from models.TestResult import Metrics -from test_cases.vva_api import VVAApi +from test_cases.govtool_api import GovToolApi from config import CURRENT_GIT_HASH from config import BUILD_ID @@ -18,7 +18,7 @@ @pytest.fixture(scope="session") -def vva_api(): +def govtool_api(): base_url: str = os.environ.get('BASE_URL') metrics_url: str = os.environ.get('METRICS_URL') @@ -36,7 +36,7 @@ def vva_api(): print("METRICS_URL environment variable is not set.", file=sys.stderr) print("Proceeding without METRICS_URL: Metrics will not be posted") - api = VVAApi(base_url) + api = GovToolApi(base_url) yield api if metrics_url: @@ -64,13 +64,13 @@ def vva_api(): @pytest.hookimpl(wrapper=True, tryfirst=True) def pytest_runtest_makereport(item): rep = yield - vva_api_object = item.funcargs.get("vva_api") + govtool_api_object = item.funcargs.get("govtool_api") if rep.when == "call": test_func_name = re.search(r'(?<=::)(.*?)*(?=\[|$)', rep.nodeid).group() - vva_api_object.add_test_metrics( + govtool_api_object.add_test_metrics( Metrics( outcome=rep.outcome, test_name=test_func_name, diff --git a/tests/vva-be/test_cases/fixtures/ada_holder.py b/tests/govtool-backend/test_cases/fixtures/ada_holder.py similarity index 80% rename from tests/vva-be/test_cases/fixtures/ada_holder.py rename to tests/govtool-backend/test_cases/fixtures/ada_holder.py index 083599011..57343cd2e 100644 --- a/tests/vva-be/test_cases/fixtures/ada_holder.py +++ b/tests/govtool-backend/test_cases/fixtures/ada_holder.py @@ -4,7 +4,7 @@ @pytest.fixture(scope="module", params=ada_holders) -def ada_holder_delegate_to_drep(request, vva_api): +def ada_holder_delegate_to_drep(request, govtool_api): ada_holder: AdaHolder = request.param delegation_data = Delegation( @@ -12,4 +12,4 @@ def ada_holder_delegate_to_drep(request, vva_api): dRepId=ada_holder["drepId"] ) - yield delegation_data \ No newline at end of file + yield delegation_data diff --git a/tests/vva-be/test_cases/fixtures/drep.py b/tests/govtool-backend/test_cases/fixtures/drep.py similarity index 100% rename from tests/vva-be/test_cases/fixtures/drep.py rename to tests/govtool-backend/test_cases/fixtures/drep.py diff --git a/tests/vva-be/test_cases/vva_api.py b/tests/govtool-backend/test_cases/govtool_api.py similarity index 99% rename from tests/vva-be/test_cases/vva_api.py rename to tests/govtool-backend/test_cases/govtool_api.py index 8dd5a2ecc..604c15459 100644 --- a/tests/vva-be/test_cases/vva_api.py +++ b/tests/govtool-backend/test_cases/govtool_api.py @@ -9,7 +9,7 @@ from config import BUILD_ID -class VVAApi(): +class GovToolApi(): def __init__(self, base_url: str): self._base_url = base_url diff --git a/tests/govtool-backend/test_cases/test_ada_holder.py b/tests/govtool-backend/test_cases/test_ada_holder.py new file mode 100644 index 000000000..651a31218 --- /dev/null +++ b/tests/govtool-backend/test_cases/test_ada_holder.py @@ -0,0 +1,14 @@ +from models.TestData import AdaHolder, Delegation + +def test_ada_delegation(govtool_api, ada_holder_delegate_to_drep): + print(ada_holder_delegate_to_drep) + response = govtool_api.ada_holder_get_current_delegation(ada_holder_delegate_to_drep["stakeKey"]) + resp = response.json() + if resp: + assert ada_holder_delegate_to_drep["drepId"] in resp + + +def test_check_voting_power(govtool_api, ada_holder_delegate_to_drep): + response = govtool_api.ada_holder_get_voting_power(ada_holder_delegate_to_drep["stakeKey"]) + ada_holder_voting_power = response.json() + assert isinstance(ada_holder_voting_power, int) diff --git a/tests/vva-be/test_cases/test_drep.py b/tests/govtool-backend/test_cases/test_drep.py similarity index 81% rename from tests/vva-be/test_cases/test_drep.py rename to tests/govtool-backend/test_cases/test_drep.py index 2766af21e..c077e9169 100644 --- a/tests/vva-be/test_cases/test_drep.py +++ b/tests/govtool-backend/test_cases/test_drep.py @@ -34,14 +34,14 @@ def validate_voteonproposal_list(voteonproposal_list: [VoteonProposal]) -> bool: return True -def test_list_drep(vva_api): - response = vva_api.drep_list() +def test_list_drep(govtool_api): + response = govtool_api.drep_list() drep_list = response.json() validate_drep_list(drep_list) -def test_initialized_getVotes( vva_api, registered_drep): - response = vva_api.drep_getVotes(registered_drep["drepId"]) +def test_initialized_getVotes( govtool_api, registered_drep): + response = govtool_api.drep_getVotes(registered_drep["drepId"]) validate_voteonproposal_list(response.json()) votes = response.json() proposals = map(lambda x: x["vote"]["proposalId"], votes) @@ -49,6 +49,6 @@ def test_initialized_getVotes( vva_api, registered_drep): assert len(proposals)==0 -def test_initialized_getVotingPower(vva_api, registered_drep): - response = vva_api.drep_get_voting_power(registered_drep["drepId"]) - assert isinstance(response.json(), int) \ No newline at end of file +def test_initialized_getVotingPower(govtool_api, registered_drep): + response = govtool_api.drep_get_voting_power(registered_drep["drepId"]) + assert isinstance(response.json(), int) diff --git a/tests/vva-be/test_cases/test_proposal.py b/tests/govtool-backend/test_cases/test_proposal.py similarity index 89% rename from tests/vva-be/test_cases/test_proposal.py rename to tests/govtool-backend/test_cases/test_proposal.py index 931390c6e..7533d56ac 100644 --- a/tests/vva-be/test_cases/test_proposal.py +++ b/tests/govtool-backend/test_cases/test_proposal.py @@ -13,7 +13,7 @@ def validate_proposal_list(proposal_list: [Proposal]) -> bool: return True -def test_list_proposal(vva_api): - response = vva_api.proposal_list() +def test_list_proposal(govtool_api): + response = govtool_api.proposal_list() proposal_list = response.json() assert validate_proposal_list(proposal_list) diff --git a/tests/vva-be/test_data.json b/tests/govtool-backend/test_data.json similarity index 100% rename from tests/vva-be/test_data.json rename to tests/govtool-backend/test_data.json diff --git a/tests/vva-be/test_data.py b/tests/govtool-backend/test_data.py similarity index 100% rename from tests/vva-be/test_data.py rename to tests/govtool-backend/test_data.py diff --git a/tests/vva-fe/.gitignore b/tests/govtool-frontend/.gitignore similarity index 100% rename from tests/vva-fe/.gitignore rename to tests/govtool-frontend/.gitignore diff --git a/tests/vva-fe/README.md b/tests/govtool-frontend/README.md similarity index 78% rename from tests/vva-fe/README.md rename to tests/govtool-frontend/README.md index 2c7720148..94ca1fab3 100644 --- a/tests/vva-fe/README.md +++ b/tests/govtool-frontend/README.md @@ -1,4 +1,4 @@ -VVA Frontend Integration Test +GovTool frontend Integration Test ============================= ## Run tests @@ -14,5 +14,5 @@ yarn cypress run ## Run tests in dev environment ``` -yarn cypress run --env baseUrl=http://localhost:5173,apiUrl=https://vva.dev.byron.network +yarn cypress run --env baseUrl=http://localhost:5173,apiUrl=https://govtool.dev.byron.network ``` diff --git a/tests/vva-fe/currents.config.js b/tests/govtool-frontend/currents.config.js similarity index 84% rename from tests/vva-fe/currents.config.js rename to tests/govtool-frontend/currents.config.js index 956b34edf..4ce504e77 100644 --- a/tests/vva-fe/currents.config.js +++ b/tests/govtool-frontend/currents.config.js @@ -1,6 +1,6 @@ module.exports = { - projectId: "vva-fe", + projectId: "govtool-frontend", recordKey: "2a3f6b8c-7d4e-5f1a-9b0c-6d2e3f4a5b6c", // Sorry Cypress users - set the director service URL cloudServiceUrl: "https://cypress-director.cardanoapi.io", -}; \ No newline at end of file +}; diff --git a/tests/vva-fe/cypress.config.ts b/tests/govtool-frontend/cypress.config.ts similarity index 89% rename from tests/vva-fe/cypress.config.ts rename to tests/govtool-frontend/cypress.config.ts index f8728974d..9d6301054 100644 --- a/tests/vva-fe/cypress.config.ts +++ b/tests/govtool-frontend/cypress.config.ts @@ -5,8 +5,8 @@ module.exports = { chromeWebSecurity: false, // experimentalModifyObstructiveThirdPartyCode: true, env: { - baseUrl: "https://vva-sanchonet.cardanoapi.io", - apiUrl: "http://vva-sanchonet.cardanoapi.io/api", + baseUrl: "https://govtool-sanchonet.cardanoapi.io", + apiUrl: "http://govtool-sanchonet.cardanoapi.io/api", disableSecurityTest: false, // set to true for github-ci networkId: "testnet", mobileViewportWidthBreakpoint: 414, @@ -29,4 +29,4 @@ module.exports = { //return cloudPlugin(on, config); }, }, -}; \ No newline at end of file +}; diff --git a/tests/vva-fe/cypress/constants/governanceActions.ts b/tests/govtool-frontend/cypress/constants/governanceActions.ts similarity index 100% rename from tests/vva-fe/cypress/constants/governanceActions.ts rename to tests/govtool-frontend/cypress/constants/governanceActions.ts diff --git a/tests/vva-fe/cypress/constants/wallet.ts b/tests/govtool-frontend/cypress/constants/wallet.ts similarity index 100% rename from tests/vva-fe/cypress/constants/wallet.ts rename to tests/govtool-frontend/cypress/constants/wallet.ts diff --git a/tests/vva-fe/cypress/e2e/0_bootstrap.cy.ts b/tests/govtool-frontend/cypress/e2e/0_bootstrap.cy.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/0_bootstrap.cy.ts rename to tests/govtool-frontend/cypress/e2e/0_bootstrap.cy.ts diff --git a/tests/vva-fe/cypress/e2e/1_user_story_wallet_connect.cy.ts b/tests/govtool-frontend/cypress/e2e/1_user_story_wallet_connect.cy.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/1_user_story_wallet_connect.cy.ts rename to tests/govtool-frontend/cypress/e2e/1_user_story_wallet_connect.cy.ts diff --git a/tests/vva-fe/cypress/e2e/2_user_story_delegate_to_drep.cy.ts b/tests/govtool-frontend/cypress/e2e/2_user_story_delegate_to_drep.cy.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/2_user_story_delegate_to_drep.cy.ts rename to tests/govtool-frontend/cypress/e2e/2_user_story_delegate_to_drep.cy.ts diff --git a/tests/vva-fe/cypress/e2e/3_user_story_drep_registration.cy.ts b/tests/govtool-frontend/cypress/e2e/3_user_story_drep_registration.cy.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/3_user_story_drep_registration.cy.ts rename to tests/govtool-frontend/cypress/e2e/3_user_story_drep_registration.cy.ts diff --git a/tests/vva-fe/cypress/e2e/4_user_story_governance_action_visibility.cy.ts b/tests/govtool-frontend/cypress/e2e/4_user_story_governance_action_visibility.cy.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/4_user_story_governance_action_visibility.cy.ts rename to tests/govtool-frontend/cypress/e2e/4_user_story_governance_action_visibility.cy.ts diff --git a/tests/vva-fe/cypress/e2e/5_user_story_governance_action_functionality.cy.ts b/tests/govtool-frontend/cypress/e2e/5_user_story_governance_action_functionality.cy.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/5_user_story_governance_action_functionality.cy.ts rename to tests/govtool-frontend/cypress/e2e/5_user_story_governance_action_functionality.cy.ts diff --git a/tests/vva-fe/cypress/e2e/6_user_story_miscellaneous.cy.ts b/tests/govtool-frontend/cypress/e2e/6_user_story_miscellaneous.cy.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/6_user_story_miscellaneous.cy.ts rename to tests/govtool-frontend/cypress/e2e/6_user_story_miscellaneous.cy.ts diff --git a/tests/vva-fe/cypress/e2e/actions/cleanUpActions.ts b/tests/govtool-frontend/cypress/e2e/actions/cleanUpActions.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/actions/cleanUpActions.ts rename to tests/govtool-frontend/cypress/e2e/actions/cleanUpActions.ts diff --git a/tests/vva-fe/cypress/e2e/actions/commonActions.ts b/tests/govtool-frontend/cypress/e2e/actions/commonActions.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/actions/commonActions.ts rename to tests/govtool-frontend/cypress/e2e/actions/commonActions.ts diff --git a/tests/vva-fe/cypress/e2e/actions/dRepActions.ts b/tests/govtool-frontend/cypress/e2e/actions/dRepActions.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/actions/dRepActions.ts rename to tests/govtool-frontend/cypress/e2e/actions/dRepActions.ts diff --git a/tests/vva-fe/cypress/e2e/actions/delegateActions.ts b/tests/govtool-frontend/cypress/e2e/actions/delegateActions.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/actions/delegateActions.ts rename to tests/govtool-frontend/cypress/e2e/actions/delegateActions.ts diff --git a/tests/vva-fe/cypress/e2e/actions/governanceActions.ts b/tests/govtool-frontend/cypress/e2e/actions/governanceActions.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/actions/governanceActions.ts rename to tests/govtool-frontend/cypress/e2e/actions/governanceActions.ts diff --git a/tests/vva-fe/cypress/e2e/security/7.1_security_overflow_data_headers.cy.ts b/tests/govtool-frontend/cypress/e2e/security/7.1_security_overflow_data_headers.cy.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/security/7.1_security_overflow_data_headers.cy.ts rename to tests/govtool-frontend/cypress/e2e/security/7.1_security_overflow_data_headers.cy.ts diff --git a/tests/vva-fe/cypress/e2e/security/7.3_security_xss.cy.ts b/tests/govtool-frontend/cypress/e2e/security/7.3_security_xss.cy.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/security/7.3_security_xss.cy.ts rename to tests/govtool-frontend/cypress/e2e/security/7.3_security_xss.cy.ts diff --git a/tests/vva-fe/cypress/e2e/security/7.4_sql_injection.cy.ts b/tests/govtool-frontend/cypress/e2e/security/7.4_sql_injection.cy.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/security/7.4_sql_injection.cy.ts rename to tests/govtool-frontend/cypress/e2e/security/7.4_sql_injection.cy.ts diff --git a/tests/vva-fe/cypress/lib/logger/logger.ts b/tests/govtool-frontend/cypress/lib/logger/logger.ts similarity index 100% rename from tests/vva-fe/cypress/lib/logger/logger.ts rename to tests/govtool-frontend/cypress/lib/logger/logger.ts diff --git a/tests/vva-fe/cypress/lib/wallet/blockfrost.ts b/tests/govtool-frontend/cypress/lib/wallet/blockfrost.ts similarity index 100% rename from tests/vva-fe/cypress/lib/wallet/blockfrost.ts rename to tests/govtool-frontend/cypress/lib/wallet/blockfrost.ts diff --git a/tests/vva-fe/cypress/lib/wallet/cardanoWallet.ts b/tests/govtool-frontend/cypress/lib/wallet/cardanoWallet.ts similarity index 100% rename from tests/vva-fe/cypress/lib/wallet/cardanoWallet.ts rename to tests/govtool-frontend/cypress/lib/wallet/cardanoWallet.ts diff --git a/tests/vva-fe/cypress/lib/wallet/crypto.ts b/tests/govtool-frontend/cypress/lib/wallet/crypto.ts similarity index 100% rename from tests/vva-fe/cypress/lib/wallet/crypto.ts rename to tests/govtool-frontend/cypress/lib/wallet/crypto.ts diff --git a/tests/vva-fe/cypress/lib/wallet/mockWallet.ts b/tests/govtool-frontend/cypress/lib/wallet/mockWallet.ts similarity index 100% rename from tests/vva-fe/cypress/lib/wallet/mockWallet.ts rename to tests/govtool-frontend/cypress/lib/wallet/mockWallet.ts diff --git a/tests/vva-fe/cypress/lib/wallet/setupWallet.ts b/tests/govtool-frontend/cypress/lib/wallet/setupWallet.ts similarity index 100% rename from tests/vva-fe/cypress/lib/wallet/setupWallet.ts rename to tests/govtool-frontend/cypress/lib/wallet/setupWallet.ts diff --git a/tests/vva-fe/cypress/lib/wallet/types.ts b/tests/govtool-frontend/cypress/lib/wallet/types.ts similarity index 100% rename from tests/vva-fe/cypress/lib/wallet/types.ts rename to tests/govtool-frontend/cypress/lib/wallet/types.ts diff --git a/tests/vva-fe/cypress/models/types.ts b/tests/govtool-frontend/cypress/models/types.ts similarity index 100% rename from tests/vva-fe/cypress/models/types.ts rename to tests/govtool-frontend/cypress/models/types.ts diff --git a/tests/vva-fe/cypress/services/apiService.ts b/tests/govtool-frontend/cypress/services/apiService.ts similarity index 100% rename from tests/vva-fe/cypress/services/apiService.ts rename to tests/govtool-frontend/cypress/services/apiService.ts diff --git a/tests/vva-fe/cypress/services/blockfrostService.ts b/tests/govtool-frontend/cypress/services/blockfrostService.ts similarity index 100% rename from tests/vva-fe/cypress/services/blockfrostService.ts rename to tests/govtool-frontend/cypress/services/blockfrostService.ts diff --git a/tests/vva-fe/cypress/services/faucetService.ts b/tests/govtool-frontend/cypress/services/faucetService.ts similarity index 100% rename from tests/vva-fe/cypress/services/faucetService.ts rename to tests/govtool-frontend/cypress/services/faucetService.ts diff --git a/tests/vva-fe/cypress/services/kuberService.ts b/tests/govtool-frontend/cypress/services/kuberService.ts similarity index 100% rename from tests/vva-fe/cypress/services/kuberService.ts rename to tests/govtool-frontend/cypress/services/kuberService.ts diff --git a/tests/vva-fe/cypress/services/types.ts b/tests/govtool-frontend/cypress/services/types.ts similarity index 100% rename from tests/vva-fe/cypress/services/types.ts rename to tests/govtool-frontend/cypress/services/types.ts diff --git a/tests/vva-fe/cypress/state/store.ts b/tests/govtool-frontend/cypress/state/store.ts similarity index 100% rename from tests/vva-fe/cypress/state/store.ts rename to tests/govtool-frontend/cypress/state/store.ts diff --git a/tests/vva-fe/cypress/state/type.ts b/tests/govtool-frontend/cypress/state/type.ts similarity index 100% rename from tests/vva-fe/cypress/state/type.ts rename to tests/govtool-frontend/cypress/state/type.ts diff --git a/tests/vva-fe/cypress/state/walletState.ts b/tests/govtool-frontend/cypress/state/walletState.ts similarity index 100% rename from tests/vva-fe/cypress/state/walletState.ts rename to tests/govtool-frontend/cypress/state/walletState.ts diff --git a/tests/vva-fe/cypress/support/command.d.ts b/tests/govtool-frontend/cypress/support/command.d.ts similarity index 100% rename from tests/vva-fe/cypress/support/command.d.ts rename to tests/govtool-frontend/cypress/support/command.d.ts diff --git a/tests/vva-fe/cypress/support/commands.ts b/tests/govtool-frontend/cypress/support/commands.ts similarity index 100% rename from tests/vva-fe/cypress/support/commands.ts rename to tests/govtool-frontend/cypress/support/commands.ts diff --git a/tests/vva-fe/cypress/support/e2e.ts b/tests/govtool-frontend/cypress/support/e2e.ts similarity index 100% rename from tests/vva-fe/cypress/support/e2e.ts rename to tests/govtool-frontend/cypress/support/e2e.ts diff --git a/tests/vva-fe/cypress/support/utils.ts b/tests/govtool-frontend/cypress/support/utils.ts similarity index 100% rename from tests/vva-fe/cypress/support/utils.ts rename to tests/govtool-frontend/cypress/support/utils.ts diff --git a/tests/vva-fe/cypress/support/validations.ts b/tests/govtool-frontend/cypress/support/validations.ts similarity index 100% rename from tests/vva-fe/cypress/support/validations.ts rename to tests/govtool-frontend/cypress/support/validations.ts diff --git a/tests/vva-fe/package.json b/tests/govtool-frontend/package.json similarity index 95% rename from tests/vva-fe/package.json rename to tests/govtool-frontend/package.json index cdfc3ca38..89136b905 100644 --- a/tests/vva-fe/package.json +++ b/tests/govtool-frontend/package.json @@ -1,5 +1,5 @@ { - "name": "vva-fe-test", + "name": "govtool-frontend-test", "version": "1.0.0", "main": "index.js", "license": "MIT", diff --git a/tests/vva-fe/tsconfig.json b/tests/govtool-frontend/tsconfig.json similarity index 100% rename from tests/vva-fe/tsconfig.json rename to tests/govtool-frontend/tsconfig.json diff --git a/tests/vva-fe/yarn.lock b/tests/govtool-frontend/yarn.lock similarity index 100% rename from tests/vva-fe/yarn.lock rename to tests/govtool-frontend/yarn.lock diff --git a/tests/load-testing/pom.xml b/tests/load-testing/pom.xml index 27cf38a59..f79842b88 100644 --- a/tests/load-testing/pom.xml +++ b/tests/load-testing/pom.xml @@ -2,8 +2,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - io.gatling.vva - vva-be + io.gatling.govtool + govtool-backend 0.0.1 @@ -86,7 +86,7 @@ - + diff --git a/tests/load-testing/src/test/java/org/cardano/vva/ApiService.java b/tests/load-testing/src/test/java/org/cardano/govtool/ApiService.java similarity index 98% rename from tests/load-testing/src/test/java/org/cardano/vva/ApiService.java rename to tests/load-testing/src/test/java/org/cardano/govtool/ApiService.java index a32b3cd86..20fed22a4 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/ApiService.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/ApiService.java @@ -1,4 +1,4 @@ -package org.cardano.vva; +package org.cardano.govtool; import io.gatling.javaapi.core.ChainBuilder; diff --git a/tests/load-testing/src/test/java/org/cardano/vva/Engine.java b/tests/load-testing/src/test/java/org/cardano/govtool/Engine.java similarity index 94% rename from tests/load-testing/src/test/java/org/cardano/vva/Engine.java rename to tests/load-testing/src/test/java/org/cardano/govtool/Engine.java index 36f40d19b..3139c4f92 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/Engine.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/Engine.java @@ -1,4 +1,4 @@ -package org.cardano.vva; +package org.cardano.govtool; import io.gatling.app.Gatling; import io.gatling.core.config.GatlingPropertiesBuilder; diff --git a/tests/load-testing/src/test/java/org/cardano/vva/IDEPathHelper.java b/tests/load-testing/src/test/java/org/cardano/govtool/IDEPathHelper.java similarity index 95% rename from tests/load-testing/src/test/java/org/cardano/vva/IDEPathHelper.java rename to tests/load-testing/src/test/java/org/cardano/govtool/IDEPathHelper.java index e5ba43868..785768d8a 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/IDEPathHelper.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/IDEPathHelper.java @@ -1,4 +1,4 @@ -package org.cardano.vva; +package org.cardano.govtool; import java.net.URISyntaxException; import java.nio.file.Path; @@ -19,7 +19,7 @@ public class IDEPathHelper { Path mavenTargetDirectory = projectRootDir.resolve("target"); Path mavenSrcTestDirectory = projectRootDir.resolve("src").resolve("test"); - mavenSourcesDirectory = mavenSrcTestDirectory.resolve("java/org/cardano/vva"); + mavenSourcesDirectory = mavenSrcTestDirectory.resolve("java/org/cardano/govtool"); mavenResourcesDirectory = mavenSrcTestDirectory.resolve("resources"); mavenBinariesDirectory = mavenTargetDirectory.resolve("test-classes"); resultsDirectory = mavenTargetDirectory.resolve("gatling"); diff --git a/tests/load-testing/src/test/java/org/cardano/vva/Recorder.java b/tests/load-testing/src/test/java/org/cardano/govtool/Recorder.java similarity index 95% rename from tests/load-testing/src/test/java/org/cardano/vva/Recorder.java rename to tests/load-testing/src/test/java/org/cardano/govtool/Recorder.java index 777413128..36807523e 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/Recorder.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/Recorder.java @@ -1,4 +1,4 @@ -package org.cardano.vva; +package org.cardano.govtool; import io.gatling.recorder.GatlingRecorder; import io.gatling.recorder.config.RecorderPropertiesBuilder; diff --git a/tests/load-testing/src/test/java/org/cardano/vva/Scenario.java b/tests/load-testing/src/test/java/org/cardano/govtool/Scenario.java similarity index 88% rename from tests/load-testing/src/test/java/org/cardano/vva/Scenario.java rename to tests/load-testing/src/test/java/org/cardano/govtool/Scenario.java index f8640ab67..32fc360ab 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/Scenario.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/Scenario.java @@ -1,10 +1,10 @@ -package org.cardano.vva; +package org.cardano.govtool; import io.gatling.javaapi.core.ScenarioBuilder; -import org.cardano.vva.actions.Action; -import org.cardano.vva.actions.AdaHolderAction; -import org.cardano.vva.actions.AuthenticationAction; -import org.cardano.vva.actions.DRepAction; +import org.cardano.govtool.actions.Action; +import org.cardano.govtool.actions.AdaHolderAction; +import org.cardano.govtool.actions.AuthenticationAction; +import org.cardano.govtool.actions.DRepAction; import static io.gatling.javaapi.core.CoreDsl.scenario; diff --git a/tests/load-testing/src/test/java/org/cardano/vva/Test.java b/tests/load-testing/src/test/java/org/cardano/govtool/Test.java similarity index 95% rename from tests/load-testing/src/test/java/org/cardano/vva/Test.java rename to tests/load-testing/src/test/java/org/cardano/govtool/Test.java index b83ffa0b4..6162f7e56 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/Test.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/Test.java @@ -1,4 +1,4 @@ -package org.cardano.vva; +package org.cardano.govtool; public class Test { public static void main(String[] args) { diff --git a/tests/load-testing/src/test/java/org/cardano/vva/Utils.java b/tests/load-testing/src/test/java/org/cardano/govtool/Utils.java similarity index 97% rename from tests/load-testing/src/test/java/org/cardano/vva/Utils.java rename to tests/load-testing/src/test/java/org/cardano/govtool/Utils.java index 22952667c..a68f38ff0 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/Utils.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/Utils.java @@ -1,4 +1,4 @@ -package org.cardano.vva; +package org.cardano.govtool; import org.bouncycastle.crypto.digests.Blake2bDigest; import org.bouncycastle.util.encoders.Hex; diff --git a/tests/load-testing/src/test/java/org/cardano/vva/actions/Action.java b/tests/load-testing/src/test/java/org/cardano/govtool/actions/Action.java similarity index 82% rename from tests/load-testing/src/test/java/org/cardano/vva/actions/Action.java rename to tests/load-testing/src/test/java/org/cardano/govtool/actions/Action.java index 116b54fca..a29f798fe 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/actions/Action.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/actions/Action.java @@ -1,7 +1,7 @@ -package org.cardano.vva.actions; +package org.cardano.govtool.actions; import io.gatling.javaapi.core.ChainBuilder; -import org.cardano.vva.ApiService; +import org.cardano.govtool.ApiService; import static io.gatling.javaapi.core.CoreDsl.*; diff --git a/tests/load-testing/src/test/java/org/cardano/vva/actions/AdaHolderAction.java b/tests/load-testing/src/test/java/org/cardano/govtool/actions/AdaHolderAction.java similarity index 73% rename from tests/load-testing/src/test/java/org/cardano/vva/actions/AdaHolderAction.java rename to tests/load-testing/src/test/java/org/cardano/govtool/actions/AdaHolderAction.java index 37ee937ba..437202bcf 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/actions/AdaHolderAction.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/actions/AdaHolderAction.java @@ -1,9 +1,9 @@ -package org.cardano.vva.actions; +package org.cardano.govtool.actions; -import org.cardano.vva.ApiService; -import org.cardano.vva.configs.HeaderConfig; +import org.cardano.govtool.ApiService; +import org.cardano.govtool.configs.HeaderConfig; import io.gatling.javaapi.core.ChainBuilder; -import org.cardano.vva.feeders.RandomDataFeeder; +import org.cardano.govtool.feeders.RandomDataFeeder; import static io.gatling.javaapi.core.CoreDsl.*; diff --git a/tests/load-testing/src/test/java/org/cardano/vva/actions/AuthenticationAction.java b/tests/load-testing/src/test/java/org/cardano/govtool/actions/AuthenticationAction.java similarity index 83% rename from tests/load-testing/src/test/java/org/cardano/vva/actions/AuthenticationAction.java rename to tests/load-testing/src/test/java/org/cardano/govtool/actions/AuthenticationAction.java index 456bd2d05..fb46e53e4 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/actions/AuthenticationAction.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/actions/AuthenticationAction.java @@ -1,8 +1,8 @@ -package org.cardano.vva.actions; +package org.cardano.govtool.actions; import io.gatling.javaapi.core.ChainBuilder; -import org.cardano.vva.ApiService; -import org.cardano.vva.feeders.RandomDataFeeder; +import org.cardano.govtool.ApiService; +import org.cardano.govtool.feeders.RandomDataFeeder; import java.util.UUID; diff --git a/tests/load-testing/src/test/java/org/cardano/vva/actions/DRepAction.java b/tests/load-testing/src/test/java/org/cardano/govtool/actions/DRepAction.java similarity index 91% rename from tests/load-testing/src/test/java/org/cardano/vva/actions/DRepAction.java rename to tests/load-testing/src/test/java/org/cardano/govtool/actions/DRepAction.java index b3073b939..1860f6130 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/actions/DRepAction.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/actions/DRepAction.java @@ -1,7 +1,7 @@ -package org.cardano.vva.actions; +package org.cardano.govtool.actions; -import org.cardano.vva.ApiService; -import org.cardano.vva.feeders.RandomDataFeeder; +import org.cardano.govtool.ApiService; +import org.cardano.govtool.feeders.RandomDataFeeder; import io.gatling.javaapi.core.ChainBuilder; import static io.gatling.javaapi.core.CoreDsl.*; diff --git a/tests/load-testing/src/test/java/org/cardano/vva/configs/HeaderConfig.java b/tests/load-testing/src/test/java/org/cardano/govtool/configs/HeaderConfig.java similarity index 84% rename from tests/load-testing/src/test/java/org/cardano/vva/configs/HeaderConfig.java rename to tests/load-testing/src/test/java/org/cardano/govtool/configs/HeaderConfig.java index c0f1e41dd..c54b047a0 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/configs/HeaderConfig.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/configs/HeaderConfig.java @@ -1,4 +1,4 @@ -package org.cardano.vva.configs; +package org.cardano.govtool.configs; import java.util.Map; diff --git a/tests/load-testing/src/test/java/org/cardano/vva/feeders/RandomDataFeeder.java b/tests/load-testing/src/test/java/org/cardano/govtool/feeders/RandomDataFeeder.java similarity index 95% rename from tests/load-testing/src/test/java/org/cardano/vva/feeders/RandomDataFeeder.java rename to tests/load-testing/src/test/java/org/cardano/govtool/feeders/RandomDataFeeder.java index c9e0d64d6..80d35520b 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/feeders/RandomDataFeeder.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/feeders/RandomDataFeeder.java @@ -1,6 +1,6 @@ -package org.cardano.vva.feeders; +package org.cardano.govtool.feeders; -import org.cardano.vva.Utils; +import org.cardano.govtool.Utils; import java.util.Collections; import java.util.Iterator; diff --git a/tests/load-testing/src/test/java/org/cardano/vva/simulations/VvaSimulation.java b/tests/load-testing/src/test/java/org/cardano/govtool/simulations/VvaSimulation.java similarity index 98% rename from tests/load-testing/src/test/java/org/cardano/vva/simulations/VvaSimulation.java rename to tests/load-testing/src/test/java/org/cardano/govtool/simulations/VvaSimulation.java index 0fbbe2609..ff61cf533 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/simulations/VvaSimulation.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/simulations/VvaSimulation.java @@ -1,6 +1,6 @@ -package org.cardano.vva.simulations; +package org.cardano.govtool.simulations; -import org.cardano.vva.Scenario; +import org.cardano.govtool.Scenario; import io.gatling.javaapi.core.Simulation; import io.gatling.javaapi.http.HttpProtocolBuilder; diff --git a/tests/load-testing/src/test/resources/gatling.conf b/tests/load-testing/src/test/resources/gatling.conf index 1fcefc33b..48104c3d7 100644 --- a/tests/load-testing/src/test/resources/gatling.conf +++ b/tests/load-testing/src/test/resources/gatling.conf @@ -31,7 +31,7 @@ gatling { } } directory { - #org.cardano.vva.simulations = "" # If set, directory where simulation classes are located + #org.cardano.govtool.simulations = "" # If set, directory where simulation classes are located #resources = "" # If set, directory where resources, such as feeder files and request bodies, are located #reportsOnly = "" # If set, name of report folder to look for in order to generate its report #binaries = "" # If set, name of the folder where compiles classes are located: Defaults to GATLING_HOME/target. diff --git a/tests/load-testing/src/test/resources/recorder.conf b/tests/load-testing/src/test/resources/recorder.conf index 8db3ade3e..00808757c 100644 --- a/tests/load-testing/src/test/resources/recorder.conf +++ b/tests/load-testing/src/test/resources/recorder.conf @@ -6,15 +6,15 @@ recorder { # package = "" # The package's name of the generated simulation # className = "RecordedSimulation" # The name of the generated Simulation class # thresholdForPauseCreation = 100 # The minimum time, in milliseconds, that must pass between requests to trigger a pause creation - # saveConfig = false # When set to true, the configuration from the org.cardano.vva.Recorder GUI overwrites this configuration - # headless = false # When set to true, run the org.cardano.vva.Recorder in headless mode instead of the GUI + # saveConfig = false # When set to true, the configuration from the org.cardano.govtool.Recorder GUI overwrites this configuration + # headless = false # When set to true, run the org.cardano.govtool.Recorder in headless mode instead of the GUI # harFilePath = "" # The path of the HAR file to convert # format = "java8" # java8|java11|java17|kotlin|scala } filters { # enable = false # If filters are enabled - # allowList = [] # The list of ressources patterns that are part of the org.cardano.vva.Recorder's allow list - # denyList = [] # The list of ressources patterns that are part of the org.cardano.vva.Recorder's deny list + # allowList = [] # The list of ressources patterns that are part of the org.cardano.govtool.Recorder's allow list + # denyList = [] # The list of ressources patterns that are part of the org.cardano.govtool.Recorder's deny list } http { # automaticReferer = true # When set to false, write the referer + enable 'disableAutoReferer' in the generated simulation diff --git a/tests/test-infrastructure/.env.example b/tests/test-infrastructure/.env.example index 15cc6dc9d..fd9687eeb 100644 --- a/tests/test-infrastructure/.env.example +++ b/tests/test-infrastructure/.env.example @@ -1,4 +1,4 @@ -STACK_NAME=vva +STACK_NAME=govtool BASE_DOMAIN=cardanoapi.io BLOCKFROST_API_URL="" -BLOCKFROST_PROJECT_ID="" \ No newline at end of file +BLOCKFROST_PROJECT_ID="" diff --git a/tests/test-infrastructure/README.md b/tests/test-infrastructure/README.md index c69268078..99a872d26 100644 --- a/tests/test-infrastructure/README.md +++ b/tests/test-infrastructure/README.md @@ -1,7 +1,7 @@ -VVA Test Infrastructure +GovTool Test Infrastructure ==================== -Services required for testing VVA +Services required for testing GovTool ## 1. Setting up the services @@ -23,7 +23,7 @@ There's a helper script `deploy-swarm.sh` to load the environment variables from cd ./test/test-infrastructire # cd into the test-infrastructure folder docker swarm init # if swarm mode is not enabled yet. docker compose build # build the images -docker node update xxxx --label-add vva-test-stack=true ## set the node to be used for deploying the services +docker node update xxxx --label-add govtool-test-stack=true ## set the node to be used for deploying the services ./gen-configs.sh # generate configs and secrets. ./deploy-swarm.sh prepare # start postgres and nginx sleep 30 # wait for 30 secs for postgres to be healthy @@ -57,7 +57,7 @@ The analysis generated by sonar-scanner is saved to SonarQube server for better username: admin password: admin ``` -- Create new project and set the projectKey in file [src/vva-fe/sonar-project.properties](../../src/vva-fe/sonar-project.properties) +- Create new project and set the projectKey in file [govtool/frontend/sonar-project.properties](../../govtool/frontend/sonar-project.properties) - Update the github action secrets - SONAR_HOST_URL - SONAR_TOKEN @@ -74,7 +74,7 @@ It is used for visualizing the test metrics and the api response times over time ### Initial Configuration - Setup initial account for ligin via the webapp. - - Under database section in admin settings, add the `vva_lithghouse` and `vva_metrics` databases + - Under database section in admin settings, add the `govtool_lithghouse` and `govtool_metrics` databases - Select the database and add visualizations, queries for the data. ## LightHouse Report Server @@ -131,4 +131,4 @@ Kuber makes it easy to construct and submit transaction from the frontend. **Docker Image:** [dquadrant/kuber:70be9b0166177eab5cf33e603fd3dc579e14cf31](https://hub.docker.com/layers/dquadrant/kuber/70be9b0166177eab5cf33e603fd3dc579e14cf31/images/sha256-d3b3f7c2304da8c4777155b26220238b682c81a3ff2b14753a5dc41c4f151364?context=explore) ### Initial Configuration -- update `CYPRESS_kuberApiUrl` variable in [.github/workflows/test_integration_cypress.yml](../../.github/workflows/test_integration_cypress.yml) \ No newline at end of file +- update `CYPRESS_kuberApiUrl` variable in [.github/workflows/test_integration_cypress.yml](../../.github/workflows/test_integration_cypress.yml) diff --git a/tests/test-infrastructure/deploy-swarm.sh b/tests/test-infrastructure/deploy-swarm.sh index 6b20e2ab1..0c94386a8 100755 --- a/tests/test-infrastructure/deploy-swarm.sh +++ b/tests/test-infrastructure/deploy-swarm.sh @@ -39,7 +39,7 @@ then elif [ "$1" == "finalize" ] then ## apply the environment to compose file - ## deploy the vva test infrastructure stack + ## deploy the govtool test infrastructure stack envsubst < ./docker-compose.yml > ./docker-compose-rendered.yml docker stack deploy -c './docker-compose-rendered.yml' ${STACK_NAME} else diff --git a/tests/test-infrastructure/docker-compose-services.yml b/tests/test-infrastructure/docker-compose-services.yml index 9a2d3421e..d7563a2ad 100644 --- a/tests/test-infrastructure/docker-compose-services.yml +++ b/tests/test-infrastructure/docker-compose-services.yml @@ -54,7 +54,7 @@ services: deploy: placement: constraints: - - node.labels.vva-test-stack == true + - node.labels.govtool-test-stack == true restart_policy: delay: "10s" postgres: @@ -83,6 +83,6 @@ services: deploy: placement: constraints: - - node.labels.vva-test-stack == true + - node.labels.govtool-test-stack == true restart_policy: - delay: "30s" \ No newline at end of file + delay: "30s" diff --git a/tests/test-infrastructure/docker-compose.yml b/tests/test-infrastructure/docker-compose.yml index 995465b37..918fba7dc 100644 --- a/tests/test-infrastructure/docker-compose.yml +++ b/tests/test-infrastructure/docker-compose.yml @@ -61,7 +61,7 @@ services: deploy: placement: constraints: - - node.labels.vva-test-stack == true + - node.labels.govtool-test-stack == true restart_policy: delay: "30s" resources: @@ -77,7 +77,7 @@ services: retries: 5 metrics_api: - image: voltaire-era/vva-metrics-api + image: voltaire-era/govtool-metrics-api build: context: ../test-metrics-api @@ -98,7 +98,7 @@ services: deploy: placement: constraints: - - node.labels.vva-test-stack == true + - node.labels.govtool-test-stack == true restart_policy: delay: "30s" resources: @@ -122,7 +122,7 @@ services: deploy: placement: constraints: - - node.labels.vva-test-stack == true + - node.labels.govtool-test-stack == true restart_policy: delay: "30s" resources: @@ -132,18 +132,18 @@ services: memory: 300M governance-action-loader-ui: - image: voltaire-era/vva-governance-action-loader + image: voltaire-era/govtool-governance-action-loader build: context: ../../src/gov-action-loader-fe dockerfile: Dockerfile environment: - VIRTUAL_HOST: https://vva-governance.${BASE_DOMAIN} + VIRTUAL_HOST: https://govtool-governance.${BASE_DOMAIN} networks: - frontend deploy: placement: constraints: - - node.labels.vva-test-stack == true + - node.labels.govtool-test-stack == true restart_policy: delay: "30s" resources: @@ -153,7 +153,7 @@ services: memory: 100M governance-action-loader-api: - image: voltaire-era/vva-kuber-proposal-loader-proxy + image: voltaire-era/govtool-kuber-proposal-loader-proxy build: context: ../../src/gov-action-loader-be dockerfile: Dockerfile @@ -162,14 +162,14 @@ services: KUBER_API_KEY: "" BLOCKFROST_API_URL: "${BLOCKFROST_API_URL}" BLOCKFROST_PROJECT_ID: "${BLOCKFROST_PROJECT_ID}" - VIRTUAL_HOST: https://vva-governance.${BASE_DOMAIN}/api/ -> /api/ + VIRTUAL_HOST: https://govtool-governance.${BASE_DOMAIN}/api/ -> /api/ networks: - default - frontend deploy: placement: constraints: - - node.labels.vva-test-stack == true + - node.labels.govtool-test-stack == true restart_policy: delay: "30s" resources: @@ -196,7 +196,7 @@ services: deploy: placement: constraints: - - node.labels.vva-test-stack == true + - node.labels.govtool-test-stack == true restart_policy: delay: 15s resources: @@ -225,7 +225,7 @@ services: deploy: placement: constraints: - - node.labels.vva-test-stack == true + - node.labels.govtool-test-stack == true restart_policy: condition: on-failure delay: 15s @@ -241,7 +241,7 @@ services: deploy: placement: constraints: - - node.labels.vva-test-stack == true + - node.labels.govtool-test-stack == true restart_policy: delay: "30s" diff --git a/tests/test-infrastructure/gen-configs.sh b/tests/test-infrastructure/gen-configs.sh index da98fbf4f..b92d6d65d 100755 --- a/tests/test-infrastructure/gen-configs.sh +++ b/tests/test-infrastructure/gen-configs.sh @@ -44,9 +44,9 @@ if [ "$1" == "clean" ]; then fi ## Check if one fo the secrets already exists -if [[ -f ./secrets/vva_postgres_user ]] +if [[ -f ./secrets/govtool_postgres_user ]] then - echo "File ./secrets/vva_postgres_user already exists." + echo "File ./secrets/govtool_postgres_user already exists." echo "Assuming that the secrets were already generated" echo " Use:" echo " > ./gen-configs.sh clean" @@ -60,9 +60,9 @@ mkdir -p ./secrets; ## save secrets to secrets folder -echo -n $POSTGRES_USER > ./secrets/vva_postgres_user -echo -n $POSTGRES_PASSWORD > ./secrets/vva_postgres_password -echo -n $metrics_api_secret > ./secrets/vva_metrics_api_secret +echo -n $POSTGRES_USER > ./secrets/govtool_postgres_user +echo -n $POSTGRES_PASSWORD > ./secrets/govtool_postgres_password +echo -n $metrics_api_secret > ./secrets/govtool_metrics_api_secret ## loop over templates and updaete them. @@ -108,4 +108,4 @@ for SECRET_FILE in $(ls ./secrets_template) do echo -n "Creating Secret: ${STACK_NAME}_${SECRET_FILE} " cat "./secrets/${STACK_NAME}_${SECRET_FILE}" | docker secret create "${STACK_NAME}_${SECRET_FILE}" - ||true -done \ No newline at end of file +done diff --git a/tests/test-metrics-api/.env.example b/tests/test-metrics-api/.env.example index 6300825a2..ab6a5e93d 100644 --- a/tests/test-metrics-api/.env.example +++ b/tests/test-metrics-api/.env.example @@ -1,6 +1,6 @@ PGHOST='office.sireto.dev' PGPORT=8080 -PGDATABASE='vva' +PGDATABASE='govtool' PGUSER='postgres' PGPASSWORD='your password' API_SECRET_TOKEN='some-token' diff --git a/tests/test-metrics-api/README.md b/tests/test-metrics-api/README.md index e8a176c7f..5526d0adb 100644 --- a/tests/test-metrics-api/README.md +++ b/tests/test-metrics-api/README.md @@ -1,6 +1,6 @@ # Test Metrics API -This api is intended to be called by Github Action whenever a new commit to vva app has been made and new metrics are obtained. The api expects a POST request with a JSON file of the metrics which will then update the database with the new metrics. +This api is intended to be called by Github Action whenever a new commit to GovTool app has been made and new metrics are obtained. The api expects a POST request with a JSON file of the metrics which will then update the database with the new metrics. ## Prerequisite diff --git a/tests/vva-be/test_cases/test_ada_holder.py b/tests/vva-be/test_cases/test_ada_holder.py deleted file mode 100644 index 963b42b72..000000000 --- a/tests/vva-be/test_cases/test_ada_holder.py +++ /dev/null @@ -1,14 +0,0 @@ -from models.TestData import AdaHolder, Delegation - -def test_ada_delegation(vva_api, ada_holder_delegate_to_drep): - print(ada_holder_delegate_to_drep) - response = vva_api.ada_holder_get_current_delegation(ada_holder_delegate_to_drep["stakeKey"]) - resp = response.json() - if resp: - assert ada_holder_delegate_to_drep["drepId"] in resp - - -def test_check_voting_power(vva_api, ada_holder_delegate_to_drep): - response = vva_api.ada_holder_get_voting_power(ada_holder_delegate_to_drep["stakeKey"]) - ada_holder_voting_power = response.json() - assert isinstance(ada_holder_voting_power, int) From 3535e10e7c984e5eed7cf32fd8f2147e157737b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Sworze=C5=84?= Date: Fri, 9 Feb 2024 17:51:25 +0100 Subject: [PATCH 03/20] change input atom --- .../frontend/src/components/atoms/Input.tsx | 94 ++++--------------- 1 file changed, 17 insertions(+), 77 deletions(-) diff --git a/govtool/frontend/src/components/atoms/Input.tsx b/govtool/frontend/src/components/atoms/Input.tsx index f45ea20bd..e5261a112 100644 --- a/govtool/frontend/src/components/atoms/Input.tsx +++ b/govtool/frontend/src/components/atoms/Input.tsx @@ -1,90 +1,30 @@ import { useId } from "react"; -import { Control, Controller } from "react-hook-form"; -import { Box, InputBase, InputBaseProps } from "@mui/material"; +import { InputBase } from "@mui/material"; -import { Typography } from "."; - -interface Props extends InputBaseProps { - control: Control; - formFieldName: string; - label?: string; - errorMessage?: string; - dataTestId?: string; - placeholder?: string; - width?: string; - marginTop?: string; - marginBottom?: string; -} +import { InputProps } from "./types"; export const Input = ({ - control, - formFieldName, errorMessage, - label, - placeholder, - disabled, - type = "text", - width, - marginTop, - marginBottom, dataTestId, + sx, ...rest -}: Props) => { +}: InputProps) => { const id = useId(); return ( - ( - - {label && ( - - {label} - - )} - - - {errorMessage && ( - - {errorMessage} - - )} - - - )} + ); }; From 05362ec59faa7267c99dedfdcf2b63ce02339492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Sworze=C5=84?= Date: Fri, 9 Feb 2024 17:51:57 +0100 Subject: [PATCH 04/20] create input field as molecule --- .../src/components/molecules/Field/Input.tsx | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 govtool/frontend/src/components/molecules/Field/Input.tsx diff --git a/govtool/frontend/src/components/molecules/Field/Input.tsx b/govtool/frontend/src/components/molecules/Field/Input.tsx new file mode 100644 index 000000000..a99508c3c --- /dev/null +++ b/govtool/frontend/src/components/molecules/Field/Input.tsx @@ -0,0 +1,38 @@ +import { Box } from "@mui/material"; + +import { Input as InputBase, Typography } from "@atoms"; + +import { InputFieldProps } from "./types"; + +export const Input = ({ + errorMessage, + errorStyle, + label, + labelStyle, + layoutStyle, + ...rest +}: InputFieldProps) => { + return ( + + {label && ( + + {label} + + )} + + {errorMessage && ( + + {errorMessage} + + )} + + ); +}; From ceb29e1433dcab8964b0aae932aed8e43ab067e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Sworze=C5=84?= Date: Fri, 9 Feb 2024 17:52:33 +0100 Subject: [PATCH 05/20] export Field from molecules --- .../src/components/molecules/Field/index.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 govtool/frontend/src/components/molecules/Field/index.tsx diff --git a/govtool/frontend/src/components/molecules/Field/index.tsx b/govtool/frontend/src/components/molecules/Field/index.tsx new file mode 100644 index 000000000..3589cd9c9 --- /dev/null +++ b/govtool/frontend/src/components/molecules/Field/index.tsx @@ -0,0 +1,17 @@ +import React, { PropsWithChildren } from "react"; + +import { Input } from "./Input"; + +type FieldComposition = React.FC & { + Input: typeof Input; +}; + +const Field: FieldComposition = ({ children }) => { + return {children}; +}; + +Field.Input = Input; + +export { Field }; + +export * from "./types"; From 863e49bc516b6fd35c32e924e779c6b75144aa1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Sworze=C5=84?= Date: Fri, 9 Feb 2024 17:53:50 +0100 Subject: [PATCH 06/20] create ControlledField who includes Input/ export it --- .../organisms/ControlledField/Input.tsx | 32 +++++++++++++++++++ .../organisms/ControlledField/index.tsx | 15 +++++++++ 2 files changed, 47 insertions(+) create mode 100644 govtool/frontend/src/components/organisms/ControlledField/Input.tsx create mode 100644 govtool/frontend/src/components/organisms/ControlledField/index.tsx diff --git a/govtool/frontend/src/components/organisms/ControlledField/Input.tsx b/govtool/frontend/src/components/organisms/ControlledField/Input.tsx new file mode 100644 index 000000000..a58d4c91d --- /dev/null +++ b/govtool/frontend/src/components/organisms/ControlledField/Input.tsx @@ -0,0 +1,32 @@ +import { useCallback } from "react"; +import { Controller, get } from "react-hook-form"; + +import { Field } from "@molecules"; + +import { ControlledInputProps, RenderInputProps } from "./types"; + +export const Input = ({ + control, + name, + errors, + rules, + ...props +}: ControlledInputProps) => { + const errorMessage = get(errors, name)?.message as string; + + const renderInput = useCallback( + ({ field }: RenderInputProps) => ( + + ), + [errorMessage, props] + ); + + return ( + + ); +}; diff --git a/govtool/frontend/src/components/organisms/ControlledField/index.tsx b/govtool/frontend/src/components/organisms/ControlledField/index.tsx new file mode 100644 index 000000000..f3b8bbd83 --- /dev/null +++ b/govtool/frontend/src/components/organisms/ControlledField/index.tsx @@ -0,0 +1,15 @@ +import React, { PropsWithChildren } from "react"; + +import { Input } from "./Input"; + +type ControlledFieldComposition = React.FC & { + Input: typeof Input; +}; + +const ControlledField: ControlledFieldComposition = ({ children }) => { + return <>{children}; +}; + +ControlledField.Input = Input; + +export { ControlledField }; From 776042b175200caaaa8b30458080b57155db0f39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Sworze=C5=84?= Date: Fri, 9 Feb 2024 17:54:38 +0100 Subject: [PATCH 07/20] create types --- .../frontend/src/components/atoms/index.ts | 3 ++ .../frontend/src/components/atoms/types.ts | 43 +++++++++++++++++++ .../src/components/molecules/Field/types.ts | 11 +++++ .../src/components/molecules/index.ts | 1 + .../organisms/ControlledField/types.ts | 20 +++++++++ .../src/components/organisms/index.ts | 2 + 6 files changed, 80 insertions(+) create mode 100644 govtool/frontend/src/components/atoms/types.ts create mode 100644 govtool/frontend/src/components/molecules/Field/types.ts create mode 100644 govtool/frontend/src/components/organisms/ControlledField/types.ts diff --git a/govtool/frontend/src/components/atoms/index.ts b/govtool/frontend/src/components/atoms/index.ts index 2b3428352..fd9d803e1 100644 --- a/govtool/frontend/src/components/atoms/index.ts +++ b/govtool/frontend/src/components/atoms/index.ts @@ -21,4 +21,7 @@ export * from "./Typography"; export * from "./VotePill"; export * from "./VotingPowerChips"; export * from "./Input"; +export * from "./Spacer"; export * from "./HighlightedText"; + +export * from "./types"; diff --git a/govtool/frontend/src/components/atoms/types.ts b/govtool/frontend/src/components/atoms/types.ts new file mode 100644 index 000000000..4784ad44e --- /dev/null +++ b/govtool/frontend/src/components/atoms/types.ts @@ -0,0 +1,43 @@ +import { + ButtonProps as MUIButtonProps, + InputBaseProps, + TypographyProps as MUITypographyProps, +} from "@mui/material"; + +export type ButtonProps = Omit & { + size?: "small" | "medium" | "large" | "extraLarge"; +}; + +export type LoadingButtonProps = ButtonProps & { + isLoading?: boolean; +}; + +export type TypographyProps = Pick< + MUITypographyProps, + "color" | "lineHeight" | "sx" +> & { + children?: React.ReactNode; + fontSize?: number; + fontWeight?: 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900; + variant?: + | "headline1" + | "headline2" + | "headline3" + | "headline4" + | "headline5" + | "title1" + | "title2" + | "body1" + | "body2" + | "caption"; +}; + +export type InputProps = InputBaseProps & { + dataTestId?: string; + errorMessage?: string; +}; + +export type SpacerProps = { + x?: number; + y?: number; +}; diff --git a/govtool/frontend/src/components/molecules/Field/types.ts b/govtool/frontend/src/components/molecules/Field/types.ts new file mode 100644 index 000000000..878f6800f --- /dev/null +++ b/govtool/frontend/src/components/molecules/Field/types.ts @@ -0,0 +1,11 @@ +import { BoxProps } from "@mui/material"; + +import { InputProps, TypographyProps } from "@atoms"; + +export type InputFieldProps = InputProps & { + errorMessage?: string; + errorStyle?: TypographyProps; + label?: string; + labelStyle?: TypographyProps; + layoutStyle?: BoxProps; +}; diff --git a/govtool/frontend/src/components/molecules/index.ts b/govtool/frontend/src/components/molecules/index.ts index 61171332c..4fc87340a 100644 --- a/govtool/frontend/src/components/molecules/index.ts +++ b/govtool/frontend/src/components/molecules/index.ts @@ -2,6 +2,7 @@ export * from "./ActionCard"; export * from "./DashboardActionCard"; export * from "./DataActionsBar"; export * from "./DRepInfoCard"; +export * from "./Field"; export * from "./GovActionDetails"; export * from "./GovernanceActionCard"; export * from "./GovernanceActionsFilters"; diff --git a/govtool/frontend/src/components/organisms/ControlledField/types.ts b/govtool/frontend/src/components/organisms/ControlledField/types.ts new file mode 100644 index 000000000..9f539b279 --- /dev/null +++ b/govtool/frontend/src/components/organisms/ControlledField/types.ts @@ -0,0 +1,20 @@ +import { InputFieldProps } from "@molecules"; +import { + Control, + ControllerRenderProps, + FieldErrors, + FieldValues, + Path, + RegisterOptions, +} from "react-hook-form"; + +export type ControlledInputProps = InputFieldProps & { + name: Path; + control: Control; + errors: FieldErrors; + rules?: Omit; +}; + +export type RenderInputProps = { + field: ControllerRenderProps; +}; diff --git a/govtool/frontend/src/components/organisms/index.ts b/govtool/frontend/src/components/organisms/index.ts index 20051f5cf..8378c5d10 100644 --- a/govtool/frontend/src/components/organisms/index.ts +++ b/govtool/frontend/src/components/organisms/index.ts @@ -22,3 +22,5 @@ export * from "./Slider"; export * from "./StatusModal"; export * from "./TopNav"; export * from "./VotingPowerModal"; + +export * from "./ControlledField"; From cf0acc55ba2834e6b6c0ccd07769d84f9bdee4aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Sworze=C5=84?= Date: Fri, 9 Feb 2024 17:54:58 +0100 Subject: [PATCH 08/20] create Spacer atom --- govtool/frontend/src/components/atoms/Spacer.tsx | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 govtool/frontend/src/components/atoms/Spacer.tsx diff --git a/govtool/frontend/src/components/atoms/Spacer.tsx b/govtool/frontend/src/components/atoms/Spacer.tsx new file mode 100644 index 000000000..0c63ad847 --- /dev/null +++ b/govtool/frontend/src/components/atoms/Spacer.tsx @@ -0,0 +1,6 @@ +import { Box } from "@mui/material"; +import { SpacerProps } from "."; + +export const Spacer = ({ x, y }: SpacerProps) => { + return ; +}; From 522e8c6bb40ac7cebb55fc8610d34d7a202d9fe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Sworze=C5=84?= Date: Fri, 9 Feb 2024 17:55:41 +0100 Subject: [PATCH 09/20] refactor types --- .../frontend/src/components/atoms/Button.tsx | 13 ++-------- .../src/components/atoms/LoadingButton.tsx | 9 ++----- .../src/components/atoms/Typography.tsx | 26 ++----------------- 3 files changed, 6 insertions(+), 42 deletions(-) diff --git a/govtool/frontend/src/components/atoms/Button.tsx b/govtool/frontend/src/components/atoms/Button.tsx index 49773dd63..97b9f100e 100644 --- a/govtool/frontend/src/components/atoms/Button.tsx +++ b/govtool/frontend/src/components/atoms/Button.tsx @@ -1,14 +1,5 @@ -import { - Button as MUIButton, - ButtonProps as MUIButtonProps, - SxProps, -} from "@mui/material"; - -interface ButtonProps extends Omit { - size?: "small" | "medium" | "large" | "extraLarge"; - variant?: "contained" | "outlined" | "text"; - sx?: SxProps; -} +import { Button as MUIButton } from "@mui/material"; +import { ButtonProps } from "."; export const Button = ({ size = "large", diff --git a/govtool/frontend/src/components/atoms/LoadingButton.tsx b/govtool/frontend/src/components/atoms/LoadingButton.tsx index cc89562b8..11a22d56f 100644 --- a/govtool/frontend/src/components/atoms/LoadingButton.tsx +++ b/govtool/frontend/src/components/atoms/LoadingButton.tsx @@ -1,11 +1,6 @@ import { Button, CircularProgress } from "@mui/material"; -import type { ButtonProps, SxProps } from "@mui/material"; -interface Props extends Omit { - isLoading?: boolean; - size?: "small" | "medium" | "large" | "extraLarge"; - sx?: SxProps; -} +import { LoadingButtonProps } from "./types"; export const LoadingButton = ({ isLoading, @@ -14,7 +9,7 @@ export const LoadingButton = ({ size = "large", sx, ...rest -}: Props) => { +}: LoadingButtonProps) => { const buttonHeight = { extraLarge: 48, large: 40, diff --git a/govtool/frontend/src/components/atoms/Typography.tsx b/govtool/frontend/src/components/atoms/Typography.tsx index b4ea2b86f..1bcaf6131 100644 --- a/govtool/frontend/src/components/atoms/Typography.tsx +++ b/govtool/frontend/src/components/atoms/Typography.tsx @@ -1,27 +1,5 @@ -import { - Typography as MUITypography, - SxProps, - TypographyProps as MUITypographyProps, -} from "@mui/material"; - -interface TypographyProps - extends Pick { - children?: React.ReactNode; - fontSize?: number; - fontWeight?: 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900; - variant?: - | "headline1" - | "headline2" - | "headline3" - | "headline4" - | "headline5" - | "title1" - | "title2" - | "body1" - | "body2" - | "caption"; - sx?: SxProps; -} +import { Typography as MUITypography } from "@mui/material"; +import { TypographyProps } from "./types"; export const Typography = ({ color, From 7a0516275fd9eac677d3ca9d03cfdbacddbbd963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Sworze=C5=84?= Date: Fri, 9 Feb 2024 17:56:05 +0100 Subject: [PATCH 10/20] replace Input with ControlledField.Input --- .../components/molecules/VoteActionForm.tsx | 34 +++++++++---------- .../organisms/DelegateTodRepStepTwo.tsx | 21 +++++++----- .../organisms/RegisterAsdRepStepOne.tsx | 28 +++++++-------- .../src/hooks/forms/useDelegateTodRepForm.tsx | 11 ++++-- .../frontend/src/pages/UpdatedRepMetadata.tsx | 27 +++++++-------- 5 files changed, 65 insertions(+), 56 deletions(-) diff --git a/govtool/frontend/src/components/molecules/VoteActionForm.tsx b/govtool/frontend/src/components/molecules/VoteActionForm.tsx index 446acc9aa..3c1645bd2 100644 --- a/govtool/frontend/src/components/molecules/VoteActionForm.tsx +++ b/govtool/frontend/src/components/molecules/VoteActionForm.tsx @@ -2,12 +2,14 @@ import { useState, useEffect, useMemo, useCallback } from "react"; import { useLocation } from "react-router-dom"; import { Box, Link } from "@mui/material"; -import { Button, Input, LoadingButton, Radio, Typography } from "@atoms"; +import { Button, LoadingButton, Radio, Spacer, Typography } from "@atoms"; import { ICONS } from "@consts"; import { useCardano, useModal } from "@context"; import { useScreenDimension, useVoteActionForm, useTranslation } from "@hooks"; import { openInNewTab } from "@utils"; +import { ControlledField } from "../organisms"; + export const VoteActionForm = ({ voteFromEP, yesVotes, @@ -27,16 +29,16 @@ export const VoteActionForm = ({ const { t } = useTranslation(); const { - setValue, - control, + areFormErrors, + clearErrors, confirmVote, - vote, - registerInput, + control, errors, isDirty, - clearErrors, - areFormErrors, isVoteLoading, + registerInput, + setValue, + vote, } = useVoteActionForm(); useEffect(() => { @@ -199,22 +201,20 @@ export const VoteActionForm = ({ {isContext && ( - - + + diff --git a/govtool/frontend/src/components/organisms/DelegateTodRepStepTwo.tsx b/govtool/frontend/src/components/organisms/DelegateTodRepStepTwo.tsx index 1dcf7caae..f75a3c83d 100644 --- a/govtool/frontend/src/components/organisms/DelegateTodRepStepTwo.tsx +++ b/govtool/frontend/src/components/organisms/DelegateTodRepStepTwo.tsx @@ -1,7 +1,7 @@ import { useMemo } from "react"; import { Box, Link } from "@mui/material"; -import { Button, Input, LoadingButton, Typography } from "../atoms"; +import { Button, LoadingButton, Typography } from "../atoms"; import { useScreenDimension, useDelegateTodRepForm, @@ -9,6 +9,7 @@ import { } from "@hooks"; import { theme } from "@/theme"; import { openInNewTab } from "@utils"; +import { ControlledField } from "."; interface DelegateProps { setStep: (newStep: number) => void; @@ -22,8 +23,13 @@ export const DelegateTodRepStepTwo = ({ setStep }: DelegateProps) => { palette: { boxShadow2 }, } = theme; - const { control, delegate, isDelegateButtonDisabled, isDelegationLoading } = - useDelegateTodRepForm(); + const { + control, + delegate, + errors, + isDelegateButtonDisabled, + isDelegationLoading, + } = useDelegateTodRepForm(); const renderDelegateButton = useMemo(() => { return ( @@ -85,12 +91,11 @@ export const DelegateTodRepStepTwo = ({ setStep }: DelegateProps) => { {t("delegation.dRepIdDescription")} - >; } @@ -91,22 +93,20 @@ export const RegisterAsdRepStepOne = ({ setStep }: Props) => { > {t("registration.descriptionStepOne")} - - + { const navigate = useNavigate(); const { t } = useTranslation(); - const { control, handleSubmit } = useForm(); + const { + control, + formState: { errors }, + handleSubmit, + } = useForm(); const watch = useWatch({ control, @@ -89,9 +93,10 @@ export const useDelegateTodRepForm = () => { return { control, - isDelegateButtonDisabled, delegate: handleSubmit(delegate), - modal, + errors, + isDelegateButtonDisabled, isDelegationLoading: isLoading, + modal, }; }; diff --git a/govtool/frontend/src/pages/UpdatedRepMetadata.tsx b/govtool/frontend/src/pages/UpdatedRepMetadata.tsx index 4e45a426b..73df93b0c 100644 --- a/govtool/frontend/src/pages/UpdatedRepMetadata.tsx +++ b/govtool/frontend/src/pages/UpdatedRepMetadata.tsx @@ -2,7 +2,7 @@ import { useMemo, useEffect } from "react"; import { Box, Link } from "@mui/material"; import { useNavigate } from "react-router-dom"; -import { Background, Input, LoadingButton, Button, Typography } from "@atoms"; +import { Background, Button, LoadingButton, Spacer, Typography } from "@atoms"; import { ICONS, PATHS } from "@consts"; import { useCardano } from "@context"; import { @@ -10,7 +10,7 @@ import { useUpdatedRepMetadataForm, useTranslation, } from "@hooks"; -import { DashboardTopNav, Footer } from "@organisms"; +import { ControlledField, DashboardTopNav, Footer } from "@organisms"; import { theme } from "@/theme"; import { WALLET_LS_KEY, getItemFromLocalStorage, openInNewTab } from "@utils"; @@ -117,22 +117,21 @@ export const UpdatedRepMetadata = () => { > {t("metadataUpdate.description")} - - + From 4c4d4392e1b2f81b7c1cb30f2ba9a2a819169ed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Sworze=C5=84?= Date: Mon, 12 Feb 2024 10:56:30 +0100 Subject: [PATCH 11/20] update Input story --- .../frontend/src/stories/Input.stories.tsx | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/govtool/frontend/src/stories/Input.stories.tsx b/govtool/frontend/src/stories/Input.stories.tsx index ec9fc4620..cbe95a400 100644 --- a/govtool/frontend/src/stories/Input.stories.tsx +++ b/govtool/frontend/src/stories/Input.stories.tsx @@ -1,38 +1,30 @@ import type { Meta, StoryFn } from "@storybook/react"; -import { Input } from "@atoms"; +import { Field } from "@molecules"; import { ComponentProps } from "react"; import { userEvent, within } from "@storybook/testing-library"; import { expect } from "@storybook/jest"; -import { useUrlAndHashFormController } from "@hooks"; const meta = { title: "Example/Input", - component: Input, + component: Field.Input, parameters: { layout: "centered", }, tags: ["autodocs"], -} satisfies Meta; +} satisfies Meta; export default meta; -const Template: StoryFn> = (args) => { - const { control } = useUrlAndHashFormController(); - - return ; +const Template: StoryFn> = (args) => { + return ; }; export const Default = Template.bind({}); -Default.args = { - placeholder: "Enter URL", - width: "400px", - formFieldName: "url", -}; Default.play = async ({ canvasElement }) => { const canvas = within(canvasElement); - const inputElement = canvas.getByPlaceholderText("Enter URL"); + const inputElement = canvas.getByPlaceholderText("Placeholder"); await userEvent.type(inputElement, "test"); expect(inputElement).toHaveValue("test"); }; @@ -40,9 +32,6 @@ Default.play = async ({ canvasElement }) => { export const WithLabel = Template.bind({}); WithLabel.args = { label: "Label", - placeholder: "Enter URL", - width: "400px", - formFieldName: "url", }; WithLabel.play = async ({ canvasElement }) => { @@ -52,13 +41,22 @@ WithLabel.play = async ({ canvasElement }) => { export const Error = Template.bind({}); Error.args = { - placeholder: "Enter URL", - errorMessage: "Invalid URL format", - width: "400px", - formFieldName: "url", + errorMessage: "Error message", }; Error.play = async ({ canvasElement }) => { const canvas = within(canvasElement); - expect(canvas.getByTestId("invalid-url-format-error")).toBeInTheDocument(); + expect(canvas.getByTestId("error-message-error")).toBeInTheDocument(); +}; + +export const ErrorAndLabel = Template.bind({}); +ErrorAndLabel.args = { + errorMessage: "Error message", + label: "Label", +}; + +ErrorAndLabel.play = async ({ canvasElement }) => { + const canvas = within(canvasElement); + expect(canvas.getByText("Label")).toBeInTheDocument(); + expect(canvas.getByTestId("error-message-error")).toBeInTheDocument(); }; From 250a7892ab8c1889930d8290568d56464ec2cd7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Sworze=C5=84?= Date: Mon, 12 Feb 2024 10:58:01 +0100 Subject: [PATCH 12/20] delete unnecesary snackbar --- .../frontend/src/components/atoms/index.ts | 2 - .../components/atoms/snackbar/Snackbar.tsx | 39 --------------- .../atoms/snackbar/SnackbarMessage.tsx | 49 ------------------- govtool/frontend/src/context/snackbar.tsx | 1 - 4 files changed, 91 deletions(-) delete mode 100644 govtool/frontend/src/components/atoms/snackbar/Snackbar.tsx delete mode 100644 govtool/frontend/src/components/atoms/snackbar/SnackbarMessage.tsx diff --git a/govtool/frontend/src/components/atoms/index.ts b/govtool/frontend/src/components/atoms/index.ts index fd9d803e1..5d03b0752 100644 --- a/govtool/frontend/src/components/atoms/index.ts +++ b/govtool/frontend/src/components/atoms/index.ts @@ -13,8 +13,6 @@ export * from "./modal/ModalWrapper"; export * from "./Radio"; export * from "./ScrollToManage"; export * from "./ScrollToTop"; -export * from "./snackbar/Snackbar"; -export * from "./snackbar/SnackbarMessage"; export * from "./StakeRadio"; export * from "./Tooltip"; export * from "./Typography"; diff --git a/govtool/frontend/src/components/atoms/snackbar/Snackbar.tsx b/govtool/frontend/src/components/atoms/snackbar/Snackbar.tsx deleted file mode 100644 index b1234c0a8..000000000 --- a/govtool/frontend/src/components/atoms/snackbar/Snackbar.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import type { GrowProps } from "@mui/material/Grow"; -import Grow from "@mui/material/Grow"; -import type { SnackbarProps } from "@mui/material/Snackbar"; -import MuiSnackbar from "@mui/material/Snackbar"; - -import { theme } from "@/theme"; -import type { SnackbarSeverity } from "@models"; - -function GrowTransition(props: GrowProps) { - return ; -} - -interface Props extends SnackbarProps { - severity: SnackbarSeverity; -} - -export function Snackbar({ severity, ...props }: Props) { - return ( - - ); -} diff --git a/govtool/frontend/src/components/atoms/snackbar/SnackbarMessage.tsx b/govtool/frontend/src/components/atoms/snackbar/SnackbarMessage.tsx deleted file mode 100644 index 8c4c34dd9..000000000 --- a/govtool/frontend/src/components/atoms/snackbar/SnackbarMessage.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import { styled } from "@mui/material/styles"; - -import { ICONS } from "@consts"; -import type { SnackbarSeverity } from "@models"; - -interface Props { - message: string; - onClose?: (_event: React.SyntheticEvent | Event, reason?: string) => void; - severity: SnackbarSeverity; -} - -export function SnackbarMessage({ message, severity, onClose }: Props) { - return ( - - {severity === "success" ? ( - - ) : ( - - )} -
{message}
- {onClose && ( - close icon - )} -
- ); -} - -const SnackContainer = styled("span")` - align-items: center; - display: flex; - gap: 8px; - justify-content: space-between; - color: white; - font-weight: 500; - font-size: 14px; - line-height: 24px; - width: 100%; -`; diff --git a/govtool/frontend/src/context/snackbar.tsx b/govtool/frontend/src/context/snackbar.tsx index 584a09dd8..6e84b719c 100644 --- a/govtool/frontend/src/context/snackbar.tsx +++ b/govtool/frontend/src/context/snackbar.tsx @@ -9,7 +9,6 @@ import { } from "react"; import { Snackbar, Alert } from "@mui/material"; -import { SnackbarMessage } from "@atoms"; import { SnackbarSeverity } from "@models"; import { useScreenDimension, useTranslation } from "@hooks"; From 8629ef746555c735063c14cdf6eeda40ee388225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Placzy=C5=84ski?= Date: Wed, 14 Feb 2024 14:04:25 +0100 Subject: [PATCH 13/20] Merge pull request #172 from IntersectMBO/171-enhance-deployment-script-for-conditional-generation-of-basicauth-configuration-files [#171] Remove Nginx config post-deployment to prevent configuration reuse across environments --- docs/operations/DEPLOY.md | 16 ++++++++++++++++ scripts/govtool/prepare-config.sh | 1 + 2 files changed, 17 insertions(+) diff --git a/docs/operations/DEPLOY.md b/docs/operations/DEPLOY.md index f0cedf97b..2f75566f3 100644 --- a/docs/operations/DEPLOY.md +++ b/docs/operations/DEPLOY.md @@ -52,3 +52,19 @@ Alternatively you can type `make all instance=$INSTANCE cardano_network=$CARDANO View the app at `https://${ENVIRONMENT}-${INSTANCE}.govtool.byron.network`. Keep in mind that after initial deployment on a new environment, it will take some time for the Cardano node to get in sync. + +## Aftermatch + +After performing a deploy from a local machine, it is crucial to carefully track +the application's accessibility and functionality to ensure no unintended +changes, such as the accidental activation of BasicAuth[^1], have occurred. + +Additionally, verifying that all configuration files and environment variables, +particularly those related to environment-specific settings like database +connections or external service endpoints, are correctly generated and applied +is essential for maintaining the intended behavior of the application across +different environments. This includes a thorough check of environment variables +to confirm they are correctly set and aligned with the specific needs of the +deployed environment. + +[^1]: https://github.com/IntersectMBO/govtool/discussions/174 diff --git a/scripts/govtool/prepare-config.sh b/scripts/govtool/prepare-config.sh index 7e072d116..062a1ecaf 100755 --- a/scripts/govtool/prepare-config.sh +++ b/scripts/govtool/prepare-config.sh @@ -79,6 +79,7 @@ sed -e "s/GRAFANA_SLACK_RECIPIENT/$GRAFANA_SLACK_RECIPIENT/" \ # nginx config for frontend optional basic auth nginx_config_dir="$target_config_dir/nginx" +rm -rf "$nginx_config_dir" mkdir -p "$nginx_config_dir" if [[ "$DOMAIN" == *"sanchonet.govtool.byron.network"* ]]; then cat >"$nginx_config_dir/auth.conf" <<_EOF_ From d534ea6f017ff916e9b337fbcdf1034d0af573a6 Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Fri, 9 Feb 2024 13:18:34 +0000 Subject: [PATCH 14/20] chore: bump node version to 8.8 --- scripts/govtool/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/govtool/docker-compose.yml b/scripts/govtool/docker-compose.yml index 6e705023a..6e35e1d60 100644 --- a/scripts/govtool/docker-compose.yml +++ b/scripts/govtool/docker-compose.yml @@ -51,7 +51,7 @@ services: max-file: "10" cardano-node: - image: inputoutput/cardano-node:8.0.0 + image: inputoutput/cardano-node:8.8.0 environment: - NETWORK=${NETWORK:-mainnet} volumes: From 8009c048db387dd9dbb12f1c91e9a8bb974bf3b6 Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Wed, 14 Feb 2024 11:02:02 +0000 Subject: [PATCH 15/20] chore: bump DBsync sancho version --- scripts/govtool/docker-compose.sanchonet.yml | 2 +- scripts/govtool/docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/govtool/docker-compose.sanchonet.yml b/scripts/govtool/docker-compose.sanchonet.yml index 0a5664263..da90ec6df 100644 --- a/scripts/govtool/docker-compose.sanchonet.yml +++ b/scripts/govtool/docker-compose.sanchonet.yml @@ -143,7 +143,7 @@ services: logging: *logging cardano-db-sync: - image: ghcr.io/intersectmbo/cardano-db-sync:sancho-3-0-0 + image: ghcr.io/intersectmbo/cardano-db-sync:sancho-4-0-0 environment: - NETWORK=${CARDANO_NETWORK:-sanchonet} - POSTGRES_HOST=postgres diff --git a/scripts/govtool/docker-compose.yml b/scripts/govtool/docker-compose.yml index 6e35e1d60..6e705023a 100644 --- a/scripts/govtool/docker-compose.yml +++ b/scripts/govtool/docker-compose.yml @@ -51,7 +51,7 @@ services: max-file: "10" cardano-node: - image: inputoutput/cardano-node:8.8.0 + image: inputoutput/cardano-node:8.0.0 environment: - NETWORK=${NETWORK:-mainnet} volumes: From 072a05a32bcc0fa2678c85602a9f83cb95856c5e Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Wed, 14 Feb 2024 11:22:30 +0000 Subject: [PATCH 16/20] chore: fix cardano node versions --- scripts/govtool/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/govtool/docker-compose.yml b/scripts/govtool/docker-compose.yml index 6e705023a..c0daa4671 100644 --- a/scripts/govtool/docker-compose.yml +++ b/scripts/govtool/docker-compose.yml @@ -51,7 +51,7 @@ services: max-file: "10" cardano-node: - image: inputoutput/cardano-node:8.0.0 + image: inputoutput/cardano-node:8.7.3 environment: - NETWORK=${NETWORK:-mainnet} volumes: From 1eb5c77d8d23dc4dd50eaf4a4dc6eaeb1f59922c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Sworze=C5=84?= Date: Wed, 14 Feb 2024 13:36:42 +0100 Subject: [PATCH 17/20] fix placeholder for metadata hash at url --- CHANGELOG.md | 1 + govtool/frontend/src/i18n/locales/en.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c21fa0e8..ac8e9ea7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ changes. - i18next library added to FE [Issue 80](https://github.com/IntersectMBO/govtool/issues/80) ### Fixed +- Fix misleading metadata hash text [Issue 90](https://github.com/IntersectMBO/govtool/issues/90) - Fixed vote calculation problems related to NoConfidence DRep [Issue 59](https://github.com/IntersectMBO/govtool/issues/59) - Fixed ada-holder/get-current-delegation error when delegated to NoConfidence or AlwaysAbstain dreps. [Issue 82](https://github.com/IntersectMBO/govtool/issues/82) diff --git a/govtool/frontend/src/i18n/locales/en.ts b/govtool/frontend/src/i18n/locales/en.ts index 876dd71b0..aa6a71f3e 100644 --- a/govtool/frontend/src/i18n/locales/en.ts +++ b/govtool/frontend/src/i18n/locales/en.ts @@ -156,7 +156,7 @@ export const en = { privacyPolicy: "Privacy policy", }, forms: { - hashPlaceholder: "The hash of your URL", + hashPlaceholder: "The hash of metadata at URL", howCreateUrlAndHash: "How to create URL and hash?", urlWithContextPlaceholder: "Your URL with with your context", urlWithInfoPlaceholder: "Your URL with extra info about you", From 7adf4a2cf4a0d59b9ab2debc2a1a6339d7cb22ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Placzy=C5=84ski?= Date: Thu, 15 Feb 2024 14:37:54 +0100 Subject: [PATCH 18/20] [#181] Implement hotfix for SanchoNet Cardano DB Sync configuration issue Summary: In response to a critical issue where the SanchoNet Cardano DB Sync Docker image failed to correctly parse configuration files for the SanchoNet environment, this commit introduces a hotfix. The resolution involved modifying the entrypoint script to allow for dynamic configuration based on external files rather than hardcoded values. This was achieved by adding additional volumes to the DBSync container for configuration files and execution scripts, ensuring the DBSync component can operate with the correct settings sourced from the official documentation. Technical Details: The changes include the creation of new scripts (govtool-dbsync, govtool-entrypoint, and govtool-sanchonet) within the scripts/govtool/dbsync directory. These scripts are designed as one-to-one replacements for the original scripts but with modifications to the paths, enabling the use of target configurations from a custom volume. Furthermore, the docker-compose.sanchonet.yml file was updated to incorporate these new scripts through volume mounts, ensuring the DBSync component utilizes the correct configurations at runtime. The prepare-config.sh script was also modified to prepare a scripts directory specifically for the DBSync entrypoint, including copying the newly created scripts into the target configuration directory. This ensures that upon deployment, the DBSync service is equipped with all necessary custom scripts to correctly interpret the environment-specific configurations. This hotfix has been tested in a development environment by triggering deployment from a local machine, confirming its effectiveness in resolving the configuration parsing issue without introducing any new problems or dependencies. This approach not only addresses the immediate problem but also enhances the flexibility of the deployment process for the SanchoNet Cardano DB Sync service within a Docker environment. Note: This solution is a temporary workaround pending a permanent fix for the configuration parsing issue. It emphasizes the importance of maintaining adaptability in deployment scripts and configurations to accommodate changes in the underlying infrastructure or application requirements. Related issue: https://github.com/IntersectMBO/cardano-db-sync/issues/1629 --- scripts/govtool/dbsync/govtool-dbsync | 72 +++++++++++++++++ scripts/govtool/dbsync/govtool-entrypoint | 81 ++++++++++++++++++++ scripts/govtool/dbsync/govtool-sanchonet | 3 + scripts/govtool/docker-compose.sanchonet.yml | 4 + scripts/govtool/prepare-config.sh | 7 ++ 5 files changed, 167 insertions(+) create mode 100755 scripts/govtool/dbsync/govtool-dbsync create mode 100755 scripts/govtool/dbsync/govtool-entrypoint create mode 100755 scripts/govtool/dbsync/govtool-sanchonet diff --git a/scripts/govtool/dbsync/govtool-dbsync b/scripts/govtool/dbsync/govtool-dbsync new file mode 100755 index 000000000..ce914684e --- /dev/null +++ b/scripts/govtool/dbsync/govtool-dbsync @@ -0,0 +1,72 @@ +#!/nix/store/vqvj60h076bhqj6977caz0pfxs6543nb-bash-5.2-p15/bin/bash +set -euo pipefail + +export CARDANO_NODE_SOCKET_PATH="/node-ipc/node.socket" + + + + + +if [ ! -z "${RESTORE_SNAPSHOT:-}" ]; then +SNAPSHOT_BASENAME="$(basename "$RESTORE_SNAPSHOT")" +RESTORED_MARKER="$SNAPSHOT_BASENAME.restored" +if [ ! -f "$RESTORED_MARKER" ]; then + if [[ "$RESTORE_SNAPSHOT" =~ ^https://.* ]]; then + echo "Downloading snapshot $RESTORE_SNAPSHOT ..." + /nix/store/6g6s5cqbvk1nw2y2c8lpbn95sk0w24f9-curl-8.2.1-bin/bin/curl -LOC - "$RESTORE_SNAPSHOT" + + /nix/store/6g6s5cqbvk1nw2y2c8lpbn95sk0w24f9-curl-8.2.1-bin/bin/curl -LO "$RESTORE_SNAPSHOT.sha256sum" + /nix/store/apn3p2b40xvirn7w740wv2gy330ppib5-coreutils-9.3/bin/sha256sum -c "$SNAPSHOT_BASENAME.sha256sum" + + + + SNAPSHOT="$SNAPSHOT_BASENAME" + else + SNAPSHOT="$RESTORE_SNAPSHOT" + fi + rm -f /var/lib/cexplorer/*.lstate + /nix/store/1bys3yjgm97yxy91sfy8f5law41fyif9-postgresql-setup.sh --restore-snapshot "$SNAPSHOT" /var/lib/cexplorer + touch $RESTORED_MARKER + rm -f $SNAPSHOT{,.sha256sum,.asc} +fi +fi + + +if [[ -n "${WAIT_FOR_NODE_SYNC:-}" ]] +then + until [ -S $CARDANO_NODE_SOCKET_PATH ]; do + echo Waiting for $CARDANO_NODE_SOCKET_PATH + sleep 10 + done + # from scripts/postgresql-setup.sh + export PGHOST=$(cut -d ":" -f 1 "${PGPASSFILE}") + export PGPORT=$(cut -d ":" -f 2 "${PGPASSFILE}") + export PGDATABASE=$(cut -d ":" -f 3 "${PGPASSFILE}") + user=$(cut -d ":" -f 4 "${PGPASSFILE}") + if [ "$user" != "*" ]; then + export PGUSER=$user + fi; + DB_MAX_BLOCK=$(psql -h $PGHOST $PGDATABASE -U $PGUSER -t -c 'select max (block_no) from block;') + NODE_CUR_BLOCK=0 + while [ $NODE_CUR_BLOCK -lt $DB_MAX_BLOCK ]; do + NODE_STATUS="$(cardano-cli query tip --testnet-magic $(jq '.networkMagic' /nix/store/558hxsvn739289w35s5nhy8p89iispb4-shelley-genesis.json) 2>/dev/null || true)" + NODE_CUR_BLOCK="$(jq -e -r '.block' <<<"$NODE_STATUS" 2>/dev/null || true)" + echo "Waiting... Sync progress at $NODE_CUR_BLOCK /$DB_MAX_BLOCK" + sleep 10 + done +fi + +mkdir -p log-dir +if [[ "${DISABLE_LEDGER:-N}" == "Y" ]]; then + LEDGER_OPTS="--disable-ledger" +else + LEDGER_OPTS="--state-dir /var/lib/cexplorer" +fi + +exec /nix/store/hjlmcj93mxvl1wqfsmac1pj9rfk106hw-cardano-db-sync-exe-cardano-db-sync-13.2.0.0/bin/cardano-db-sync \ + --config /configuration/db-sync-config.json \ + --socket-path "$CARDANO_NODE_SOCKET_PATH" \ + --schema-dir /nix/store/4xzm921ryfrvp73j86alrq8rkk14h7s6-schema \ + ${LEDGER_OPTS} \ + ${EXTRA_DB_SYNC_ARGS:-} + diff --git a/scripts/govtool/dbsync/govtool-entrypoint b/scripts/govtool/dbsync/govtool-entrypoint new file mode 100755 index 000000000..acd578f06 --- /dev/null +++ b/scripts/govtool/dbsync/govtool-entrypoint @@ -0,0 +1,81 @@ +#!/nix/store/vqvj60h076bhqj6977caz0pfxs6543nb-bash-5.2-p15/bin/bash +mkdir -p /configuration +if [ ! -f /configuration/pgpass ]; then + /nix/store/vwp2kcwif9afpcqpm31bxlk9gh3h2r5r-gen-pgpass /run/secrets +fi +export PGPASSFILE=/configuration/pgpass + +# set up /tmp (override with TMPDIR variable) +mkdir -p -m 1777 /tmp +if [[ -z "$NETWORK" ]]; then + echo "Connecting to network specified in configuration.yaml" + DBSYNC=/nix/store/hjlmcj93mxvl1wqfsmac1pj9rfk106hw-cardano-db-sync-exe-cardano-db-sync-13.2.0.0/bin/cardano-db-sync + + set -euo pipefail + if [ ! -z "${RESTORE_SNAPSHOT:-}" ]; then +SNAPSHOT_BASENAME="$(basename "$RESTORE_SNAPSHOT")" +RESTORED_MARKER="$SNAPSHOT_BASENAME.restored" +if [ ! -f "$RESTORED_MARKER" ]; then + if [[ "$RESTORE_SNAPSHOT" =~ ^https://.* ]]; then + echo "Downloading snapshot $RESTORE_SNAPSHOT ..." + /nix/store/6g6s5cqbvk1nw2y2c8lpbn95sk0w24f9-curl-8.2.1-bin/bin/curl -LOC - "$RESTORE_SNAPSHOT" + + /nix/store/6g6s5cqbvk1nw2y2c8lpbn95sk0w24f9-curl-8.2.1-bin/bin/curl -LO "$RESTORE_SNAPSHOT.sha256sum" + /nix/store/apn3p2b40xvirn7w740wv2gy330ppib5-coreutils-9.3/bin/sha256sum -c "$SNAPSHOT_BASENAME.sha256sum" + + + + SNAPSHOT="$SNAPSHOT_BASENAME" + else + SNAPSHOT="$RESTORE_SNAPSHOT" + fi + rm -f /var/lib/cexplorer/*.lstate + /nix/store/1bys3yjgm97yxy91sfy8f5law41fyif9-postgresql-setup.sh --restore-snapshot "$SNAPSHOT" /var/lib/cexplorer + touch $RESTORED_MARKER + rm -f $SNAPSHOT{,.sha256sum,.asc} +fi +fi + + + if [[ "${DISABLE_LEDGER:-N}" == "Y" ]]; then + LEDGER_OPTS="--disable-ledger" + else + LEDGER_OPTS="--state-dir /var/lib/cexplorer" + fi + + exec $DBSYNC --schema-dir /nix/store/4xzm921ryfrvp73j86alrq8rkk14h7s6-schema ${LEDGER_OPTS} $@ + +elif [[ "$NETWORK" == "mainnet" ]]; then + echo "Connecting to network: mainnet" + exec /nix/store/85v1wxvwsf487ng3pc0cfw999jzgyf00-cardano-db-sync-mainnet/bin/cardano-db-sync-mainnet + echo "Cleaning up" + +elif [[ "$NETWORK" == "preprod" ]]; then + echo "Connecting to network: preprod" + exec /nix/store/3qmpvpl9p1azinz2aqp4rgmhfymn7m2y-cardano-db-sync-preprod/bin/cardano-db-sync-preprod + echo "Cleaning up" + +elif [[ "$NETWORK" == "preview" ]]; then + echo "Connecting to network: preview" + exec /nix/store/km8zmilk90kb51q1qg4vf8d72dwb3w7l-cardano-db-sync-preview/bin/cardano-db-sync-preview + echo "Cleaning up" + +elif [[ "$NETWORK" == "private" ]]; then + echo "Connecting to network: private" + exec /nix/store/674zfi0nxjxbzmi9lbjm6pfdgdxhnvv2-cardano-db-sync-private/bin/cardano-db-sync-private + echo "Cleaning up" + +elif [[ "$NETWORK" == "sanchonet" ]]; then + echo "Connecting to network: sanchonet" + exec /scripts/govtool-sanchonet + echo "Cleaning up" + +elif [[ "$NETWORK" == "shelley_qa" ]]; then + echo "Connecting to network: shelley_qa" + exec /nix/store/2dv0dff02yx5cixxiacp2ha70z53hhc3-cardano-db-sync-shelley_qa/bin/cardano-db-sync-shelley_qa + echo "Cleaning up" + + +else + echo "Managed configuration for network "$NETWORK" does not exist" +fi diff --git a/scripts/govtool/dbsync/govtool-sanchonet b/scripts/govtool/dbsync/govtool-sanchonet new file mode 100755 index 000000000..8612cad47 --- /dev/null +++ b/scripts/govtool/dbsync/govtool-sanchonet @@ -0,0 +1,3 @@ +#!/nix/store/vqvj60h076bhqj6977caz0pfxs6543nb-bash-5.2-p15/bin/bash +set -euo pipefail +/scripts/govtool-dbsync $@ diff --git a/scripts/govtool/docker-compose.sanchonet.yml b/scripts/govtool/docker-compose.sanchonet.yml index da90ec6df..14de8a9db 100644 --- a/scripts/govtool/docker-compose.sanchonet.yml +++ b/scripts/govtool/docker-compose.sanchonet.yml @@ -160,9 +160,13 @@ services: - postgres_password - postgres_user - postgres_db + entrypoint: + - /scripts/govtool-entrypoint volumes: - db-sync-data:/var/lib/cexplorer - node-ipc:/node-ipc + - /home/ubuntu/config/cardano-node:/configuration + - /home/ubuntu/config/dbsync-scripts:/scripts restart: always logging: *logging diff --git a/scripts/govtool/prepare-config.sh b/scripts/govtool/prepare-config.sh index 062a1ecaf..9be21ebf3 100755 --- a/scripts/govtool/prepare-config.sh +++ b/scripts/govtool/prepare-config.sh @@ -7,6 +7,13 @@ config_dir="$repo_root_dir/scripts/govtool/config" target_config_dir="$repo_root_dir/scripts/govtool/config/target" mkdir -p "$target_config_dir" +# prepare a scripts directory for the DBSync entrypoint +dbsync_scripts_dir="$target_config_dir/dbsync-scripts" +mkdir -p "$dbsync_scripts_dir" +cp "$repo_root_dir/scripts/govtool/dbsync/govtool-entrypoint" "$dbsync_scripts_dir/govtool-entrypoint" +cp "$repo_root_dir/scripts/govtool/dbsync/govtool-sanchonet" "$dbsync_scripts_dir/govtool-sanchonet" +cp "$repo_root_dir/scripts/govtool/dbsync/govtool-dbsync" "$dbsync_scripts_dir/govtool-dbsync" + # cardano node config cardano_node_config_dir="$target_config_dir/cardano-node" mkdir -p "$cardano_node_config_dir" From ef233298cf13cb40b5bdef752e357da3fd36f64f Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Thu, 15 Feb 2024 16:36:07 +0000 Subject: [PATCH 19/20] chore: bump DBSync version to use fixed image --- scripts/govtool/docker-compose.sanchonet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/govtool/docker-compose.sanchonet.yml b/scripts/govtool/docker-compose.sanchonet.yml index 14de8a9db..7278acddf 100644 --- a/scripts/govtool/docker-compose.sanchonet.yml +++ b/scripts/govtool/docker-compose.sanchonet.yml @@ -143,7 +143,7 @@ services: logging: *logging cardano-db-sync: - image: ghcr.io/intersectmbo/cardano-db-sync:sancho-4-0-0 + image: ghcr.io/intersectmbo/cardano-db-sync:sancho-4-0-0-fix-config environment: - NETWORK=${CARDANO_NETWORK:-sanchonet} - POSTGRES_HOST=postgres From 657ce73a03733b2b8dd1a085824f2751e398d4d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Placzy=C5=84ski?= Date: Fri, 16 Feb 2024 06:55:59 +0100 Subject: [PATCH 20/20] Revert "[#181] Implement hotfix for SanchoNet Cardano DB Sync configuration issue" This reverts commit b55a3a91df8712c33446ae8e049328d754964889. There is a solution made for https://github.com/IntersectMBO/cardano-db-sync/issues/1629 involving a new image release. The new image is ghcr.io/intersectmbo/cardano-db-sync:sancho-4-0-0-fix-config. We will use the official solution instead of my hotfix, hence this revert. We also want to document our efforts that's why we do not simply romowe the reverted commit from the history. --- scripts/govtool/dbsync/govtool-dbsync | 72 ----------------- scripts/govtool/dbsync/govtool-entrypoint | 81 -------------------- scripts/govtool/dbsync/govtool-sanchonet | 3 - scripts/govtool/docker-compose.sanchonet.yml | 4 - scripts/govtool/prepare-config.sh | 7 -- 5 files changed, 167 deletions(-) delete mode 100755 scripts/govtool/dbsync/govtool-dbsync delete mode 100755 scripts/govtool/dbsync/govtool-entrypoint delete mode 100755 scripts/govtool/dbsync/govtool-sanchonet diff --git a/scripts/govtool/dbsync/govtool-dbsync b/scripts/govtool/dbsync/govtool-dbsync deleted file mode 100755 index ce914684e..000000000 --- a/scripts/govtool/dbsync/govtool-dbsync +++ /dev/null @@ -1,72 +0,0 @@ -#!/nix/store/vqvj60h076bhqj6977caz0pfxs6543nb-bash-5.2-p15/bin/bash -set -euo pipefail - -export CARDANO_NODE_SOCKET_PATH="/node-ipc/node.socket" - - - - - -if [ ! -z "${RESTORE_SNAPSHOT:-}" ]; then -SNAPSHOT_BASENAME="$(basename "$RESTORE_SNAPSHOT")" -RESTORED_MARKER="$SNAPSHOT_BASENAME.restored" -if [ ! -f "$RESTORED_MARKER" ]; then - if [[ "$RESTORE_SNAPSHOT" =~ ^https://.* ]]; then - echo "Downloading snapshot $RESTORE_SNAPSHOT ..." - /nix/store/6g6s5cqbvk1nw2y2c8lpbn95sk0w24f9-curl-8.2.1-bin/bin/curl -LOC - "$RESTORE_SNAPSHOT" - - /nix/store/6g6s5cqbvk1nw2y2c8lpbn95sk0w24f9-curl-8.2.1-bin/bin/curl -LO "$RESTORE_SNAPSHOT.sha256sum" - /nix/store/apn3p2b40xvirn7w740wv2gy330ppib5-coreutils-9.3/bin/sha256sum -c "$SNAPSHOT_BASENAME.sha256sum" - - - - SNAPSHOT="$SNAPSHOT_BASENAME" - else - SNAPSHOT="$RESTORE_SNAPSHOT" - fi - rm -f /var/lib/cexplorer/*.lstate - /nix/store/1bys3yjgm97yxy91sfy8f5law41fyif9-postgresql-setup.sh --restore-snapshot "$SNAPSHOT" /var/lib/cexplorer - touch $RESTORED_MARKER - rm -f $SNAPSHOT{,.sha256sum,.asc} -fi -fi - - -if [[ -n "${WAIT_FOR_NODE_SYNC:-}" ]] -then - until [ -S $CARDANO_NODE_SOCKET_PATH ]; do - echo Waiting for $CARDANO_NODE_SOCKET_PATH - sleep 10 - done - # from scripts/postgresql-setup.sh - export PGHOST=$(cut -d ":" -f 1 "${PGPASSFILE}") - export PGPORT=$(cut -d ":" -f 2 "${PGPASSFILE}") - export PGDATABASE=$(cut -d ":" -f 3 "${PGPASSFILE}") - user=$(cut -d ":" -f 4 "${PGPASSFILE}") - if [ "$user" != "*" ]; then - export PGUSER=$user - fi; - DB_MAX_BLOCK=$(psql -h $PGHOST $PGDATABASE -U $PGUSER -t -c 'select max (block_no) from block;') - NODE_CUR_BLOCK=0 - while [ $NODE_CUR_BLOCK -lt $DB_MAX_BLOCK ]; do - NODE_STATUS="$(cardano-cli query tip --testnet-magic $(jq '.networkMagic' /nix/store/558hxsvn739289w35s5nhy8p89iispb4-shelley-genesis.json) 2>/dev/null || true)" - NODE_CUR_BLOCK="$(jq -e -r '.block' <<<"$NODE_STATUS" 2>/dev/null || true)" - echo "Waiting... Sync progress at $NODE_CUR_BLOCK /$DB_MAX_BLOCK" - sleep 10 - done -fi - -mkdir -p log-dir -if [[ "${DISABLE_LEDGER:-N}" == "Y" ]]; then - LEDGER_OPTS="--disable-ledger" -else - LEDGER_OPTS="--state-dir /var/lib/cexplorer" -fi - -exec /nix/store/hjlmcj93mxvl1wqfsmac1pj9rfk106hw-cardano-db-sync-exe-cardano-db-sync-13.2.0.0/bin/cardano-db-sync \ - --config /configuration/db-sync-config.json \ - --socket-path "$CARDANO_NODE_SOCKET_PATH" \ - --schema-dir /nix/store/4xzm921ryfrvp73j86alrq8rkk14h7s6-schema \ - ${LEDGER_OPTS} \ - ${EXTRA_DB_SYNC_ARGS:-} - diff --git a/scripts/govtool/dbsync/govtool-entrypoint b/scripts/govtool/dbsync/govtool-entrypoint deleted file mode 100755 index acd578f06..000000000 --- a/scripts/govtool/dbsync/govtool-entrypoint +++ /dev/null @@ -1,81 +0,0 @@ -#!/nix/store/vqvj60h076bhqj6977caz0pfxs6543nb-bash-5.2-p15/bin/bash -mkdir -p /configuration -if [ ! -f /configuration/pgpass ]; then - /nix/store/vwp2kcwif9afpcqpm31bxlk9gh3h2r5r-gen-pgpass /run/secrets -fi -export PGPASSFILE=/configuration/pgpass - -# set up /tmp (override with TMPDIR variable) -mkdir -p -m 1777 /tmp -if [[ -z "$NETWORK" ]]; then - echo "Connecting to network specified in configuration.yaml" - DBSYNC=/nix/store/hjlmcj93mxvl1wqfsmac1pj9rfk106hw-cardano-db-sync-exe-cardano-db-sync-13.2.0.0/bin/cardano-db-sync - - set -euo pipefail - if [ ! -z "${RESTORE_SNAPSHOT:-}" ]; then -SNAPSHOT_BASENAME="$(basename "$RESTORE_SNAPSHOT")" -RESTORED_MARKER="$SNAPSHOT_BASENAME.restored" -if [ ! -f "$RESTORED_MARKER" ]; then - if [[ "$RESTORE_SNAPSHOT" =~ ^https://.* ]]; then - echo "Downloading snapshot $RESTORE_SNAPSHOT ..." - /nix/store/6g6s5cqbvk1nw2y2c8lpbn95sk0w24f9-curl-8.2.1-bin/bin/curl -LOC - "$RESTORE_SNAPSHOT" - - /nix/store/6g6s5cqbvk1nw2y2c8lpbn95sk0w24f9-curl-8.2.1-bin/bin/curl -LO "$RESTORE_SNAPSHOT.sha256sum" - /nix/store/apn3p2b40xvirn7w740wv2gy330ppib5-coreutils-9.3/bin/sha256sum -c "$SNAPSHOT_BASENAME.sha256sum" - - - - SNAPSHOT="$SNAPSHOT_BASENAME" - else - SNAPSHOT="$RESTORE_SNAPSHOT" - fi - rm -f /var/lib/cexplorer/*.lstate - /nix/store/1bys3yjgm97yxy91sfy8f5law41fyif9-postgresql-setup.sh --restore-snapshot "$SNAPSHOT" /var/lib/cexplorer - touch $RESTORED_MARKER - rm -f $SNAPSHOT{,.sha256sum,.asc} -fi -fi - - - if [[ "${DISABLE_LEDGER:-N}" == "Y" ]]; then - LEDGER_OPTS="--disable-ledger" - else - LEDGER_OPTS="--state-dir /var/lib/cexplorer" - fi - - exec $DBSYNC --schema-dir /nix/store/4xzm921ryfrvp73j86alrq8rkk14h7s6-schema ${LEDGER_OPTS} $@ - -elif [[ "$NETWORK" == "mainnet" ]]; then - echo "Connecting to network: mainnet" - exec /nix/store/85v1wxvwsf487ng3pc0cfw999jzgyf00-cardano-db-sync-mainnet/bin/cardano-db-sync-mainnet - echo "Cleaning up" - -elif [[ "$NETWORK" == "preprod" ]]; then - echo "Connecting to network: preprod" - exec /nix/store/3qmpvpl9p1azinz2aqp4rgmhfymn7m2y-cardano-db-sync-preprod/bin/cardano-db-sync-preprod - echo "Cleaning up" - -elif [[ "$NETWORK" == "preview" ]]; then - echo "Connecting to network: preview" - exec /nix/store/km8zmilk90kb51q1qg4vf8d72dwb3w7l-cardano-db-sync-preview/bin/cardano-db-sync-preview - echo "Cleaning up" - -elif [[ "$NETWORK" == "private" ]]; then - echo "Connecting to network: private" - exec /nix/store/674zfi0nxjxbzmi9lbjm6pfdgdxhnvv2-cardano-db-sync-private/bin/cardano-db-sync-private - echo "Cleaning up" - -elif [[ "$NETWORK" == "sanchonet" ]]; then - echo "Connecting to network: sanchonet" - exec /scripts/govtool-sanchonet - echo "Cleaning up" - -elif [[ "$NETWORK" == "shelley_qa" ]]; then - echo "Connecting to network: shelley_qa" - exec /nix/store/2dv0dff02yx5cixxiacp2ha70z53hhc3-cardano-db-sync-shelley_qa/bin/cardano-db-sync-shelley_qa - echo "Cleaning up" - - -else - echo "Managed configuration for network "$NETWORK" does not exist" -fi diff --git a/scripts/govtool/dbsync/govtool-sanchonet b/scripts/govtool/dbsync/govtool-sanchonet deleted file mode 100755 index 8612cad47..000000000 --- a/scripts/govtool/dbsync/govtool-sanchonet +++ /dev/null @@ -1,3 +0,0 @@ -#!/nix/store/vqvj60h076bhqj6977caz0pfxs6543nb-bash-5.2-p15/bin/bash -set -euo pipefail -/scripts/govtool-dbsync $@ diff --git a/scripts/govtool/docker-compose.sanchonet.yml b/scripts/govtool/docker-compose.sanchonet.yml index 7278acddf..5c052a02d 100644 --- a/scripts/govtool/docker-compose.sanchonet.yml +++ b/scripts/govtool/docker-compose.sanchonet.yml @@ -160,13 +160,9 @@ services: - postgres_password - postgres_user - postgres_db - entrypoint: - - /scripts/govtool-entrypoint volumes: - db-sync-data:/var/lib/cexplorer - node-ipc:/node-ipc - - /home/ubuntu/config/cardano-node:/configuration - - /home/ubuntu/config/dbsync-scripts:/scripts restart: always logging: *logging diff --git a/scripts/govtool/prepare-config.sh b/scripts/govtool/prepare-config.sh index 9be21ebf3..062a1ecaf 100755 --- a/scripts/govtool/prepare-config.sh +++ b/scripts/govtool/prepare-config.sh @@ -7,13 +7,6 @@ config_dir="$repo_root_dir/scripts/govtool/config" target_config_dir="$repo_root_dir/scripts/govtool/config/target" mkdir -p "$target_config_dir" -# prepare a scripts directory for the DBSync entrypoint -dbsync_scripts_dir="$target_config_dir/dbsync-scripts" -mkdir -p "$dbsync_scripts_dir" -cp "$repo_root_dir/scripts/govtool/dbsync/govtool-entrypoint" "$dbsync_scripts_dir/govtool-entrypoint" -cp "$repo_root_dir/scripts/govtool/dbsync/govtool-sanchonet" "$dbsync_scripts_dir/govtool-sanchonet" -cp "$repo_root_dir/scripts/govtool/dbsync/govtool-dbsync" "$dbsync_scripts_dir/govtool-dbsync" - # cardano node config cardano_node_config_dir="$target_config_dir/cardano-node" mkdir -p "$cardano_node_config_dir"