Skip to content

Commit 9e02a43

Browse files
authored
Merge pull request #3811 from IntersectMBO/staging
v2.0.26.1
2 parents 870f0ec + b5587e2 commit 9e02a43

File tree

23 files changed

+510
-85
lines changed

23 files changed

+510
-85
lines changed
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
name: Check and Build QA
2+
3+
on:
4+
push:
5+
branches:
6+
- test
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
packages: write
13+
14+
jobs:
15+
check-build:
16+
if: contains(fromJson('["test"]'), github.ref_name)
17+
environment: ${{ matrix.network }}
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
include:
22+
- branch: test
23+
network: qa-govtool
24+
workdir: ./govtool/backend
25+
name: govtool-backend
26+
dockerfile: ./govtool/backend/Dockerfile.qovery
27+
image: ghcr.io/${{ github.repository }}-backend
28+
qovery_container_name: govtool-backend
29+
- branch: test
30+
network: qa-govtool
31+
workdir: ./govtool/frontend
32+
name: govtool-frontend
33+
dockerfile: ./govtool/frontend/Dockerfile.qovery
34+
image: ghcr.io/${{ github.repository }}-frontend
35+
qovery_container_name: govtool-frontend
36+
- branch: test
37+
network: qa-govtool
38+
workdir: ./govtool/metadata-validation
39+
name: govtool-metadata-validation
40+
dockerfile: ./govtool/metadata-validation/Dockerfile
41+
image: ghcr.io/${{ github.repository }}-metadata-validation
42+
qovery_container_name: govtool-metadata-validation
43+
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Checkout code
47+
uses: actions/checkout@v4
48+
49+
- name: Ensure Job Runs Only for Matching Branch
50+
if: github.ref_name != matrix.branch
51+
run: |
52+
echo "Branch mismatch, exiting..."
53+
exit 0
54+
55+
- name: Set TAG Environment Variable
56+
id: set_tag
57+
run: |
58+
SANITIZED_BRANCH=$(echo "${{ github.ref_name }}" | tr '/' '-')
59+
echo "COMMIT_TAG=${SANITIZED_BRANCH}-${{ github.sha }}-${{ github.run_number }}" >> $GITHUB_ENV
60+
echo "STATIC_TAG=qa-latest" >> $GITHUB_ENV
61+
echo "Generated TAG: $COMMIT_TAG"
62+
echo "Generated STATIC_TAG: $STATIC_TAG"
63+
64+
65+
- name: Lint Dockerfile
66+
id: hadolint
67+
uses: hadolint/[email protected]
68+
with:
69+
failure-threshold: error
70+
format: json
71+
dockerfile: ${{ matrix.dockerfile }}
72+
# output-file: hadolint_output.json
73+
74+
- name: Save Hadolint output
75+
id: save_hadolint_output
76+
if: always()
77+
run: cd ${{ matrix.workdir }} && echo "$HADOLINT_RESULTS" | jq '.' > hadolint_output.json
78+
79+
- name: Print Dockerfile lint output
80+
run: |
81+
cd ${{ matrix.workdir }}
82+
echo "-----HADOLINT RESULT-----"
83+
echo "Outcome: ${{ steps.hadolint.outcome }}"
84+
echo "-----DETAILS--------"
85+
cat hadolint_output.json
86+
echo "--------------------"
87+
88+
- name: Code lint
89+
id: code_lint
90+
run: |
91+
cd ${{ matrix.workdir }}
92+
if [ ! -f lint.sh ]; then
93+
echo "lint skipped" | tee code_lint_output.txt
94+
exit 0
95+
fi
96+
set -o pipefail
97+
sudo chmod +x lint.sh && ./lint.sh 2>&1 | tee code_lint_output.txt
98+
99+
- name: Unit tests
100+
id: unit_tests
101+
run: |
102+
cd ${{ matrix.workdir }}
103+
if [ ! -f unit-test.sh ]; then
104+
echo "unit tests skipped" | tee code_lint_output.txt
105+
exit 0
106+
fi
107+
set -o pipefail
108+
sudo chmod +x unit-test.sh && ./unit-test.sh 2>&1 | tee unit_test_output.txt
109+
110+
- name: Set up Docker Buildx
111+
uses: docker/setup-buildx-action@v2
112+
113+
- name: Cache Docker layers
114+
uses: actions/cache@v4
115+
with:
116+
path: /tmp/.buildx-cache
117+
key: ${{ runner.os }}-buildx-${{ github.sha }}-${{ github.run_number}}
118+
restore-keys: |
119+
${{ runner.os }}-buildx-
120+
121+
- id: image_lowercase
122+
uses: ASzc/change-string-case-action@v6
123+
with:
124+
string: ${{ matrix.image }}
125+
126+
- name: Set ENVIRONMENT Variable
127+
run: echo "ENVIRONMENT=${{ matrix.network }}" >> $GITHUB_ENV
128+
129+
- name: Sanitize Network Name
130+
run: |
131+
CLEAN_NETWORK=$(echo "${{ matrix.network }}" | sed 's/-govtool$//')
132+
echo "CLEAN_NETWORK=$CLEAN_NETWORK" >> $GITHUB_ENV
133+
134+
- name: Build Docker image
135+
uses: docker/build-push-action@v5
136+
with:
137+
context: ${{ matrix.workdir }}
138+
file: ${{ matrix.dockerfile }}
139+
tags: >
140+
${{ steps.image_lowercase.outputs.lowercase }}-${{ env.CLEAN_NETWORK }}:${{ env.COMMIT_TAG }},
141+
${{ steps.image_lowercase.outputs.lowercase }}-${{ env.CLEAN_NETWORK }}:${{ env.STATIC_TAG }}
142+
load: false
143+
cache-from: type=local,src=/tmp/.buildx-cache
144+
cache-to: type=local,dest=/tmp/.buildx-cache
145+
outputs: type=docker,dest=/tmp/image-${{ matrix.name }}-${{ env.ENVIRONMENT }}.tar
146+
build-args: |
147+
VITE_APP_ENV=${{ secrets.VITE_APP_ENV }}
148+
VITE_BASE_URL=${{ secrets.VITE_BASE_URL }}
149+
VITE_METADATA_API_URL=${{ secrets.VITE_METADATA_API_URL }}
150+
VITE_NETWORK_FLAG=${{ secrets.VITE_NETWORK_FLAG }}
151+
VITE_SENTRY_DSN=${{ secrets.VITE_SENTRY_DSN }}
152+
VITE_USERSNAP_SPACE_API_KEY=${{ secrets.VITE_USERSNAP_SPACE_API_KEY }}
153+
VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED=${{ secrets.VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED }}
154+
VITE_IS_GOVERNANCE_OUTCOMES_PILLAR_ENABLED=${{ secrets.VITE_IS_GOVERNANCE_OUTCOMES_PILLAR_ENABLED }}
155+
VITE_OUTCOMES_API_URL=${{secrets.VITE_OUTCOMES_API_URL}}
156+
VITE_PDF_API_URL=${{ secrets.VITE_PDF_API_URL }}
157+
VITE_IPFS_GATEWAY=${{ secrets.IPFS_GATEWAY }}
158+
VITE_IPFS_PROJECT_ID=${{ secrets.IPFS_PROJECT_ID }}
159+
IPFS_GATEWAY=${{ secrets.IPFS_GATEWAY }}
160+
IPFS_PROJECT_ID=${{ secrets.IPFS_PROJECT_ID }}
161+
162+
- name: Login to GHCR
163+
uses: docker/login-action@v2
164+
with:
165+
registry: ghcr.io
166+
username: ${{ github.actor }}
167+
password: ${{ secrets.GITHUB_TOKEN }}
168+
169+
- name: Scan Docker image with Dockle
170+
id: dockle
171+
run: |
172+
wget -q https://github.com/goodwithtech/dockle/releases/download/v0.4.14/dockle_0.4.14_Linux-64bit.tar.gz
173+
tar zxf dockle_0.4.14_Linux-64bit.tar.gz
174+
sudo mv dockle /usr/local/bin
175+
176+
dockle --exit-code 1 --exit-level fatal --format json -ak GHC_RELEASE_KEY -ak CABAL_INSTALL_RELEASE_KEY -ak STACK_RELEASE_KEY -ak KEY_SHA512 --input '/tmp/image-${{ matrix.name }}-${{ env.ENVIRONMENT }}.tar' --output ${{ matrix.workdir }}/dockle_scan_output.json
177+
echo " dockle exited w/ $?"
178+
cat ${{ matrix.workdir }}/dockle_scan_output.json
179+
180+
echo "outcome=success" >> $GITHUB_OUTPUT
181+
182+
- name: Debug TAG Before Docker Push
183+
run: |
184+
echo "Lowercase Image: ${{ steps.image_lowercase.outputs.lowercase }}"
185+
echo "Network: ${{ matrix.network }}"
186+
echo "COMMIT_TAG: ${{ env.COMMIT_TAG }}"
187+
echo "STATIC_TAG: ${{ env.STATIC_TAG }}"
188+
echo "Final Docker Tag: ${{ steps.image_lowercase.outputs.lowercase }}-${{ matrix.network}}:${{ env.TAG }}"
189+
190+
- name: Push Docker image to GHCR
191+
run: |
192+
docker load -i '/tmp/image-${{ matrix.name }}-${{ env.ENVIRONMENT }}.tar'
193+
rm -rf '/tmp/image-${{ matrix.name }}-${{ env.ENVIRONMENT }}.tar'
194+
docker push ${{ steps.image_lowercase.outputs.lowercase }}-${{ env.CLEAN_NETWORK}}:${{ env.COMMIT_TAG }}
195+
docker push ${{ steps.image_lowercase.outputs.lowercase }}-${{ env.CLEAN_NETWORK}}:${{ env.STATIC_TAG }}
196+
197+
- name: Notify Qovery of new image tag
198+
run: |
199+
curl -X POST https://api.qovery.com/organization/${{ secrets.QOVERY_ORG_ID }}/container/deploy \
200+
-H "Authorization: Token ${{ secrets.QOVERY_API_TOKEN }}" \
201+
-H "Content-Type: application/json" \
202+
-d '{
203+
"image_name": "${{ steps.image_lowercase.outputs.lowercase }}-${{ env.CLEAN_NETWORK }}",
204+
"tag": "${{ env.COMMIT_TAG }}"
205+
}'
206+
207+
- name: Add tag as a PR comment
208+
uses: ubie-oss/[email protected]
209+
id: comment-to-merged-pr
210+
with:
211+
github-token: ${{ secrets.GITHUB_TOKEN }}
212+
message: |-
213+
This PR is in the tag: ${{ env.COMMIT_TAG }} , for ${{ matrix.name }} service

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ changes.
1313
### Added
1414

