Skip to content

Commit

Permalink
Merge pull request #1343 from IntersectMBO/develop
Browse files Browse the repository at this point in the history
chore: add force rebuild images toggle to github actions
  • Loading branch information
MSzalowski authored Jun 19, 2024
2 parents 284b60c + 8bb1b0b commit 0b5a5ee
Show file tree
Hide file tree
Showing 43 changed files with 1,351 additions and 256 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
3 changes: 2 additions & 1 deletion .github/workflows/build-and-deploy-test-stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ jobs:
SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }}
GTM_ID: ${{ secrets.GTM_ID }}
NPMRC_TOKEN: ${{ secrets.NPMRC_TOKEN }}
SENTRY_DSN_FRONTEND: ${{ secrets.INTERSECT_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
28 changes: 28 additions & 0 deletions govtool/frontend/storybook.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM node:18-alpine as deps
ARG NPMRC_TOKEN

WORKDIR /src

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

COPY package.json package-lock.json ./
RUN npm install

FROM node:18-alpine as builder
ARG NPMRC_TOKEN
ENV NODE_OPTIONS=--max_old_space_size=8192
WORKDIR /src

COPY --from=deps /src/node_modules ./node_modules
COPY . .

RUN npm run build-storybook --quiet

FROM nginx:stable-alpine
EXPOSE 80

COPY --from=builder /src/storybook-static /usr/share/nginx/html

CMD ["nginx", "-g", "daemon off;"]
9 changes: 7 additions & 2 deletions scripts/govtool/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,15 @@ check_defined = \
__check_defined = \
$(if $(value $1),, \
$(error Undefined $1$(if $2, ($2))))


force_rebuild := $(shell echo $${FORCE_REBUILD:-false})
# helper function for checking if image exists on ECR
check_image_on_ecr = \
$(docker) manifest inspect "$(repo_url)/$1:$2" > /dev/null 2>&1
if [ "$(force_rebuild)" = "true" ]; then \
false; \
else \
$(docker) manifest inspect "$(repo_url)/$1:$2" > /dev/null 2>&1; \
fi

.PHONY: check-env-defined
check-env-defined:
Expand Down
3 changes: 3 additions & 0 deletions tests/govtool-frontend/playwright/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ API_URL=http://localhost:3000/api

DOCS_URL=https://docs.sanchogov.tools


PDF_URL=https://dev.api.pdf.gov.tools

# 0 for testnet, 1 for mainnet
NETWORK_ID=0

Expand Down
1 change: 1 addition & 0 deletions tests/govtool-frontend/playwright/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ allure-report/
lib/_mock/registerDRepWallets.json
lib/_mock/registeredDRepWallets.json
lib/_mock/wallets.json
lib/_mock/proposals.json
./lock_logs.txt
44 changes: 44 additions & 0 deletions tests/govtool-frontend/playwright/lib/_mock/proposal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"data": {
"id": 128,
"attributes": {
"prop_likes": 0,
"prop_dislikes": 0,
"prop_comments_number": 3,
"prop_submited": false,
"prop_status_id": null,
"user_id": "52",
"createdAt": "2024-06-14T08:28:18.000Z",
"updatedAt": "2024-06-14T08:28:18.000Z",
"content": {
"id": 121,
"attributes": {
"proposal_id": "128",
"prop_rev_active": true,
"prop_abstract": "Calamitas suppono coniuratio aiunt pecto uberrime deleniti tepidus acerbitas. Nihil vitium conservo abeo tametsi odit creator basium.",
"prop_motivation": "Demonstro apparatus torrens patrocinor. Concedo campana possimus agnosco tutamen astrum conventus defendo sublime.",
"prop_rationale": "Brevis suppellex coadunatio vis. Alii terreo carbo sono utilis vicissitudo.",
"gov_action_type_id": "1",
"prop_name": "Labadie, Stehr and Rosenbaum",
"prop_receiving_address": "addr_test1qqqqqqqqqqa4kpmh",
"prop_amount": 402,
"createdAt": "2024-06-14T08:28:18.012Z",
"updatedAt": "2024-06-14T08:28:18.012Z",
"is_draft": false,
"user_id": "52",
"proposal_links": [],
"gov_action_type": {
"id": 1,
"attributes": {
"gov_action_type_name": "Info",
"createdAt": "2024-05-27T15:06:15.640Z",
"updatedAt": "2024-05-27T15:06:15.640Z"
}
}
}
},
"user_govtool_username": "Jett.Hagenes21"
}
},
"meta": {}
}
51 changes: 51 additions & 0 deletions tests/govtool-frontend/playwright/lib/_mock/proposalComments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"data": [
{
"id": 139,
"attributes": {
"proposal_id": "128",
"comment_parent_id": null,
"user_id": "20",
"comment_text": "Hello",
"createdAt": "2024-06-14T13:38:35.830Z",
"updatedAt": "2024-06-14T13:38:35.830Z",
"user_govtool_username": "Anonymous",
"subcommens_number": 0
}
},
{
"id": 138,
"attributes": {
"proposal_id": "128",
"comment_parent_id": null,
"user_id": "20",
"comment_text": "Nice proposal",
"createdAt": "2024-06-14T13:38:31.279Z",
"updatedAt": "2024-06-14T13:38:31.279Z",
"user_govtool_username": "Anonymous",
"subcommens_number": 0
}
},
{
"id": 137,
"attributes": {
"proposal_id": "128",
"comment_parent_id": null,
"user_id": "20",
"comment_text": "Go Ahead",
"createdAt": "2024-06-14T13:38:27.286Z",
"updatedAt": "2024-06-14T13:38:27.286Z",
"user_govtool_username": "Anonymous",
"subcommens_number": 0
}
}
],
"meta": {
"pagination": {
"page": 1,
"pageSize": 25,
"pageCount": 1,
"total": 3
}
}
}
24 changes: 24 additions & 0 deletions tests/govtool-frontend/playwright/lib/_mock/proposalPoll.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"data": [
{
"id": 39,
"attributes": {
"proposal_id": "128",
"poll_yes": 0,
"poll_no": 0,
"poll_start_dt": "2024-06-14T08:26:34.400Z",
"is_poll_active": true,
"createdAt": "2024-06-14T08:28:20.210Z",
"updatedAt": "2024-06-14T08:28:20.210Z"
}
}
],
"meta": {
"pagination": {
"page": 1,
"pageSize": 1,
"pageCount": 1,
"total": 1
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const environments = {
frontendUrl: SERVER_HOST_URL,
apiUrl: `${SERVER_HOST_URL}/api`,
docsUrl: process.env.DOCS_URL || "https://docs.sanchogov.tools",
pdfUrl: process.env.PDF_URL || "https://dev.api.pdf.gov.tools",
networkId: parseInt(process.env.NETWORK_ID) || 0,
faucet: {
apiUrl:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export const adaHolder06Wallet = staticWallets[9];
// Does not takes part in transaction
export const user01Wallet: StaticWallet = staticWallets[5];

// Username is already set
export const proposal01Wallet: StaticWallet = staticWallets[10];

export const adaHolderWallets = [
adaHolder01Wallet,
adaHolder02Wallet,
Expand All @@ -28,3 +31,5 @@ export const adaHolderWallets = [
export const userWallets = [user01Wallet];

export const dRepWallets = [dRep01Wallet, dRep02Wallet];

export const proposalWallets = [proposal01Wallet];
37 changes: 37 additions & 0 deletions tests/govtool-frontend/playwright/lib/fixtures/proposal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { proposal01Wallet } from "@constants/staticWallets";
import { test as base } from "@fixtures/walletExtension";
import { createNewPageWithWallet } from "@helpers/page";
import ProposalDiscussionDetailsPage from "@pages/proposalDiscussionDetailsPage";
import ProposalDiscussionPage from "@pages/proposalDiscussionPage";

type TestOptions = {
proposalId: number;
pollEnabled: boolean;
};

export const test = base.extend<TestOptions>({
pollEnabled: [false, { option: true }],

proposalId: async ({ page, browser, pollEnabled }, use) => {
// setup
const proposalPage = await createNewPageWithWallet(browser, {
storageState: ".auth/proposal01.json",
wallet: proposal01Wallet,
});

const proposalDiscussionPage = new ProposalDiscussionPage(proposalPage);
await proposalDiscussionPage.goto();
const proposalId = await proposalDiscussionPage.createProposal();
const proposalDetailsPage = new ProposalDiscussionDetailsPage(proposalPage);

if (pollEnabled) {
await proposalDetailsPage.addPollBtn.click();
}

await use(proposalId);

// cleanup
await proposalDetailsPage.goto(proposalId);
await proposalDetailsPage.deleteProposal();
},
});
7 changes: 7 additions & 0 deletions tests/govtool-frontend/playwright/lib/helpers/cardano.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { bech32 } from "bech32";

export function lovelaceToAda(lovelace: number) {
if (lovelace === 0) return 0;

return lovelace / 1e6;
}

export function generateWalletAddress() {
const randomBytes = new Uint8Array(10);
return bech32.encode("addr_test", randomBytes);
}
Loading

0 comments on commit 0b5a5ee

Please sign in to comment.