Skip to content

Commit

Permalink
Merge pull request #1332 from IntersectMBO/staging
Browse files Browse the repository at this point in the history
sancho-v1.0.7
  • Loading branch information
MSzalowski authored Jun 27, 2024
2 parents 5a732fc + 1e8b49e commit b03f9ba
Show file tree
Hide file tree
Showing 153 changed files with 6,021 additions and 681 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/build-and-deploy-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,20 @@ on:
options:
- "enabled"
- "disabled"
forceRebuildDockerImages:
description: "Force rebuild the docker images"
required: false
type: choice
default: "false"
options:
- "true"
- "false"

env:
ENVIRONMENT: "beta"
CARDANO_NETWORK: "sanchonet"
DOMAIN: "sanchogov.tools"
FORCE_REBUILD: ${{inputs.forceRebuildDockerImages == 'true'}}

jobs:
deploy:
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/build-and-deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,20 @@ on:
options:
- "enabled"
- "disabled"
forceRebuildDockerImages:
description: "Force rebuild the docker images"
required: false
type: choice
default: "false"
options:
- "true"
- "false"

env:
ENVIRONMENT: "dev"
CARDANO_NETWORK: "sanchonet"
DOMAIN: "dev-sanchonet.govtool.byron.network"
FORCE_REBUILD: ${{inputs.forceRebuildDockerImages == 'true'}}

jobs:
deploy:
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/build-and-deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@ on:
options:
- "enabled"
- "disabled"
forceRebuildDockerImages:
description: "Force rebuild the docker images"
required: false
type: choice
default: "false"
options:
- "true"
- "false"

env:
ENVIRONMENT: "staging"
CARDANO_NETWORK: "sanchonet"
DOMAIN: "staging.govtool.byron.network"
FORCE_REBUILD: ${{inputs.forceRebuildDockerImages == 'true'}}

jobs:
deploy:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/build-and-deploy-test-stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
push:
branches:
- test
- infra/test-chores

env:
ENVIRONMENT: "test"
Expand All @@ -21,9 +22,10 @@ jobs:
SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }}
GTM_ID: ${{ secrets.GTM_ID }}
NPMRC_TOKEN: ${{ secrets.NPMRC_TOKEN }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN_FRONTEND }}
SENTRY_DSN_FRONTEND: ${{ secrets.SENTRY_DSN_FRONTEND }}
PIPELINE_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
USERSNAP_SPACE_API_KEY: ${{ secrets.USERSNAP_SPACE_API_KEY }}
APP_ENV: test
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/build-and-deploy-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@ on:
options:
- "enabled"
- "disabled"
forceRebuildDockerImages:
description: "Force rebuild the docker images"
required: false
type: choice
default: "false"
options:
- "true"
- "false"

env:
ENVIRONMENT: "test"
CARDANO_NETWORK: "sanchonet"
DOMAIN: "test-sanchonet.govtool.byron.network"
FORCE_REBUILD: ${{inputs.forceRebuildDockerImages == 'true'}}

jobs:
deploy:
Expand Down
20 changes: 6 additions & 14 deletions .github/workflows/frontend_sonar_scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,19 @@ jobs:
uses: actions/setup-node@v4
with:
node-version-file: "govtool/frontend/.nvmrc"

registry-url: "https://registry.npmjs.org/"
scope: "@intersect.mbo"
- name: 🧪 Test
working-directory: govtool/frontend
env:
NODE_OPTIONS: "--max_old_space_size=4096"
NODE_OPTIONS: "--max_old_space_size=6144"
NODE_AUTH_TOKEN: ${{ secrets.NPMRC_TOKEN }}
run: |
npm install
npm ci
npm run test:coverage
# Running with docker
#
# - name: Run SonarQube Scanner
# run: |
# docker run --rm \
# -e SONAR_HOST_URL="https://sonarcloud.io" \
# -e SONAR_TOKEN="ec4183646e59dd70c8077acfabe52062ccbea7a9" \
# -v "$(pwd):/usr/src" \
# --workdir=/usr/src/govtool/frontend \
# sonarsource/sonar-scanner-cli:5.0.1

