Skip to content

Commit

Permalink
Merge pull request #2496 from IntersectMBO/develop
Browse files Browse the repository at this point in the history
GovTool - v1.0.30
  • Loading branch information
MSzalowski authored Dec 10, 2024
2 parents f3ecac2 + 60c5196 commit 4d1d28d
Show file tree
Hide file tree
Showing 64 changed files with 6,419 additions and 34,298 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/code_check_frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.NPMRC_TOKEN }}

- name: 🧪 Test
env:
NODE_OPTIONS: "--max_old_space_size=8192"
run: |
npm run test
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/frontend_sonar_scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ jobs:
- name: 🧪 Test
working-directory: govtool/frontend
env:
NODE_OPTIONS: "--max_old_space_size=6144"
NODE_AUTH_TOKEN: ${{ secrets.NPMRC_TOKEN }}
run: |
npm ci
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test_storybook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 16
node-version-file: "govtool/frontend/.nvmrc"
- name: Install dependencies
run: |
npm config set @intersect.mbo:registry "https://registry.npmjs.org/" --location=global
Expand All @@ -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: 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
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,26 @@ changes.

-

## [v1.0.30](https://github.com/IntersectMBO/govtool/releases/tag/v1.0.30) 2024-12-10

### Added

- Add stake key registration certificate to voting and gov action proposal if not registered [Issue 2490](https://github.com/IntersectMBO/govtool/issues/2490)

### Fixed

- Fix vulnerabilities in dependencies [Issue 2192](https://github.com/IntersectMBO/govtool/issues/2192)
- Optimize resources usage in frontend service build [Issue 2192](https://github.com/IntersectMBO/govtool/issues/2192)
- Fix sentry reports on multiple reloads of Governance Actions [Issue 2446](https://github.com/IntersectMBO/govtool/issues/2446)

### Changed

-

### Removed

-

## [v1.0.29](https://github.com/IntersectMBO/govtool/releases/tag/v1.0.29) 2024-12-05

### Added
Expand Down
2 changes: 1 addition & 1 deletion govtool/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ FROM $BASE_IMAGE_REPO:$BASE_IMAGE_TAG
WORKDIR /src
COPY . .
RUN cabal build
RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.7/vva-be-1.0.29/x/vva-be/build/vva-be/vva-be /usr/local/bin
RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.7/vva-be-1.0.30/x/vva-be/build/vva-be/vva-be /usr/local/bin
2 changes: 1 addition & 1 deletion govtool/backend/Dockerfile.qovery
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM $BASE_IMAGE_REPO:$BASE_IMAGE_TAG
WORKDIR /src
COPY . .
RUN cabal build
RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.7/vva-be-1.0.29/x/vva-be/build/vva-be/vva-be /usr/local/bin
RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.7/vva-be-1.0.30/x/vva-be/build/vva-be/vva-be /usr/local/bin

# Expose the necessary port
EXPOSE 9876
Expand Down
40 changes: 28 additions & 12 deletions govtool/backend/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

module Main where

import Control.Exception (Exception, SomeException, fromException, throw)
import Control.Exception (IOException, Exception, SomeException, fromException, throw)
import Control.Lens.Operators ((.~))
import Control.Monad
import Control.Monad.IO.Class
Expand All @@ -21,6 +21,7 @@ import Data.ByteString.Char8 (unpack)
import qualified Data.Cache as Cache
import Data.Function ((&))
import Data.Has (getter)
import Data.List (isInfixOf)
import Data.Monoid (mempty)
import Data.OpenApi (OpenApi, Server (Server), _openApiServers,
_serverDescription, _serverUrl, _serverVariables,
Expand Down Expand Up @@ -88,7 +89,8 @@ startApp vvaConfig sentryService = do
settings =
setPort vvaPort
$ setHost vvaHost
$ setTimeout 120 -- 120 seconds timeout
$ setTimeout 300-- 300 seconds timeout
$ setGracefulShutdownTimeout (Just 60) -- Allow 60 seconds for cleanup
$ setBeforeMainLoop
( Text.hPutStrLn stderr $
Text.pack
Expand Down Expand Up @@ -130,25 +132,39 @@ startApp vvaConfig sentryService = do

exceptionHandler :: VVAConfig -> SentryService -> Maybe Request -> SomeException -> IO ()
exceptionHandler vvaConfig sentryService mRequest exception = do
print mRequest
print exception
-- These are not considered application errors
-- They represent the client closing the connection prematurely
-- or the timeout thread being killed by WARP
let isNotTimeoutThread x = case fromException x of
Just TimeoutThread -> False
_ -> True
isNotConnectionClosedByPeer x = case fromException x of
Just ConnectionClosedByPeer -> False
_ -> True
guard . isNotTimeoutThread $ exception
guard . isNotConnectionClosedByPeer $ exception
let env = sentryEnv vvaConfig
register
sentryService
"vva.be"
Error
(formatMessage mRequest exception)
(recordUpdate env mRequest exception)
isNotClientClosedConnection x =
case fromException x of
Just ioe -> not ("Warp: Client closed connection prematurely" `isInfixOf` show (ioe :: IOException))
Nothing -> True
isNotThreadKilledByTimeoutManager x =
"Thread killed by timeout manager" `notElem` lines (show x)
shouldSkipError =
isNotTimeoutThread exception &&
isNotConnectionClosedByPeer exception &&
isNotClientClosedConnection exception &&
isNotThreadKilledByTimeoutManager exception

guard shouldSkipError

let env = sentryEnv vvaConfig
case mRequest of
Nothing -> return ()
Just _ -> register
sentryService
"vva.be"
Error
(formatMessage mRequest exception)
(recordUpdate env mRequest exception)

formatMessage :: Maybe Request -> SomeException -> String
formatMessage Nothing exception = "Exception before request could be parsed: " ++ show exception
Expand Down
4 changes: 2 additions & 2 deletions govtool/backend/sql/list-proposals.sql
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ SELECT
encode(creator_tx.hash, 'hex'),
gov_action_proposal.index,
gov_action_proposal.type::text,
(
COALESCE(
case when gov_action_proposal.type = 'TreasuryWithdrawals' then
(
select json_agg(
Expand Down Expand Up @@ -159,7 +159,7 @@ SELECT
else
null
end
) as description,
, '{}'::json) as description,
CASE
WHEN meta.network_name::text = 'mainnet' OR meta.network_name::text = 'preprod' THEN
latest_epoch.start_time + (gov_action_proposal.expiration - latest_epoch.no)::bigint * INTERVAL '5 days'
Expand Down
2 changes: 1 addition & 1 deletion govtool/backend/src/VVA/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Control.Exception (throw, throwIO)
import Control.Monad.Except (runExceptT, throwError)
import Control.Monad.Reader

import Data.Aeson (Value(..), Array, decode, encode, FromJSON, ToJSON, toJSON)
import Data.Aeson (Value(..), Array, decode, encode, ToJSON, toJSON)
import Data.Bool (Bool)
import Data.List (sortOn)
import qualified Data.Map as Map
Expand Down
37 changes: 22 additions & 15 deletions govtool/backend/src/VVA/Proposal.hs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ScopedTypeVariables #-}

module VVA.Proposal where

import Control.Exception (throw)
import Control.Exception (throw, SomeException, try)
import Control.Monad.Except (MonadError, throwError)
import Control.Monad.Reader

Expand Down Expand Up @@ -70,11 +71,17 @@ getProposals ::
Maybe [Text] -> m [Proposal]
getProposals mSearchTerms = withPool $ \conn -> do
let searchParam = maybe "" head mSearchTerms
liftIO $ SQL.query conn listProposalsSql
( searchParam
, "%" <> searchParam <> "%"
, "%" <> searchParam <> "%"
, "%" <> searchParam <> "%"
, "%" <> searchParam <> "%"
, "%" <> searchParam <> "%"
)
liftIO $ do
result <- try $ SQL.query conn listProposalsSql
( searchParam
, "%" <> searchParam <> "%"
, "%" <> searchParam <> "%"
, "%" <> searchParam <> "%"
, "%" <> searchParam <> "%"
, "%" <> searchParam <> "%"
)
case result of
Left (e :: SomeException) -> do
return []
Right rows -> do
return rows
2 changes: 1 addition & 1 deletion govtool/backend/vva-be.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.6
name: vva-be
version: 1.0.29
version: 1.0.30

-- A short (one-line) description of the package.
-- synopsis:
Expand Down
8 changes: 3 additions & 5 deletions govtool/frontend/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ import type { StorybookConfig } from "@storybook/react-vite";
const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-jest",
"@storybook/addon-links",
"@storybook/addon-onboarding",
"@storybook/addon-interactions",
],
framework: {
name: "@storybook/react-vite",
options: {},
},
docs: {
autodocs: "tag",
},
docs: {},
};
export default config;
47 changes: 25 additions & 22 deletions govtool/frontend/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { MemoryRouter, Route, Routes } from "react-router-dom";
import { FeatureFlagProvider } from "../src/context/featureFlag";
import { AppContextProvider } from "../src/context/appContext";
import { ModalProvider } from "../src/context/modal";
import { CardanoProvider } from "../src/context/wallet";
import i18n from "../src/i18n";
import { theme } from "../src/theme";

Expand All @@ -29,28 +30,30 @@ const preview: Preview = {
<AppContextProvider>
<FeatureFlagProvider>
<ThemeProvider theme={theme}>
<ModalProvider>
<I18nextProvider i18n={i18n}>
<MemoryRouter>
<Routes>
<Route
path="/*"
element={
<div
style={{
margin: "0px",
padding: "0px",
position: "relative",
}}
>
<Story />
</div>
}
/>
</Routes>
</MemoryRouter>
</I18nextProvider>
</ModalProvider>
<CardanoProvider>
<ModalProvider>
<I18nextProvider i18n={i18n}>
<MemoryRouter>
<Routes>
<Route
path="/*"
element={
<div
style={{
margin: "0px",
padding: "0px",
position: "relative",
}}
>
<Story />
</div>
}
/>
</Routes>
</MemoryRouter>
</I18nextProvider>
</ModalProvider>
</CardanoProvider>
</ThemeProvider>
</FeatureFlagProvider>
</AppContextProvider>
Expand Down
13 changes: 0 additions & 13 deletions govtool/frontend/.storybook/test-runner-jest.js

This file was deleted.

4 changes: 2 additions & 2 deletions govtool/frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ RUN \
: "${VITE_IPFS_GATEWAY:?Build argument VITE_IPFS_GATEWAY is not set}" && \
: "${VITE_IPFS_PROJECT_ID:?Build argument VITE_IPFS_PROJECT_ID is not set}"

ENV NODE_OPTIONS=--max_old_space_size=8192

WORKDIR /src

# Set npm configuration settings using environment variables
RUN npm config set @intersect.mbo:registry "https://registry.npmjs.org/" --location=global
RUN npm config set //registry.npmjs.org/:_authToken ${NPMRC_TOKEN} --location=global

COPY package.json package-lock.json ./
COPY patches ./patches

RUN npm install
COPY . .
RUN npm run build
Expand Down
4 changes: 2 additions & 2 deletions govtool/frontend/Dockerfile.qovery
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ ARG VITE_PDF_API_URL
ARG VITE_IPFS_GATEWAY
ARG VITE_IPFS_PROJECT_ID

ENV NODE_OPTIONS=--max_old_space_size=8192

WORKDIR /src

# Set npm configuration settings using environment variables
RUN npm config set @intersect.mbo:registry "https://registry.npmjs.org/" --location=global
RUN npm config set //registry.npmjs.org/:_authToken ${NPMRC_TOKEN} --location=global

COPY package.json package-lock.json ./
COPY patches ./patches

RUN npm install
COPY . .
RUN npm run build
Expand Down
Loading

0 comments on commit 4d1d28d

Please sign in to comment.