From f7db6843a3660481870b36894dc04df2424306a3 Mon Sep 17 00:00:00 2001 From: Jackson Foley Date: Tue, 9 May 2023 15:50:31 -0600 Subject: [PATCH 01/17] Merge release-v1.9.1 into prod-gcp (#722) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4e128ff31..16609087d 100644 --- a/README.md +++ b/README.md @@ -17,3 +17,4 @@ Dapper Collective has adopted a Code of Conduct that we expect project participa ### [Contributing Guide](https://github.com/DapperCollectives/CAST/blob/main/CONTRIBUTING.md) Read our [contributing guide](https://github.com/DapperCollectives/CAST/blob/main/CONTRIBUTING.md) to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes. + From f48921ec72f519afda162a9508aba4301c1df685 Mon Sep 17 00:00:00 2001 From: vishal <1117327+vishalchangrani@users.noreply.github.com> Date: Wed, 13 Sep 2023 13:27:10 -0700 Subject: [PATCH 02/17] updating readme --- .idea/.gitignore | 8 ++++++++ .idea/CAST.iml | 9 +++++++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ README.md | 3 +++ 5 files changed, 34 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/CAST.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 000000000..13566b81b --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/CAST.iml b/.idea/CAST.iml new file mode 100644 index 000000000..5e764c4f0 --- /dev/null +++ b/.idea/CAST.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 000000000..33a48f1dd --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 000000000..94a25f7f4 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 5659e41d9..9fecb7dc6 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ + +# Active development for CAST is now on https://github.com/onflow/CAST + # CAST ![stability-wip](https://img.shields.io/badge/stability-work_in_progress-lightgrey.svg) From b40e7af4f053b9e0693cba551783155564c03795 Mon Sep 17 00:00:00 2001 From: Vishal <1117327+vishalchangrani@users.noreply.github.com> Date: Thu, 21 Sep 2023 14:56:23 -0700 Subject: [PATCH 03/17] v1.9.6 (#750) Release v1.9.5 -> Staging (#746) Merging onflow/cast to branch release-v1.9.5 (#745) * update links to point to new subdomain * updating readme; merging upstream --------- Co-authored-by: Amarildo Grembi From 84cbc5c2c5e62cbeb3f5c89dfa2ba0a9639a2e0b Mon Sep 17 00:00:00 2001 From: vishal <1117327+vishalchangrani@users.noreply.github.com> Date: Thu, 21 Sep 2023 15:08:34 -0700 Subject: [PATCH 04/17] removing IDE files --- .idea/.gitignore | 8 -------- .idea/CAST.iml | 9 --------- .idea/modules.xml | 8 -------- .idea/vcs.xml | 6 ------ 4 files changed, 31 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/CAST.iml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b81b..000000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/CAST.iml b/.idea/CAST.iml deleted file mode 100644 index 5e764c4f0..000000000 --- a/.idea/CAST.iml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 33a48f1dd..000000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7f4..000000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 9045bd82a12091f6960b93660f5a31d2f0a8f9d3 Mon Sep 17 00:00:00 2001 From: sjonpaulbrown Date: Thu, 30 May 2024 09:50:11 -0600 Subject: [PATCH 05/17] Add new workflows for Cloud Run deployments --- .../deploy-to-cloudrun-production.yml | 96 +++++++++++++++++++ .../workflows/deploy-to-cloudrun-staging.yml | 96 +++++++++++++++++++ 2 files changed, 192 insertions(+) create mode 100644 .github/workflows/deploy-to-cloudrun-production.yml create mode 100644 .github/workflows/deploy-to-cloudrun-staging.yml diff --git a/.github/workflows/deploy-to-cloudrun-production.yml b/.github/workflows/deploy-to-cloudrun-production.yml new file mode 100644 index 000000000..47f010106 --- /dev/null +++ b/.github/workflows/deploy-to-cloudrun-production.yml @@ -0,0 +1,96 @@ +name: "Deploy to Production Cloud Run" + +on: + push: + branches: + - prod-gcp + - jp-testing + +env: + + # DB VARS + db_username: ${{ secrets.DB_USERNAME }} + db_password: ${{ secrets.DB_PASSWORD }} + db_hostname: ${{ secrets.DB_HOSTNAME }} + db_port: ${{ secrets.DB_PORT }} + db_name: ${{ secrets.DB_NAME }} + backend_api: ${{ secrets.BACKEND_API }} + tx_options: ${{ secrets.TX_OPTIONS }} + hotjar_site_id: ${{ secrets.HOTJAR_STAGE_ID }} + sentry_url: ${{ secrets.SENTRY_STAGE_URL }} + + # GCP VARS + BACKEND_DOCKER_IMAGE_URL: ${{ vars.BACKEND_GCP_DOCKER_IMAGE_URL }}:${{ github.sha }} + FRONTEND_DOCKER_IMAGE_URL: ${{ vars.FRONTNED_GCP_DOCKER_IMAGE_URL }}:${{ github.sha }} + GAR_LOCATION: ${{ vars.GCP_GAR_LOCATION }} + PROJECT_ID: ${{ vars.GCP_PROJECT_ID }} + SERVICE_ACCOUNT: ${{ vars.GCP_SERVICE_ACCOUNT }} + WORKLOAD_IDENTITY_PROVIDER: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }} + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Google auth + id: auth + uses: google-github-actions/auth@v2 + with: + token_format: 'access_token' + workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_PROVIDER }} + service_account: ${{ env.SERVICE_ACCOUNT }} + + - name: Set up Cloud SDK + uses: google-github-actions/setup-gcloud@v1 + with: + project_id: ${{ env.PROJECT_ID }} + + - name: Docker Auth + run: |- + gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev + docker build -t ${{ env.BACKEND_DOCKER_IMAGE_URL }} --file backend/Dockerfile . + docker push ${{ env.BACKEND_DOCKER_IMAGE_URL }} + + - name: build and push frontend - stage - + env: + BACKEND: ${{ env.backend_api }} + run: | + gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev + cd frontend && sed -i -e 's/REPLACE_HOTJAR_SITE_ID/${{ env.hotjar_site_id }}/g' Dockerfile.stage && sed -i -e 's|REPLACE_SENTRY_URL|${{ env.sentry_url }}|g' Dockerfile.stage && docker build -f Dockerfile.stage . -t ${{ env.FRONTEND_DOCKER_IMAGE_URL }} + + deploy-staging-backend: + needs: [build] + environment: staging + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Google auth + id: auth + uses: google-github-actions/auth@v2 + with: + token_format: 'access_token' + workload_identity_provider: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }} + service_account: ${{ vars.GCP_SERVICE_ACCOUNT }} + + - name: Deploy Backend to Cloud Run + uses: google-github-actions/deploy-cloudrun@v1 + with: + service: ${{ vars.BACKEND_GCP_SERVICE }} + image: ${{ env.BACKEND_DOCKER_IMAGE_URL }} + + - name: Deploy Frontend to Cloud Run + uses: google-github-actions/deploy-cloudrun@v1 + with: + service: ${{ vars.FRONTEND_GCP_SERVICE }} + image: ${{ env.FRONTEND_DOCKER_IMAGE_URL }} + diff --git a/.github/workflows/deploy-to-cloudrun-staging.yml b/.github/workflows/deploy-to-cloudrun-staging.yml new file mode 100644 index 000000000..dc0eb7c27 --- /dev/null +++ b/.github/workflows/deploy-to-cloudrun-staging.yml @@ -0,0 +1,96 @@ +name: "Deploy to Staging Cloud Run" + +on: + push: + branches: + - staging + - jp-testing + +env: + + # DB VARS + db_username: ${{ secrets.DB_USERNAME }} + db_password: ${{ secrets.DB_PASSWORD }} + db_hostname: ${{ secrets.DB_HOSTNAME }} + db_port: ${{ secrets.DB_PORT }} + db_name: ${{ secrets.DB_NAME }} + backend_api: ${{ secrets.BACKEND_API }} + tx_options: ${{ secrets.TX_OPTIONS }} + hotjar_site_id: ${{ secrets.HOTJAR_STAGE_ID }} + sentry_url: ${{ secrets.SENTRY_STAGE_URL }} + + # GCP VARS + BACKEND_DOCKER_IMAGE_URL: ${{ vars.BACKEND_GCP_DOCKER_IMAGE_URL }}:${{ github.sha }} + FRONTEND_DOCKER_IMAGE_URL: ${{ vars.FRONTNED_GCP_DOCKER_IMAGE_URL }}:${{ github.sha }} + GAR_LOCATION: ${{ vars.GCP_GAR_LOCATION }} + PROJECT_ID: ${{ vars.GCP_PROJECT_ID }} + SERVICE_ACCOUNT: ${{ vars.GCP_SERVICE_ACCOUNT }} + WORKLOAD_IDENTITY_PROVIDER: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }} + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Google auth + id: auth + uses: google-github-actions/auth@v2 + with: + token_format: 'access_token' + workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_PROVIDER }} + service_account: ${{ env.SERVICE_ACCOUNT }} + + - name: Set up Cloud SDK + uses: google-github-actions/setup-gcloud@v1 + with: + project_id: ${{ env.PROJECT_ID }} + + - name: Docker Auth + run: |- + gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev + docker build -t ${{ env.BACKEND_DOCKER_IMAGE_URL }} --file backend/Dockerfile . + docker push ${{ env.BACKEND_DOCKER_IMAGE_URL }} + + - name: build and push frontend - stage - + env: + BACKEND: ${{ env.backend_api }} + run: | + gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev + cd frontend && sed -i -e 's/REPLACE_HOTJAR_SITE_ID/${{ env.hotjar_site_id }}/g' Dockerfile.stage && sed -i -e 's|REPLACE_SENTRY_URL|${{ env.sentry_url }}|g' Dockerfile.stage && docker build -f Dockerfile.stage . -t ${{ env.FRONTEND_DOCKER_IMAGE_URL }} + + deploy-staging-backend: + needs: [build] + environment: staging + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Google auth + id: auth + uses: google-github-actions/auth@v2 + with: + token_format: 'access_token' + workload_identity_provider: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }} + service_account: ${{ vars.GCP_SERVICE_ACCOUNT }} + + - name: Deploy Backend to Cloud Run + uses: google-github-actions/deploy-cloudrun@v1 + with: + service: ${{ vars.BACKEND_GCP_SERVICE }} + image: ${{ env.BACKEND_DOCKER_IMAGE_URL }} + + - name: Deploy Frontend to Cloud Run + uses: google-github-actions/deploy-cloudrun@v1 + with: + service: ${{ vars.FRONTEND_GCP_SERVICE }} + image: ${{ env.FRONTEND_DOCKER_IMAGE_URL }} + From 5ce5544b4b37cb625b86bd9a2c787392dd25a7e4 Mon Sep 17 00:00:00 2001 From: sjonpaulbrown Date: Thu, 30 May 2024 09:52:21 -0600 Subject: [PATCH 06/17] Fix workflow --- .github/workflows/deploy-to-cloudrun-production.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-to-cloudrun-production.yml b/.github/workflows/deploy-to-cloudrun-production.yml index 47f010106..649d0df32 100644 --- a/.github/workflows/deploy-to-cloudrun-production.yml +++ b/.github/workflows/deploy-to-cloudrun-production.yml @@ -50,22 +50,22 @@ jobs: with: project_id: ${{ env.PROJECT_ID }} - - name: Docker Auth + - name: Build CAST Backend run: |- gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev docker build -t ${{ env.BACKEND_DOCKER_IMAGE_URL }} --file backend/Dockerfile . docker push ${{ env.BACKEND_DOCKER_IMAGE_URL }} - - name: build and push frontend - stage - + - name: Build CAST Frontend env: BACKEND: ${{ env.backend_api }} run: | gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev cd frontend && sed -i -e 's/REPLACE_HOTJAR_SITE_ID/${{ env.hotjar_site_id }}/g' Dockerfile.stage && sed -i -e 's|REPLACE_SENTRY_URL|${{ env.sentry_url }}|g' Dockerfile.stage && docker build -f Dockerfile.stage . -t ${{ env.FRONTEND_DOCKER_IMAGE_URL }} - deploy-staging-backend: + deploy-production-backend: needs: [build] - environment: staging + environment: production runs-on: ubuntu-latest permissions: contents: read From 658919f6c89a33462069ba53fd89aa10d8217127 Mon Sep 17 00:00:00 2001 From: sjonpaulbrown Date: Tue, 4 Jun 2024 09:22:26 -0600 Subject: [PATCH 07/17] Update backend to support unix socket connections to db --- backend/main/server/app.go | 90 ++++++++++++++++++++++++++------------ 1 file changed, 63 insertions(+), 27 deletions(-) diff --git a/backend/main/server/app.go b/backend/main/server/app.go index 43f377180..14618bba9 100644 --- a/backend/main/server/app.go +++ b/backend/main/server/app.go @@ -1,42 +1,43 @@ package server import ( - // "errors" - "context" "encoding/json" "flag" "fmt" "io/ioutil" "net/http" + "net/url" "os" "strings" - "github.com/DapperCollectives/CAST/backend/main/middleware" - "github.com/DapperCollectives/CAST/backend/main/models" - "github.com/DapperCollectives/CAST/backend/main/shared" - "github.com/DapperCollectives/CAST/backend/main/strategies" "github.com/axiomzen/envconfig" "github.com/gorilla/mux" "github.com/jackc/pgx/v4/pgxpool" - "github.com/rs/zerolog" "github.com/rs/zerolog/log" + + "github.com/DapperCollectives/CAST/backend/main/middleware" + "github.com/DapperCollectives/CAST/backend/main/models" + "github.com/DapperCollectives/CAST/backend/main/shared" + "github.com/DapperCollectives/CAST/backend/main/strategies" ) -type Database shared.Database -type IpfsClient shared.IpfsClient -type Allowlist shared.Allowlist -type Vote models.Vote -type Proposal models.Proposal -type Community models.Community -type Balance models.Balance -type List models.List -type ListRequest models.ListPayload -type ListUpdatePayload models.ListUpdatePayload -type CommunityUser models.CommunityUser -type CommunityUserPayload models.CommunityUserPayload -type UserCommunity models.UserCommunity +type ( + Database shared.Database + IpfsClient shared.IpfsClient + Allowlist shared.Allowlist + Vote models.Vote + Proposal models.Proposal + Community models.Community + Balance models.Balance + List models.List + ListRequest models.ListPayload + ListUpdatePayload models.ListUpdatePayload + CommunityUser models.CommunityUser + CommunityUserPayload models.CommunityUserPayload + UserCommunity models.UserCommunity +) type TxOptionsAddresses []string @@ -54,9 +55,19 @@ type App struct { } type Strategy interface { - TallyVotes(votes []*models.VoteWithBalance, p *models.ProposalResults, proposal *models.Proposal) (models.ProposalResults, error) - GetVotes(votes []*models.VoteWithBalance, proposal *models.Proposal) ([]*models.VoteWithBalance, error) - GetVoteWeightForBalance(vote *models.VoteWithBalance, proposal *models.Proposal) (float64, error) + TallyVotes( + votes []*models.VoteWithBalance, + p *models.ProposalResults, + proposal *models.Proposal, + ) (models.ProposalResults, error) + GetVotes( + votes []*models.VoteWithBalance, + proposal *models.Proposal, + ) ([]*models.VoteWithBalance, error) + GetVoteWeightForBalance( + vote *models.VoteWithBalance, + proposal *models.Proposal, + ) (float64, error) InitStrategy(f *shared.FlowAdapter, db *shared.Database) FetchBalance(b *models.Balance, p *models.Proposal) (*models.Balance, error) RequiresSnapshot() bool @@ -164,7 +175,7 @@ func (a *App) Initialize() { } // Create Map for Flow Adaptor to look up when voting - var customScriptsMap = make(map[string]shared.CustomScript) + customScriptsMap := make(map[string]shared.CustomScript) for _, script := range customScripts { customScriptsMap[script.Key] = script } @@ -202,9 +213,7 @@ func (a *App) ConnectDB(username, password, host, port, dbname string) { database.Context = context.Background() database.Name = dbname - connectionString := - fmt.Sprintf("postgres://%s:%s@%s:%s/%s", username, password, host, port, dbname) - + connectionString := ToUnixURL(false, username, password, dbname, host) pconf, confErr := pgxpool.ParseConfig(connectionString) if confErr != nil { log.Fatal().Err(err).Msg("Unable to parse database config url") @@ -226,3 +235,30 @@ func (a *App) ConnectDB(username, password, host, port, dbname string) { log.Info().Msgf("Successfully created Postgres conn pool") } } + +func ToUnixURL(ssl bool, username, password, db, host string) string { + urlStr := "postgresql://" + + if len(username) == 0 { + username = "postgres" + } + urlStr += username + + if len(password) > 0 { + urlStr = urlStr + ":" + url.PathEscape(password) + } + urlStr += "@" + + urlStr += "/" + url.PathEscape(db) + + // Append query parameters + urlStr += "?" + "host=" + host + + mode := "" + if !ssl { + mode = "&sslmode=disable" + } + + urlStr += mode + return urlStr +} From e500db3def9a048484b86694ebc5b6f6878f57c2 Mon Sep 17 00:00:00 2001 From: sjonpaulbrown Date: Tue, 4 Jun 2024 09:22:40 -0600 Subject: [PATCH 08/17] Remove unnecessary dependencies from frontend --- frontend/Dockerfile | 2 -- frontend/Dockerfile.stage | 2 -- frontend/packages/client/.env.example | 2 -- frontend/packages/client/package.json | 3 --- frontend/packages/client/src/App.js | 4 ---- frontend/packages/client/src/index.js | 8 -------- 6 files changed, 21 deletions(-) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index ca9f28d14..6677b9c1d 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -19,8 +19,6 @@ ENV REACT_APP_BACK_END_SERVER_API "https://api.cast.fyi" ENV REACT_APP_IPFS_GATEWAY "https://dappercollectives.mypinata.cloud/ipfs" ENV REACT_APP_FLOW_ENV "mainnet" ENV REACT_APP_TX_OPTIONS_ADDRS "0xe0de919ed4ebeee4,0x7f81b82fa0e59b17" -ENV REACT_APP_HOTJAR_SITE_ID=REPLACE_HOTJAR_SITE_ID -ENV REACT_APP_SENTRY_URL=REPLACE_SENTRY_URL RUN yarn build diff --git a/frontend/Dockerfile.stage b/frontend/Dockerfile.stage index 6cbdb910a..ebd09fced 100644 --- a/frontend/Dockerfile.stage +++ b/frontend/Dockerfile.stage @@ -18,8 +18,6 @@ ENV REACT_APP_BACK_END_SERVER_API "https://app.staging.cast.dapperlabs.com" ENV REACT_APP_IPFS_GATEWAY "https://dappercollectives.mypinata.cloud/ipfs" ENV REACT_APP_FLOW_ENV "mainnet" ENV REACT_APP_TX_OPTIONS_ADDRS "0xe0de919ed4ebeee4,0x7f81b82fa0e59b17" -ENV REACT_APP_HOTJAR_SITE_ID=REPLACE_HOTJAR_SITE_ID -ENV REACT_APP_SENTRY_URL=REPLACE_SENTRY_URL RUN yarn build diff --git a/frontend/packages/client/.env.example b/frontend/packages/client/.env.example index 3335d86a1..511070c00 100644 --- a/frontend/packages/client/.env.example +++ b/frontend/packages/client/.env.example @@ -4,5 +4,3 @@ REACT_APP_FLOW_ENV=emulator REACT_APP_BACK_END_SERVER_API=http://localhost:5001 REACT_APP_IPFS_GATEWAY=https://dappercollectives.mypinata.cloud/ipfs REACT_APP_TX_OPTIONS_ADDRS="0xc590d541b72f0ac1,0x72d401812f579e3e" -REACT_APP_HOTJAR_SITE_ID=0 -REACT_APP_SENTRY_URL=REPLACE_SENTRY_URL \ No newline at end of file diff --git a/frontend/packages/client/package.json b/frontend/packages/client/package.json index c637649d2..5f0f29510 100644 --- a/frontend/packages/client/package.json +++ b/frontend/packages/client/package.json @@ -6,12 +6,9 @@ "@craco/craco": "^6.4.5", "@creativebulma/bulma-tooltip": "^1.2.0", "@hookform/resolvers": "^2.9.7", - "@hotjar/browser": "^1.0.6", "@onflow/fcl": "^1.2.0", "@onflow/sdk": "^1.1.1", "@onflow/six-transfer-tokens": "0.0.8", - "@sentry/react": "^7.14.0", - "@sentry/tracing": "^7.14.0", "@tanstack/react-query": "4.3.3", "@tanstack/react-query-devtools": "4.3.3", "@trivago/prettier-plugin-sort-imports": "^3.3.0", diff --git a/frontend/packages/client/src/App.js b/frontend/packages/client/src/App.js index 7cd3680fe..79e84f1cb 100644 --- a/frontend/packages/client/src/App.js +++ b/frontend/packages/client/src/App.js @@ -6,16 +6,12 @@ import NotificationModalProvider from 'contexts/NotificationModal'; import { Web3Provider } from 'contexts/Web3'; import { ErrorHandler } from 'components'; import { IS_PRODUCTION } from 'const'; -import Hotjar from '@hotjar/browser'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; import AppPages from 'pages'; import Error from 'pages/Error'; import './App.sass'; -const hotjarVersion = 6; -Hotjar.init(process.env.REACT_APP_HOTJAR_SITE_ID, hotjarVersion); - // create react-query client const queryClient = new QueryClient(); diff --git a/frontend/packages/client/src/index.js b/frontend/packages/client/src/index.js index e9a2e36a2..3af1c396d 100644 --- a/frontend/packages/client/src/index.js +++ b/frontend/packages/client/src/index.js @@ -1,13 +1,5 @@ import ReactDOM from 'react-dom'; -import * as Sentry from '@sentry/react'; -import { BrowserTracing } from '@sentry/tracing'; import App from './App'; import './index.css'; -Sentry.init({ - dsn: process.env.REACT_APP_SENTRY_URL, - integrations: [new BrowserTracing()], - tracesSampleRate: 0.3, -}); - ReactDOM.render(, document.getElementById('root')); From 8c1962e9c5505e30ddd1a13e330c55d7869a82ad Mon Sep 17 00:00:00 2001 From: sjonpaulbrown Date: Tue, 4 Jun 2024 09:22:51 -0600 Subject: [PATCH 09/17] Fix workflows --- .github/workflows/deploy-to-cloudrun-production.yml | 7 ++++--- .github/workflows/deploy-to-cloudrun-staging.yml | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy-to-cloudrun-production.yml b/.github/workflows/deploy-to-cloudrun-production.yml index 649d0df32..e030e5dcb 100644 --- a/.github/workflows/deploy-to-cloudrun-production.yml +++ b/.github/workflows/deploy-to-cloudrun-production.yml @@ -21,7 +21,7 @@ env: # GCP VARS BACKEND_DOCKER_IMAGE_URL: ${{ vars.BACKEND_GCP_DOCKER_IMAGE_URL }}:${{ github.sha }} - FRONTEND_DOCKER_IMAGE_URL: ${{ vars.FRONTNED_GCP_DOCKER_IMAGE_URL }}:${{ github.sha }} + FRONTEND_DOCKER_IMAGE_URL: ${{ vars.FRONTEND_GCP_DOCKER_IMAGE_URL }}:${{ github.sha }} GAR_LOCATION: ${{ vars.GCP_GAR_LOCATION }} PROJECT_ID: ${{ vars.GCP_PROJECT_ID }} SERVICE_ACCOUNT: ${{ vars.GCP_SERVICE_ACCOUNT }} @@ -53,7 +53,7 @@ jobs: - name: Build CAST Backend run: |- gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev - docker build -t ${{ env.BACKEND_DOCKER_IMAGE_URL }} --file backend/Dockerfile . + docker build -t ${{ env.BACKEND_DOCKER_IMAGE_URL }} --file backend/Dockerfile ./backend docker push ${{ env.BACKEND_DOCKER_IMAGE_URL }} - name: Build CAST Frontend @@ -61,7 +61,8 @@ jobs: BACKEND: ${{ env.backend_api }} run: | gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev - cd frontend && sed -i -e 's/REPLACE_HOTJAR_SITE_ID/${{ env.hotjar_site_id }}/g' Dockerfile.stage && sed -i -e 's|REPLACE_SENTRY_URL|${{ env.sentry_url }}|g' Dockerfile.stage && docker build -f Dockerfile.stage . -t ${{ env.FRONTEND_DOCKER_IMAGE_URL }} + docker build -f Dockerfile.stage ./frontend -t ${{ env.FRONTEND_DOCKER_IMAGE_URL }} + docker push ${{ env.FRONTEND_DOCKER_IMAGE_URL }} deploy-production-backend: needs: [build] diff --git a/.github/workflows/deploy-to-cloudrun-staging.yml b/.github/workflows/deploy-to-cloudrun-staging.yml index dc0eb7c27..dd641af88 100644 --- a/.github/workflows/deploy-to-cloudrun-staging.yml +++ b/.github/workflows/deploy-to-cloudrun-staging.yml @@ -21,7 +21,7 @@ env: # GCP VARS BACKEND_DOCKER_IMAGE_URL: ${{ vars.BACKEND_GCP_DOCKER_IMAGE_URL }}:${{ github.sha }} - FRONTEND_DOCKER_IMAGE_URL: ${{ vars.FRONTNED_GCP_DOCKER_IMAGE_URL }}:${{ github.sha }} + FRONTEND_DOCKER_IMAGE_URL: ${{ vars.FRONTEND_GCP_DOCKER_IMAGE_URL }}:${{ github.sha }} GAR_LOCATION: ${{ vars.GCP_GAR_LOCATION }} PROJECT_ID: ${{ vars.GCP_PROJECT_ID }} SERVICE_ACCOUNT: ${{ vars.GCP_SERVICE_ACCOUNT }} @@ -53,7 +53,7 @@ jobs: - name: Docker Auth run: |- gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev - docker build -t ${{ env.BACKEND_DOCKER_IMAGE_URL }} --file backend/Dockerfile . + docker build -t ${{ env.BACKEND_DOCKER_IMAGE_URL }} --file backend/Dockerfile ./backend docker push ${{ env.BACKEND_DOCKER_IMAGE_URL }} - name: build and push frontend - stage - @@ -61,7 +61,8 @@ jobs: BACKEND: ${{ env.backend_api }} run: | gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev - cd frontend && sed -i -e 's/REPLACE_HOTJAR_SITE_ID/${{ env.hotjar_site_id }}/g' Dockerfile.stage && sed -i -e 's|REPLACE_SENTRY_URL|${{ env.sentry_url }}|g' Dockerfile.stage && docker build -f Dockerfile.stage . -t ${{ env.FRONTEND_DOCKER_IMAGE_URL }} + docker build -f Dockerfile.stage ./frontend -t ${{ env.FRONTEND_DOCKER_IMAGE_URL }} + docker push ${{ env.FRONTEND_DOCKER_IMAGE_URL }} deploy-staging-backend: needs: [build] From 9ad1001833f4189c0cb7e9130796ac0d455b637a Mon Sep 17 00:00:00 2001 From: sjonpaulbrown Date: Tue, 4 Jun 2024 09:45:50 -0600 Subject: [PATCH 10/17] Update workflows --- .github/workflows/deploy-to-cloudrun-production.yml | 2 +- .github/workflows/deploy-to-cloudrun-staging.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-to-cloudrun-production.yml b/.github/workflows/deploy-to-cloudrun-production.yml index e030e5dcb..4435947f4 100644 --- a/.github/workflows/deploy-to-cloudrun-production.yml +++ b/.github/workflows/deploy-to-cloudrun-production.yml @@ -4,7 +4,7 @@ on: push: branches: - prod-gcp - - jp-testing + - jp/add-cloudrun-support env: diff --git a/.github/workflows/deploy-to-cloudrun-staging.yml b/.github/workflows/deploy-to-cloudrun-staging.yml index dd641af88..d10d197eb 100644 --- a/.github/workflows/deploy-to-cloudrun-staging.yml +++ b/.github/workflows/deploy-to-cloudrun-staging.yml @@ -4,7 +4,7 @@ on: push: branches: - staging - - jp-testing + - jp/add-cloudrun-support env: From c615c78c6d1d83149a071123bd953cf70ddb6534 Mon Sep 17 00:00:00 2001 From: sjonpaulbrown Date: Tue, 4 Jun 2024 09:54:38 -0600 Subject: [PATCH 11/17] Fix builds --- .github/workflows/deploy-to-cloudrun-production.yml | 2 +- .github/workflows/deploy-to-cloudrun-staging.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-to-cloudrun-production.yml b/.github/workflows/deploy-to-cloudrun-production.yml index 4435947f4..6fd38f21c 100644 --- a/.github/workflows/deploy-to-cloudrun-production.yml +++ b/.github/workflows/deploy-to-cloudrun-production.yml @@ -61,7 +61,7 @@ jobs: BACKEND: ${{ env.backend_api }} run: | gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev - docker build -f Dockerfile.stage ./frontend -t ${{ env.FRONTEND_DOCKER_IMAGE_URL }} + docker build -f ./frontend/Dockerfile ./frontend -t ${{ env.FRONTEND_DOCKER_IMAGE_URL }} docker push ${{ env.FRONTEND_DOCKER_IMAGE_URL }} deploy-production-backend: diff --git a/.github/workflows/deploy-to-cloudrun-staging.yml b/.github/workflows/deploy-to-cloudrun-staging.yml index d10d197eb..ec044bebc 100644 --- a/.github/workflows/deploy-to-cloudrun-staging.yml +++ b/.github/workflows/deploy-to-cloudrun-staging.yml @@ -61,7 +61,7 @@ jobs: BACKEND: ${{ env.backend_api }} run: | gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev - docker build -f Dockerfile.stage ./frontend -t ${{ env.FRONTEND_DOCKER_IMAGE_URL }} + docker build -f ./frontend/Dockerfile.stage ./frontend -t ${{ env.FRONTEND_DOCKER_IMAGE_URL }} docker push ${{ env.FRONTEND_DOCKER_IMAGE_URL }} deploy-staging-backend: From ac105e37cef5ec952ed30c6fb0bb5eccbaf17571 Mon Sep 17 00:00:00 2001 From: sjonpaulbrown Date: Tue, 4 Jun 2024 10:09:46 -0600 Subject: [PATCH 12/17] Remove unnecessary workflows --- .github/workflows/update-dev.yaml | 27 ----- .github/workflows/update-prod.yaml | 161 ------------------------- .github/workflows/update-qa.yaml | 27 ----- .github/workflows/update-stage.yaml | 179 ---------------------------- .github/workflows/update-uat.yaml | 27 ----- 5 files changed, 421 deletions(-) delete mode 100644 .github/workflows/update-dev.yaml delete mode 100644 .github/workflows/update-prod.yaml delete mode 100644 .github/workflows/update-qa.yaml delete mode 100644 .github/workflows/update-stage.yaml delete mode 100644 .github/workflows/update-uat.yaml diff --git a/.github/workflows/update-dev.yaml b/.github/workflows/update-dev.yaml deleted file mode 100644 index 17118532c..000000000 --- a/.github/workflows/update-dev.yaml +++ /dev/null @@ -1,27 +0,0 @@ -name: UPDATE DEVELOP - -on: - # Trigger the workflow on push or pull request - push: - branches: - - develop - -env: - TAG: ${{ github.sha }} - jenkins_user: ${{ secrets.JENKINS_USER }} - jenkins_token: ${{ secrets.JENKINS_TOKEN }} - jenkins_url: ${{ secrets.JENKINS_URL }} - -jobs: - - get-last-commit: - name: UPDATE-DEVELOP - if: "!contains(github.event.head_commit.message, 'cancel action')" - runs-on: ubuntu-20.04 - timeout-minutes: 1 - steps: - - name: Update DEVELOP - shell: bash - run : | - tag_short=$(echo ${{ env.TAG }} | cut -c1-7) - curl -X POST https://${{ env.jenkins_user }}:${{ env.jenkins_token }}@${{ env.jenkins_url }}/job/VT-DEVELOP-UPDATE/build --data-urlencode json='{"parameter": [{"name":"TAG", "value":"'$tag_short'"}]}' \ No newline at end of file diff --git a/.github/workflows/update-prod.yaml b/.github/workflows/update-prod.yaml deleted file mode 100644 index 4a0d89bce..000000000 --- a/.github/workflows/update-prod.yaml +++ /dev/null @@ -1,161 +0,0 @@ -name: UPDATE PROD GCP - -on: - push: - branches: - - prod-gcp - -env: - db_username: ${{ secrets.DB_USERNAME }} - db_password: ${{ secrets.DB_PASSWORD }} - db_hostname: ${{ secrets.DB_HOSTNAME }} - db_password_prod: ${{ secrets.DB_PASSWORD_PROD }} - db_hostname_prod: ${{ secrets.DB_HOSTNAME_PROD }} - db_port: ${{ secrets.DB_PORT }} - db_name: ${{ secrets.DB_NAME }} - dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} - dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }} - argo_repo: ${{ secrets.ARGO_REPO }} - argo_ref: ${{ secrets.ARGO_REF }} - argo_token: ${{ secrets.ARGO_TOKEN }} - backend_api: ${{ secrets.BACKEND_API }} - tx_options: ${{ secrets.TX_OPTIONS }} - github_token: ${{ secrets.GH_TOKEN }} - hotjar_site_id: ${{ secrets.HOTJAR_PROD_ID }} - sentry_url: ${{ secrets.SENTRY_PROD_URL }} - -jobs: - -##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -## MIGRATIONS -##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - migrations: - name: Migrations - runs-on: production-runner - if: "!contains(github.event.head_commit.message, 'cancel migrations')" - steps: - - - name: checkout - uses: actions/checkout@v3 - with: - ref: prod-gcp - - - name: Install and run migrations - run: | - sudo curl -L https://github.com/golang-migrate/migrate/releases/download/v4.15.2/migrate.linux-amd64.tar.gz | tar xvz && sudo mv migrate /usr/local/bin && sudo chmod +x /usr/local/bin/migrate - sudo migrate -path ./backend/migrations -database 'postgres://${{ env.db_username }}:${{ env.db_password_prod }}@${{ env.db_hostname_prod }}:${{ env.db_port }}/${{ env.db_name }}?sslmode=disable' -verbose up - -##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -## BUILD AND PUSH BACKEND PROD - ARGO TIME! -##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - build-and-push-backend: - name: Build and push backend - runs-on: ubuntu-20.04 - if: "!contains(github.event.head_commit.message, 'cancel build backend')" - steps: - - - name: checkout - uses: actions/checkout@v3 - with: - ref: prod-gcp - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ env.dockerhub_username }} - password: ${{ env.dockerhub_token }} - - - - name: Build Docker image from release - id: docker-from-release - run: | - export TAG=$(curl -H "Accept: application/vnd.github+json" https://api.github.com/repos/DapperCollectives/CAST/releases/latest | jq -r '.tag_name') - cd backend && docker build . -t bruddev/cast-backend:$TAG && docker push bruddev/cast-backend:$TAG - -## ARGO FROM HERE - - - name: Clone ArgoManifests - run: | - mkdir -p ./argo - - - name: Checkout ArgoManifests - uses: actions/checkout@v3 - with: - repository: ${{ env.argo_repo }} - ref: ${{ env.argo_ref }} - token: ${{ env.argo_token }} - path: ./argo - - - name: time - id: time - run: echo "::set-output name=time::$(date "+%T")" - - - name: Install Kustomize and update tag - env: - TIME: ${{ steps.time.outputs.time }} - run: | - curl -fL https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.5.5/kustomize_v4.5.5_linux_amd64.tar.gz| tar xz && \ - chmod +x kustomize - export TAG=$(curl -H "Accept: application/vnd.github+json" https://api.github.com/repos/DapperCollectives/CAST/releases/latest | jq -r '.tag_name') - cd ./argo/voting-tool-stage-prod/backend/environments/prod && kustomize edit set image bruddev/cast-backend:$TAG - git config --global user.email "brunkins@brudfyi.com" - git config --global user.name "Brunkins" - git commit -am "Added new backend value $TAG from GHA $TIME" && git push - -##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -## BUILD AND PUSH FRONTEND PROD - ARGO TIME! -##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - build-and-push-frontend: - name: Build and push frontend - runs-on: ubuntu-20.04 - if: "!contains(github.event.head_commit.message, 'cancel build frontend')" - steps: - - - name: checkout - uses: actions/checkout@v3 - with: - ref: prod-gcp - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ env.dockerhub_username }} - password: ${{ env.dockerhub_token }} - - - name: Build Docker image from release #TEST THIS - id: docker-from-release - run: | - export TAG=$(curl -H "Accept: application/vnd.github+json" https://api.github.com/repos/DapperCollectives/CAST/releases/latest | jq -r '.tag_name') - cd frontend && sed -i -e 's/REPLACE_HOTJAR_SITE_ID/${{ env.hotjar_site_id }}/g' Dockerfile && sed -i -e 's|REPLACE_SENTRY_URL|${{ env.sentry_url }}|g' Dockerfile && docker build . -t bruddev/cast-frontend:$TAG && docker push bruddev/cast-frontend:$TAG - -## ARGO FROM HERE - - - name: Clone ArgoManifests - run: | - mkdir -p ./argo - - - name: Checkout ArgoManifests - uses: actions/checkout@v3 - with: - repository: ${{ env.argo_repo }} - ref: ${{ env.argo_ref }} - token: ${{ env.argo_token }} - path: ./argo - - - name: time - id: time - run: echo "::set-output name=time::$(date "+%T")" - - - name: Install Kustomize and update tag - env: - TIME: ${{ steps.time.outputs.time }} - run: | - curl -fL https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.5.5/kustomize_v4.5.5_linux_amd64.tar.gz| tar xz && \ - chmod +x kustomize - export TAG=$(curl -H "Accept: application/vnd.github+json" https://api.github.com/repos/DapperCollectives/CAST/releases/latest | jq -r '.tag_name') - cd ./argo/voting-tool-stage-prod/frontend/environments/prod && kustomize edit set image bruddev/cast-frontend:$TAG - git config --global user.email "brunkins@brudfyi.com" - git config --global user.name "Brunkins" - git commit -am "Added new frontend value $TAG from GHA $TIME" && git push diff --git a/.github/workflows/update-qa.yaml b/.github/workflows/update-qa.yaml deleted file mode 100644 index 9da9f2bc7..000000000 --- a/.github/workflows/update-qa.yaml +++ /dev/null @@ -1,27 +0,0 @@ -name: UPDATE QA - -on: - # Trigger the workflow on push or pull request merge - push: - branches: - - qa - -env: - TAG: ${{ github.sha }} - jenkins_user: ${{ secrets.JENKINS_USER }} - jenkins_token: ${{ secrets.JENKINS_TOKEN }} - jenkins_url: ${{ secrets.JENKINS_URL }} - -jobs: - - get-last-commit: - name: UPDATE-QA - if: "!contains(github.event.head_commit.message, 'cancel action')" - runs-on: ubuntu-20.04 - timeout-minutes: 1 - steps: - - name: Update QA - shell: bash - run : | - tag_short=$(echo ${{ env.TAG }} | cut -c1-7) - curl -X POST https://${{ env.jenkins_user }}:${{ env.jenkins_token }}@${{ env.jenkins_url }}/job/VT-QA-UPDATE/build --data-urlencode json='{"parameter": [{"name":"TAG", "value":"'$tag_short'"}]}' \ No newline at end of file diff --git a/.github/workflows/update-stage.yaml b/.github/workflows/update-stage.yaml deleted file mode 100644 index 6a637dfba..000000000 --- a/.github/workflows/update-stage.yaml +++ /dev/null @@ -1,179 +0,0 @@ -name: UPDATE STAGE - -on: - push: - branches: - - staging - -env: - db_username: ${{ secrets.DB_USERNAME }} - db_password: ${{ secrets.DB_PASSWORD }} - db_hostname: ${{ secrets.DB_HOSTNAME }} - db_port: ${{ secrets.DB_PORT }} - db_name: ${{ secrets.DB_NAME }} - dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} - dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }} - argo_repo: ${{ secrets.ARGO_REPO }} - argo_ref: ${{ secrets.ARGO_REF }} - argo_token: ${{ secrets.ARGO_TOKEN }} - backend_api: ${{ secrets.BACKEND_API }} - tx_options: ${{ secrets.TX_OPTIONS }} - hotjar_site_id: ${{ secrets.HOTJAR_STAGE_ID }} - sentry_url: ${{ secrets.SENTRY_STAGE_URL }} - -jobs: - -##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -## MIGRATIONS -##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - migrations: - name: Migrations - runs-on: staging-runner - if: "!contains(github.event.head_commit.message, 'cancel migrations')" - steps: - - - name: checkout - uses: actions/checkout@v3 - with: - ref: staging - - - name: Install and run migrations - run: | - sudo apt-get update - sudo apt-get -y install curl - sudo apt-get -y install tar - sudo curl -L https://github.com/golang-migrate/migrate/releases/download/v4.15.2/migrate.linux-amd64.tar.gz | tar xvz && sudo mv migrate /usr/local/bin && sudo chmod +x /usr/local/bin/migrate - sudo migrate -path ./backend/migrations -database 'postgres://${{ env.db_username }}:${{ env.db_password }}@${{ env.db_hostname }}:${{ env.db_port }}/${{ env.db_name }}?sslmode=disable' -verbose up - -##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -## BUILD AND PUSH BACKEND STAGE - ARGO TIME! -##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - build-and-push-backend: - name: Build and push backend - runs-on: ubuntu-20.04 - if: "!contains(github.event.head_commit.message, 'cancel build backend')" - steps: - - - name: checkout - uses: actions/checkout@v3 - with: - ref: staging - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ env.dockerhub_username }} - password: ${{ env.dockerhub_token }} - - - name: Get short SHA - id: short - run: echo "::set-output name=sha7::$(echo ${GITHUB_SHA} | cut -c1-7)" - - - name: build and push backend - stage - - env: - TAG: ${{ steps.short.outputs.sha7 }} - run: | - cd backend && docker build . -t bruddev/cast-stage:$TAG-be && docker push bruddev/cast-stage:$TAG-be - -## ARGO FROM HERE - - - name: Clone ArgoManifests - run: | - mkdir -p ./argo - - - name: Checkout ArgoManifests - uses: actions/checkout@v3 - with: - repository: ${{ env.argo_repo }} - ref: ${{ env.argo_ref }} - token: ${{ env.argo_token }} - path: ./argo - - - name: time - id: time - run: echo "::set-output name=time::$(date "+%T")" - - - name: Get short SHA - id: short-backend - run: echo "::set-output name=sha7::$(echo ${GITHUB_SHA} | cut -c1-7)" - - - name: Install Kustomize and update tag - env: - TIME: ${{ steps.time.outputs.time }} - TAG: ${{ steps.short-backend.outputs.sha7 }} - run: | - curl -fL https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.5.5/kustomize_v4.5.5_linux_amd64.tar.gz| tar xz && \ - chmod +x kustomize - cd ./argo/voting-tool-stage-prod/backend/environments/stage && kustomize edit set image bruddev/cast-stage:$TAG-be - git config --global user.email "brunkins@brudfyi.com" - git config --global user.name "Brunkins" - git commit -am "Added new backend value from GHA $TIME" && git push - -##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -## BUILD AND PUSH FRONTEND STAGE - ARGO TIME! -##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - build-and-push-frontend: - name: Build and push frontend - runs-on: ubuntu-20.04 - if: "!contains(github.event.head_commit.message, 'cancel build frontend')" - steps: - - - name: checkout - uses: actions/checkout@v3 - with: - ref: staging - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ env.dockerhub_username }} - password: ${{ env.dockerhub_token }} - - - name: Get short SHA - id: short-frontend - run: echo "::set-output name=sha7::$(echo ${GITHUB_SHA} | cut -c1-7)" - - - name: build and push frontend - stage - - env: - TAG: ${{ steps.short-frontend.outputs.sha7 }} - BACKEND: ${{ env.backend_api }} - TX: ${{ env.tx_options }} - run: | - cd frontend && sed -i -e 's/REPLACE_HOTJAR_SITE_ID/${{ env.hotjar_site_id }}/g' Dockerfile.stage && sed -i -e 's|REPLACE_SENTRY_URL|${{ env.sentry_url }}|g' Dockerfile.stage && docker build -f Dockerfile.stage . -t bruddev/cast-stage:$TAG-fe - docker push bruddev/cast-stage:$TAG-fe - -## ARGO FROM HERE - - - name: Clone ArgoManifests - run: | - mkdir -p ./argo - - - name: Checkout ArgoManifests - uses: actions/checkout@v3 - with: - repository: ${{ env.argo_repo }} - ref: ${{ env.argo_ref }} - token: ${{ env.argo_token }} - path: ./argo - - - name: time - id: time - run: echo "::set-output name=time::$(date "+%T")" - - - name: Get short SHA - id: short - run: echo "::set-output name=sha7::$(echo ${GITHUB_SHA} | cut -c1-7)" - - - name: Install Kustomize and update tag - env: - TIME: ${{ steps.time.outputs.time }} - TAG: ${{ steps.short.outputs.sha7 }} - run: | - curl -fL https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.5.5/kustomize_v4.5.5_linux_amd64.tar.gz| tar xz && \ - chmod +x kustomize - cd ./argo/voting-tool-stage-prod/frontend/environments/stage && kustomize edit set image bruddev/cast-stage:$TAG-fe - git config --global user.email "brunkins@brudfyi.com" - git config --global user.name "Brunkins" - git commit -am "Added new frontend value from GHA $TIME" && git push diff --git a/.github/workflows/update-uat.yaml b/.github/workflows/update-uat.yaml deleted file mode 100644 index 7c79f38e6..000000000 --- a/.github/workflows/update-uat.yaml +++ /dev/null @@ -1,27 +0,0 @@ -name: UPDATE UAT - -on: - # Trigger the workflow on push or pull request merge - push: - branches: - - uat #We need to test this environment. - -env: - TAG: ${{ github.sha }} - jenkins_user: ${{ secrets.JENKINS_USER }} - jenkins_token: ${{ secrets.JENKINS_TOKEN }} - jenkins_url: ${{ secrets.JENKINS_URL }} - -jobs: - - get-last-commit: - name: UPDATE-UAT - if: "!contains(github.event.head_commit.message, 'cancel action')" - runs-on: ubuntu-20.04 - timeout-minutes: 1 - steps: - - name: Update UAT - shell: bash - run : | - tag_short=$(echo ${{ env.TAG }} | cut -c1-7) - curl -X POST https://${{ env.jenkins_user }}:${{ env.jenkins_token }}@${{ env.jenkins_url }}/job/VT-UAT-UPDATE/build --data-urlencode json='{"parameter": [{"name":"TAG", "value":"'$tag_short'"}]}' \ No newline at end of file From 87550751785d725671180becb7275bee020ff5cb Mon Sep 17 00:00:00 2001 From: sjonpaulbrown Date: Tue, 4 Jun 2024 10:11:50 -0600 Subject: [PATCH 13/17] Update backend URLs for testing --- frontend/Dockerfile | 2 +- frontend/Dockerfile.stage | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 6677b9c1d..b191995d6 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -15,7 +15,7 @@ RUN yarn install ENV NODE_ENV "production" ENV REACT_APP_APP_ENV "production" ENV REACT_APP_FRONTEND_URL "cast.fyi" -ENV REACT_APP_BACK_END_SERVER_API "https://api.cast.fyi" +ENV REACT_APP_BACK_END_SERVER_API "https://cast-backend-prod-cxc3jxjjdq-uc.a.run.app" ENV REACT_APP_IPFS_GATEWAY "https://dappercollectives.mypinata.cloud/ipfs" ENV REACT_APP_FLOW_ENV "mainnet" ENV REACT_APP_TX_OPTIONS_ADDRS "0xe0de919ed4ebeee4,0x7f81b82fa0e59b17" diff --git a/frontend/Dockerfile.stage b/frontend/Dockerfile.stage index ebd09fced..4fe2f70b2 100644 --- a/frontend/Dockerfile.stage +++ b/frontend/Dockerfile.stage @@ -14,7 +14,7 @@ RUN yarn install ENV NODE_ENV "production" ENV REACT_APP_APP_ENV "production" ENV REACT_APP_FRONTEND_URL "fe.staging.cast.dapperlabs.com" -ENV REACT_APP_BACK_END_SERVER_API "https://app.staging.cast.dapperlabs.com" +ENV REACT_APP_BACK_END_SERVER_API "https://cast-backend-staging-oa3wu6tmxq-uc.a.run.app" ENV REACT_APP_IPFS_GATEWAY "https://dappercollectives.mypinata.cloud/ipfs" ENV REACT_APP_FLOW_ENV "mainnet" ENV REACT_APP_TX_OPTIONS_ADDRS "0xe0de919ed4ebeee4,0x7f81b82fa0e59b17" From 4d07e5075fc31ef34e78e36f25948ecd06f6bbad Mon Sep 17 00:00:00 2001 From: sjonpaulbrown Date: Tue, 4 Jun 2024 10:19:03 -0600 Subject: [PATCH 14/17] Update CORs to be used --- backend/main/shared/structs.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/main/shared/structs.go b/backend/main/shared/structs.go index 25bd4c3a5..e35d0fbc0 100644 --- a/backend/main/shared/structs.go +++ b/backend/main/shared/structs.go @@ -10,7 +10,7 @@ import ( ) type Config struct { - Features map[string]bool `default:"useCorsMiddleware:false,validateTimestamps:true,validateAllowlist:true,validateBlocklist:true,validateSigs:true"` + Features map[string]bool `default:"useCorsMiddleware:true,validateTimestamps:true,validateAllowlist:true,validateBlocklist:true,validateSigs:true"` } type Database struct { @@ -97,10 +97,10 @@ type FTBalanceResponse struct { } type CustomScript struct { - Key string `json:"key" validate:"required"` - Name string `json:"name" validate:"required"` + Key string `json:"key" validate:"required"` + Name string `json:"name" validate:"required"` Description string `json:"description" validate:"required"` - Src string `json:"src" validate:"required"` + Src string `json:"src" validate:"required"` } func (b *FTBalanceResponse) NewFTBalance() { From b91a901e4288d49efecfd5b3ef97d93195c7c71e Mon Sep 17 00:00:00 2001 From: sjonpaulbrown Date: Tue, 4 Jun 2024 16:24:20 -0600 Subject: [PATCH 15/17] Update endpoints & cors --- backend/main/shared/structs.go | 2 +- frontend/Dockerfile | 2 +- frontend/Dockerfile.stage | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/main/shared/structs.go b/backend/main/shared/structs.go index e35d0fbc0..2ad9379a3 100644 --- a/backend/main/shared/structs.go +++ b/backend/main/shared/structs.go @@ -10,7 +10,7 @@ import ( ) type Config struct { - Features map[string]bool `default:"useCorsMiddleware:true,validateTimestamps:true,validateAllowlist:true,validateBlocklist:true,validateSigs:true"` + Features map[string]bool `default:"useCorsMiddleware:false,validateTimestamps:true,validateAllowlist:true,validateBlocklist:true,validateSigs:true"` } type Database struct { diff --git a/frontend/Dockerfile b/frontend/Dockerfile index b191995d6..6677b9c1d 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -15,7 +15,7 @@ RUN yarn install ENV NODE_ENV "production" ENV REACT_APP_APP_ENV "production" ENV REACT_APP_FRONTEND_URL "cast.fyi" -ENV REACT_APP_BACK_END_SERVER_API "https://cast-backend-prod-cxc3jxjjdq-uc.a.run.app" +ENV REACT_APP_BACK_END_SERVER_API "https://api.cast.fyi" ENV REACT_APP_IPFS_GATEWAY "https://dappercollectives.mypinata.cloud/ipfs" ENV REACT_APP_FLOW_ENV "mainnet" ENV REACT_APP_TX_OPTIONS_ADDRS "0xe0de919ed4ebeee4,0x7f81b82fa0e59b17" diff --git a/frontend/Dockerfile.stage b/frontend/Dockerfile.stage index 4fe2f70b2..6e37d55ef 100644 --- a/frontend/Dockerfile.stage +++ b/frontend/Dockerfile.stage @@ -13,8 +13,8 @@ RUN yarn install #ENVS FOR STAGING FRONTEND ENV NODE_ENV "production" ENV REACT_APP_APP_ENV "production" -ENV REACT_APP_FRONTEND_URL "fe.staging.cast.dapperlabs.com" -ENV REACT_APP_BACK_END_SERVER_API "https://cast-backend-staging-oa3wu6tmxq-uc.a.run.app" +ENV REACT_APP_FRONTEND_URL "staging.cast.fyi.com" +ENV REACT_APP_BACK_END_SERVER_API "https://api.staging.cast.fyi.com" ENV REACT_APP_IPFS_GATEWAY "https://dappercollectives.mypinata.cloud/ipfs" ENV REACT_APP_FLOW_ENV "mainnet" ENV REACT_APP_TX_OPTIONS_ADDRS "0xe0de919ed4ebeee4,0x7f81b82fa0e59b17" From 7a489cbbcd3412bfe994b3b19a84d690dc048f58 Mon Sep 17 00:00:00 2001 From: sjonpaulbrown Date: Tue, 4 Jun 2024 16:25:13 -0600 Subject: [PATCH 16/17] Update workflows to remove unnecessary branch rules --- .github/workflows/deploy-to-cloudrun-production.yml | 1 - .github/workflows/deploy-to-cloudrun-staging.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/deploy-to-cloudrun-production.yml b/.github/workflows/deploy-to-cloudrun-production.yml index 6fd38f21c..f1754eea5 100644 --- a/.github/workflows/deploy-to-cloudrun-production.yml +++ b/.github/workflows/deploy-to-cloudrun-production.yml @@ -4,7 +4,6 @@ on: push: branches: - prod-gcp - - jp/add-cloudrun-support env: diff --git a/.github/workflows/deploy-to-cloudrun-staging.yml b/.github/workflows/deploy-to-cloudrun-staging.yml index ec044bebc..fc1c175a6 100644 --- a/.github/workflows/deploy-to-cloudrun-staging.yml +++ b/.github/workflows/deploy-to-cloudrun-staging.yml @@ -4,7 +4,6 @@ on: push: branches: - staging - - jp/add-cloudrun-support env: From fb0367ab7a484b4b2674abd604a68efd62246e4e Mon Sep 17 00:00:00 2001 From: sjonpaulbrown Date: Tue, 4 Jun 2024 16:35:12 -0600 Subject: [PATCH 17/17] Add updated lock file --- frontend/yarn.lock | 70 +--------------------------------------------- 1 file changed, 1 insertion(+), 69 deletions(-) diff --git a/frontend/yarn.lock b/frontend/yarn.lock index 54a83d40e..144c2996c 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -1425,11 +1425,6 @@ resolved "https://registry.yarnpkg.com/@hookform/resolvers/-/resolvers-2.9.8.tgz#9af51d15602f3c6e3249714712d8275564e65b72" integrity sha512-iVVjH0USq+1TqDdGkWe2M1x7Wn5OFPgVRo7CbWFsXTqqXqCaZtZcnzJu+UhljCWbthFWxWGXKLGYUDPZ04oVvQ== -"@hotjar/browser@^1.0.6": - version "1.0.6" - resolved "https://registry.yarnpkg.com/@hotjar/browser/-/browser-1.0.6.tgz#5e1c9a2b0c7c21d65acb741b76c39ed81eaa4e5f" - integrity sha512-yq8pFrCk/pGe1LeI9kgd4NZNI3C8eQlck+ISmWnL3T8RtN/YYEmzDFEZ1AFZ9GGAbxyxG6xUdaL3/S7sOSqeCQ== - "@humanwhocodes/config-array@^0.5.0": version "0.5.0" resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.5.0.tgz#1407967d4c6eecd7388f83acf1eaf4d0c6e58ef9" @@ -1993,69 +1988,6 @@ estree-walker "^1.0.1" picomatch "^2.2.2" -"@sentry/browser@7.14.0": - version "7.14.0" - resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.14.0.tgz#bc2c6934f9270e1287ae1437b63e4b0edd67a9f0" - integrity sha512-AdLmqeOXvCVYgJAgMUUby+TRh+yIeZO16NPpZWQPGggXIjnhSzoN4liyXJvQ7Mhm326GboFUKjQwqpCEviQcyg== - dependencies: - "@sentry/core" "7.14.0" - "@sentry/types" "7.14.0" - "@sentry/utils" "7.14.0" - tslib "^1.9.3" - -"@sentry/core@7.14.0": - version "7.14.0" - resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.14.0.tgz#89178822de75c6023e1718c29bee8d588687cedd" - integrity sha512-Hgn7De6CiCFnz868/Lrtei+9rj7/TIwhbDe3J+NeH+2ffXYn4VI8FxrlR/p2XfIq9iCfmG80EQXDtSh+Kh7mOw== - dependencies: - "@sentry/hub" "7.14.0" - "@sentry/types" "7.14.0" - "@sentry/utils" "7.14.0" - tslib "^1.9.3" - -"@sentry/hub@7.14.0": - version "7.14.0" - resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-7.14.0.tgz#cf8e8a345c63a75ea1f3a2d7169a47ab73ff9603" - integrity sha512-O+pxsipeiURC6Mxuivz1pX3yHlkQCI2yjP38bISxUZv1NIijHuxiDmgqrrcCJltiIfyY2+f9LAezKVCAXnPFuw== - dependencies: - "@sentry/types" "7.14.0" - "@sentry/utils" "7.14.0" - tslib "^1.9.3" - -"@sentry/react@^7.14.0": - version "7.14.0" - resolved "https://registry.yarnpkg.com/@sentry/react/-/react-7.14.0.tgz#cd7db3b7040f6535871e536f811c8eed29852a90" - integrity sha512-PEHqqr6o0ZfrNhFYe1lLTNY1+vV5bEuZaG0i8s+Jo4OHozh689CeH+lGZSjvFxCpaexC+FskpiGAzcXTeurpaA== - dependencies: - "@sentry/browser" "7.14.0" - "@sentry/types" "7.14.0" - "@sentry/utils" "7.14.0" - hoist-non-react-statics "^3.3.2" - tslib "^1.9.3" - -"@sentry/tracing@^7.14.0": - version "7.14.0" - resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-7.14.0.tgz#083dadb7736f62cf5b4e168a649d8728260fb60b" - integrity sha512-AtSitQukvU52PsLlYZJ2g2Lhj3VMmy4EwF/OMp8UHCtbJYwTNDF5N4Co0GUwFIs8zdXkIoJD+GMKfsSX1L3NXA== - dependencies: - "@sentry/hub" "7.14.0" - "@sentry/types" "7.14.0" - "@sentry/utils" "7.14.0" - tslib "^1.9.3" - -"@sentry/types@7.14.0": - version "7.14.0" - resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.14.0.tgz#8069e58a0104190e328647963036c7597e2e5fa8" - integrity sha512-9iFZS9Hr5hAoL+M9oUH2dY9burOaQh+CHGH66fortuTp++YDWKdbPEeKcz8hRJaUyBBn53rdxiBmAyHsrlE6KA== - -"@sentry/utils@7.14.0": - version "7.14.0" - resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.14.0.tgz#58dab9e53ad662231c3289842edbc7f885ebc7cb" - integrity sha512-q9em4ZBcaUk7J1WULiltZVEcbyCE0wwAIjqRaoNmHVe4FeK++uAPo2ULZM1kQgN8syZnQ1jcfLktIKkWfnE2cg== - dependencies: - "@sentry/types" "7.14.0" - tslib "^1.9.3" - "@sinclair/typebox@^0.24.1": version "0.24.41" resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.24.41.tgz#45470b8bae32a28f1e0501066d0bacbd8b772804" @@ -8188,7 +8120,7 @@ hmac-drbg@^1.0.1: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.1" -hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.2: +hoist-non-react-statics@^3.1.0: version "3.3.2" resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45" integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==