- uses: sonarsource/sonarqube-scan-action@master
if: always()
with:
projectBaseDir: govtool/frontend
env:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test_backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
KUBER_API_URL: https://kuber-govtool.cardanoapi.io

- name: Upload report
if: always()
uses: actions/upload-artifact@v3
with:
name: allure-results
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_storybook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Install Playwright
run: npx playwright install --with-deps
- name: Build Storybook
run: NODE_OPTIONS="--max-old-space-size=8046" npm run build-storybook --quiet
run: NODE_OPTIONS="--max-old-space-size=8046" npm run build:storybook --quiet
- name: Serve Storybook and run tests
run: |
npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ changes.

## [Unreleased]

- Added 'sentryenv' field in backend config file [Issue 1401](https://github.com/IntersectMBO/govtool/issues/1401)
- Add wallet connector package [Issue 898](https://github.com/IntersectMBO/govtool/issues/898)
- Change DRep without metadata name from "Sole Voter" to "Direct Voter" [Issue 880](https://github.com/IntersectMBO/govtool/issues/880)
- Inicialize Usersnap into App [Issue 546](https://github.com/IntersectMBO/govtool/issues/546)
Expand Down Expand Up @@ -63,9 +64,16 @@ changes.
- Add eslint & prettier to frontend package [Issue 166](https://github.com/IntersectMBO/govtool/issues/166)
- Add DRep list pagination [Issue 740](https://github.com/IntersectMBO/govtool/issues/740)
- Add PDF pillar [Issue 1090](https://github.com/IntersectMBO/govtool/issues/1090)
- Replace govtool-wrapper governance action creation in favor of pdf-pillar [Issue 1284](https://github.com/IntersectMBO/govtool/issues/1284)
- Add sentry environment config [Issue 1324](https://github.com/IntersectMBO/govtool/issues/1324)
- Add proposal discussion pillar to home page [Issue 1431](https://github.com/IntersectMBO/govtool/issues/1431)

### Fixed

- silenced `Thread killed by timeout manager` sentry log [Issue 1417](https://github.com/IntersectMBO/govtool/issues/1417)
- silenced `Warp: Client closed connection prematurely` error [Issue 1422](https://github.com/IntersectMBO/govtool/issues/1422)
- backend is now compiled with -threaded [Issue 1148](https://github.com/IntersectMBO/govtool/issues/1148)
- drep/get-voting-power no longer throws 500 for non-existing dreps. Instead it returns 0 [Issue 1093](https://github.com/IntersectMBO/govtool/issues/1093)
- proposal/list no longer throws 500 error when proposal's url is incorrect [Issue 1073](https://github.com/IntersectMBO/govtool/issues/1073)
- drep/list sql fix (now the drep type is correct) [Issue 957](https://github.com/IntersectMBO/govtool/issues/957)
- drep/list sql fix (now the latest tx date is correct) [Issue 826](https://github.com/IntersectMBO/govtool/issues/826)
Expand Down Expand Up @@ -94,6 +102,10 @@ changes.
- Remove wrongly appended `Yourself` filter on DRep Directory [Issue 1028](https://github.com/IntersectMBO/govtool/issues/1028)
- Fix validation of uris in metadata [Issue 1011](https://github.com/IntersectMBO/govtool/issues/1011)
- Fix wrong link to the GA Details once it is in progress [Issue 1252](https://github.com/IntersectMBO/govtool/issues/1252)
- Fix validation of the GAs with missing references [Issue 1282](https://github.com/IntersectMBO/govtool/issues/1282)
- Fix displaying the GA Markdowns [Issue 1244](https://github.com/IntersectMBO/govtool/issues/1244)
- Fix app crash on voting on the GA without the connected wallet before [Issue 1313](https://github.com/IntersectMBO/govtool/issues/1313)
- Fix the navigation to Home from Proposal pillar on disconnected wallet [Issue 1355](https://github.com/IntersectMBO/govtool/issues/1355)

### Changed

Expand Down Expand Up @@ -126,6 +138,7 @@ changes.
- Changed documents to prepare for open source [Issue 737](https://github.com/IntersectMBO/govtool/issues/737)
- Changed copy on maintenance page [Issue 753](https://github.com/IntersectMBO/govtool/issues/753)
- Update link to docs [Issue 1246](https://github.com/IntersectMBO/govtool/issues/1246)
- Change label of Proposal Discussion nav item [Issue 1349](https://github.com/IntersectMBO/govtool/issues/1349)

### Removed

Expand Down
43 changes: 43 additions & 0 deletions docs/GOVERNANCE_ACTION_SUBMISSION.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,46 @@ await buildSignSubmitConwayCertTx({
### Step 6: Verify the Governance Action

`buildSignSubmitConwayCertTx` logs the transaction CBOR making it able to be tracked on the transactions tools such as cexplorer.

## Additional steps for using the GovTool metadata validation on the imported Pillar component

```tsx
enum MetadataValidationStatus {
URL_NOT_FOUND = "URL_NOT_FOUND",
INVALID_JSONLD = "INVALID_JSONLD",
INVALID_HASH = "INVALID_HASH",
INCORRECT_FORMAT = "INCORRECT_FORMAT",
}
// Using the props passed to the component
type Props = {
validateMetadata: ({
url,
hash,
standard,
}: {
url: string;
hash: string;
standard: "CIP108";
}) => Promise<{
metadata?: any;
status?: MetadataValidationStatus;
valid: boolean;
}>;
};

import React, { Suspense } from "react";

const SomeImportedPillar: React.FC<Props> = React.lazy(
() => import("path/to/SomeImportedPillar")
);

const SomeWrapperComponent = () => {
const { validateMetadata } = useValidateMutation();

return (
<Suspense fallback={<div>I am lazy loading...</div>}>
<SomeImportedPillar validateMetadata={validateMetadata} />
</Suspense>
);
};
```
14 changes: 9 additions & 5 deletions govtool/backend/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ exceptionHandler :: VVAConfig -> Maybe Request -> SomeException -> IO ()
exceptionHandler vvaConfig mRequest exception = do
print mRequest
print exception
guard (show exception /= "Thread killed by timeout manager")
guard (show exception /= "Warp: Client closed connection prematurely")
let env = sentryEnv vvaConfig
sentryService <-
initRaven
(sentryDSN vvaConfig)
Expand All @@ -154,20 +157,21 @@ exceptionHandler vvaConfig mRequest exception = do
"vva.be"
Error
(formatMessage mRequest exception)
(recordUpdate mRequest exception)
(recordUpdate env mRequest exception)



formatMessage :: Maybe Request -> SomeException -> String
formatMessage Nothing exception = "Exception before request could be parsed: " ++ show exception
formatMessage (Just request) exception = "Exception " ++ show exception ++ " while handling request " ++ show request

recordUpdate :: Maybe Request -> SomeException -> SentryRecord -> SentryRecord
recordUpdate Nothing exception record = record
recordUpdate (Just request) exception record =
recordUpdate :: String -> Maybe Request -> SomeException -> SentryRecord -> SentryRecord
recordUpdate env Nothing exception record = record { srEnvironment = Just env }
recordUpdate env (Just request) exception record =
record
{ srCulprit = Just $ unpack $ rawPathInfo request,
srServerName = unpack <$> requestHeaderHost request
srServerName = unpack <$> requestHeaderHost request,
srEnvironment = Just env
}

shouldDisplayException :: SomeException -> Bool
Expand Down
1 change: 1 addition & 0 deletions govtool/backend/example-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"host" : "localhost",
"cachedurationseconds": 20,
"sentrydsn": "https://username:[email protected]/id",
"sentryenv": "dev",
"metadatavalidationhost": "localhost",
"metadatavalidationport": 3001,
"metadatavalidationmaxconcurrentrequests": 10
Expand Down
6 changes: 6 additions & 0 deletions govtool/backend/src/VVA/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ data VVAConfigInternal
, vVaConfigInternalCacheDurationSeconds :: Int
-- | Sentry DSN
, vVAConfigInternalSentrydsn :: String
-- | Sentry environment
, vVAConfigInternalSentryEnv :: String
-- | Metadata validation service host
, vVAConfigInternalMetadataValidationHost :: Text
-- | Metadata validation service port
Expand All @@ -97,6 +99,7 @@ instance DefaultConfig VVAConfigInternal where
vVAConfigInternalHost = "localhost",
vVaConfigInternalCacheDurationSeconds = 20,
vVAConfigInternalSentrydsn = "https://username:[email protected]/id",
vVAConfigInternalSentryEnv = "development",
vVAConfigInternalMetadataValidationHost = "localhost",
vVAConfigInternalMetadataValidationPort = 3001,
vVAConfigInternalMetadataValidationMaxConcurrentRequests = 10
Expand All @@ -115,6 +118,8 @@ data VVAConfig
, cacheDurationSeconds :: Int
-- | Sentry DSN
, sentryDSN :: String
-- | Sentry environment
, sentryEnv :: String
-- | Metadata validation service host
, metadataValidationHost :: Text
-- | Metadata validation service port
Expand Down Expand Up @@ -161,6 +166,7 @@ convertConfig VVAConfigInternal {..} =
serverHost = vVAConfigInternalHost,
cacheDurationSeconds = vVaConfigInternalCacheDurationSeconds,
sentryDSN = vVAConfigInternalSentrydsn,
sentryEnv = vVAConfigInternalSentryEnv,
metadataValidationHost = vVAConfigInternalMetadataValidationHost,
metadataValidationPort = vVAConfigInternalMetadataValidationPort,
metadataValidationMaxConcurrentRequests = vVAConfigInternalMetadataValidationMaxConcurrentRequests
Expand Down
6 changes: 4 additions & 2 deletions govtool/backend/src/VVA/DRep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ getVotingPower ::
Text ->
m Integer
getVotingPower drepId = withPool $ \conn -> do
[SQL.Only votingPower] <-
result <-
liftIO
(SQL.query @_ @(SQL.Only Scientific) conn getVotingPowerSql $ SQL.Only drepId)
return $ floor votingPower
case result of
[SQL.Only votingPower] -> return $ floor votingPower
[] -> return 0

listDRepsSql :: SQL.Query
listDRepsSql = sqlFrom $(embedFile "sql/list-dreps.sql")
Expand Down
2 changes: 2 additions & 0 deletions govtool/backend/vva-be.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ executable vva-be

hs-source-dirs: app
default-language: Haskell2010
ghc-options: -threaded

library
hs-source-dirs: src
Expand Down Expand Up @@ -118,3 +119,4 @@ library
, VVA.Types
, VVA.Network
, VVA.Metadata
ghc-options: -threaded
1 change: 1 addition & 0 deletions govtool/frontend/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
VITE_APP_ENV="development"
VITE_BASE_URL=""
VITE_NETWORK_FLAG=0
VITE_SENTRY_DSN=""
Expand Down
2 changes: 2 additions & 0 deletions govtool/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM node:18-alpine as builder

ARG VITE_APP_ENV='beta'
ARG VITE_BASE_URL
ARG VITE_GTM_ID
ARG VITE_NETWORK_FLAG=0
Expand Down
Loading

0 comments on commit b03f9ba

Please sign in to comment.