1515
- Preserve maintenance ending banner state on the wallet connection change [Issue 3681](https://github.com/IntersectMBO/govtool/issues/3681)
16+
- Add authors for Live Voting Governance Actions [Issue 3745](https://github.com/IntersectMBO/govtool/issues/3745)
1617

1718
### Fixed
1819

docs/GOVERNANCE_ACTION_SUBMISSION.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ const buildProtocolParameterChangeGovernanceAction: (
134134
protocolParameterChangeProps: ProtocolParameterChangeProps
135135
) => Promise<VotingProposalBuilder | undefined>;
136136

137-
const buildHardForkInitiationGovernanceAction: (
137+
const buildHardForkGovernanceAction: (
138138
hardForkInitiationProps: HardForkInitiationProps
139139
) => Promise<VotingProposalBuilder | undefined>;
140140

@@ -210,7 +210,7 @@ const {
210210
buildSignSubmitConwayCertTx,
211211
buildNewInfoGovernanceAction,
212212
buildProtocolParameterChangeGovernanceAction,
213-
buildHardForkInitiationGovernanceAction,
213+
buildHardForkGovernanceAction,
214214
buildTreasuryGovernanceAction,
215215
buildNewConstitutionGovernanceAction,
216216
buildUpdateCommitteeGovernanceAction,
@@ -241,7 +241,7 @@ govActionBuilder = await buildProtocolParameterChangeGovernanceAction({
241241
});
242242

243243
// hash of the previous Governance Action, index of the previous Governance Action, url of the metadata, hash of the metadata, and the major and minor numbers of the hard fork initiation
244-
govActionBuilder = await buildHardForkInitiationGovernanceAction({
244+
govActionBuilder = await buildHardForkGovernanceAction({
245245
prevGovernanceActionHash,
246246
prevGovernanceActionIndex,
247247
url,

govtool/backend/sql/list-proposals.sql

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,18 @@ SELECT
303303
COALESCE(cv.ccNoVotes, 0) cc_no_votes,
304304
COALESCE(cv.ccAbstainVotes, 0) cc_abstain_votes,
305305
prev_gov_action.index as prev_gov_action_index,
306-
encode(prev_gov_action_tx.hash, 'hex') as prev_gov_action_tx_hash
306+
encode(prev_gov_action_tx.hash, 'hex') as prev_gov_action_tx_hash,
307+
COALESCE(
308+
json_agg(
309+
json_build_object(
310+
'name', off_chain_vote_author.name,
311+
'witnessAlgorithm', off_chain_vote_author.witness_algorithm,
312+
'publicKey', off_chain_vote_author.public_key,
313+
'signature', off_chain_vote_author.signature
314+
)
315+
) FILTER (WHERE off_chain_vote_author.id IS NOT NULL),
316+
'[]'
317+
) authors
307318
FROM
308319
gov_action_proposal
309320
JOIN ActiveProposals ON gov_action_proposal.id = ActiveProposals.id
@@ -314,6 +325,7 @@ FROM
314325
LEFT JOIN block AS creator_block ON creator_block.id = creator_tx.block_id
315326
LEFT JOIN voting_anchor ON voting_anchor.id = gov_action_proposal.voting_anchor_id
316327
LEFT JOIN off_chain_vote_data ON off_chain_vote_data.voting_anchor_id = voting_anchor.id
328+
lEFT JOIN off_chain_vote_author ON off_chain_vote_author.off_chain_vote_data_id = off_chain_vote_data.id
317329
LEFT JOIN off_chain_vote_gov_action_data ON off_chain_vote_gov_action_data.off_chain_vote_data_id = off_chain_vote_data.id
318330
LEFT JOIN param_proposal AS proposal_params ON gov_action_proposal.param_proposal = proposal_params.id
319331
LEFT JOIN cost_model AS cost_model ON proposal_params.cost_model_id = cost_model.id
@@ -355,4 +367,4 @@ GROUP BY
355367
off_chain_vote_gov_action_data.title,
356368
off_chain_vote_gov_action_data.abstract,
357369
off_chain_vote_gov_action_data.motivation,
358-
off_chain_vote_gov_action_data.rationale;
370+
off_chain_vote_gov_action_data.rationale;

govtool/backend/src/VVA/API.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ proposalToResponse timeZone Types.Proposal {..} =
244244
proposalResponseCcNoVotes = proposalCcNoVotes,
245245
proposalResponseCcAbstainVotes = proposalCcAbstainVotes,
246246
proposalResponsePrevGovActionIndex = proposalPrevGovActionIndex,
247-
proposalResponsePrevGovActionTxHash = HexText <$> proposalPrevGovActionTxHash
247+
proposalResponsePrevGovActionTxHash = HexText <$> proposalPrevGovActionTxHash,
248+
proposalResponseAuthors = ProposalAuthors <$> proposalAuthors
248249
}
249250

250251
voteToResponse :: Types.Vote -> VoteParams

govtool/backend/src/VVA/API/Types.hs

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,52 @@ data ProposalResponse
401401
, proposalResponseCcAbstainVotes :: Integer
402402
, proposalResponsePrevGovActionIndex :: Maybe Integer
403403
, proposalResponsePrevGovActionTxHash :: Maybe HexText
404+
, proposalResponseAuthors :: Maybe ProposalAuthors
404405
}
405406
deriving (Generic, Show)
406407

408+
newtype ProposalAuthors = ProposalAuthors { getProposalAuthors :: Value }
409+
deriving newtype (Show)
410+
411+
instance FromJSON ProposalAuthors where
412+
parseJSON v@(Array _) = pure $ ProposalAuthors v
413+
parseJSON _ = fail "ProposalAuthors must be a JSON array"
414+
415+
instance ToJSON ProposalAuthors where
416+
toJSON (ProposalAuthors v) = v
417+
418+
instance ToSchema ProposalAuthors where
419+
declareNamedSchema _ = pure $ NamedSchema (Just "ProposalAuthors") $ mempty
420+
& type_ ?~ OpenApiArray
421+
& description ?~ "A JSON array of proposal authors"
422+
& example ?~ toJSON
423+
[ object
424+
[ "name" .= ("Alice" :: Text)
425+
, "witnessAlgorithm" .= ("algo" :: Text)
426+
, "publicKey" .= ("key" :: Text)
427+
, "signature" .= ("sig" :: Text)
428+
]
429+
, object
430+
[ "name" .= ("Bob" :: Text)
431+
, "witnessAlgorithm" .= ("algo2" :: Text)
432+
, "publicKey" .= ("key2" :: Text)
433+
, "signature" .= ("sig2" :: Text)
434+
]
435+
]
436+
437+
exampleProposalAuthors :: Text
438+
exampleProposalAuthors =
439+
"[\
440+
\ {\"name\": \"Alice\",\
441+
\ \"witnessAlgorithm\": \"Ed25519\",\
442+
\ \"publicKey\": \"abcdef123456\",\
443+
\ \"signature\": \"deadbeef\"},\
444+
\ {\"name\": \"Bob\",\
445+
\ \"witnessAlgorithm\": \"Ed25519\",\
446+
\ \"publicKey\": \"123456abcdef\",\
447+
\ \"signature\": \"beefdead\"}\
448+
\]"
449+
407450
deriveJSON (jsonOptions "proposalResponse") ''ProposalResponse
408451

409452
exampleProposalResponse :: Text
@@ -433,7 +476,9 @@ exampleProposalResponse = "{ \"id\": \"proposalId123\","
433476
<> "\"cCNoVotes\": 0,"
434477
<> "\"cCAbstainVotes\": 0,"
435478
<> "\"prevGovActionIndex\": 0,"
436-
<> "\"prevGovActionTxHash\": \"47c14a128cd024f1b990c839d67720825921ad87ed875def42641ddd2169b39c\"}"
479+
<> "\"prevGovActionTxHash\": \"47c14a128cd024f1b990c839d67720825921ad87ed875def42641ddd2169b39c\","
480+
<> "\"authors\": " <> exampleProposalAuthors
481+
<> "}"
437482

438483
instance ToSchema Value where
439484
declareNamedSchema _ = pure $ NamedSchema (Just "Value") $ mempty

govtool/backend/src/VVA/Types.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ data Proposal
208208
, proposalCcAbstainVotes :: Integer
209209
, proposalPrevGovActionIndex :: Maybe Integer
210210
, proposalPrevGovActionTxHash :: Maybe Text
211+
, proposalAuthors :: Maybe Value
211212
}
212213
deriving (Show)
213214

@@ -241,6 +242,7 @@ instance FromRow Proposal where
241242
<*> (floor @Scientific <$> field) -- proposalCcAbstainVotes
242243
<*> field -- prevGovActionIndex
243244
<*> field -- prevGovActionTxHash
245+
<*> field -- proposalAuthors
244246

245247
data TransactionStatus = TransactionStatus
246248
{ transactionConfirmed :: Bool

0 commit comments

Comments
 (0)