Skip to content

Commit

Permalink
Convert Connect to Scoutgame (#4461)
Browse files Browse the repository at this point in the history
* Connect to Scoutgame

* Update ebextensions

* Revert deploy_connect matrix change

* Update manifest for scoutgame

* Revert manifest

* Fix ts errors

* Update deploy

* Fix e2e

* Fix old connect issues

* Fix CI

* Fix CI

* Rename service

* Delete project related test

---------

Co-authored-by: mattcasey <[email protected]>
  • Loading branch information
valentinludu and mattcasey authored Aug 22, 2024
1 parent 379c1cb commit 01891b3
Show file tree
Hide file tree
Showing 138 changed files with 182 additions and 1,835 deletions.
4 changes: 2 additions & 2 deletions .cdk/bin/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const deployProps: cdk.StackProps = {

const app = new cdk.App();

// Command example: cdk deploy --context name=stg-connect
// Command example: cdk deploy --context name=stg-scoutgame
const stackNameParam: string = app.node.getContext('name');

// Sunny awawrds production
Expand All @@ -28,7 +28,7 @@ else if (stackNameParam.startsWith('prd')) {
});
}
// Connect staging
else if (stackNameParam.startsWith('stg-connect')) {
else if (stackNameParam.startsWith('stg-scoutgame')) {
new StagingStack(app, stackNameParam, deployProps);
}
// Sunny awards staging
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Do not put any env var or secrets used by the app here. Put in .ebstalk.app.env/ceramic.env
# Do not put any env var or secrets used by the app here. Put in .ebstalk.apps.env/scoutgame.env
# This file should only have
# - env variables referenced in docker-compose file
# - variables needed for the .platform/hooks/predeploy/01_pull_secrets.sh script to run

option_settings:
aws:elasticbeanstalk:application:environment:
COMPOSE_PROJECT_NAME: "prd"
COMPOSE_PROFILES: "prd-connect"
EBSTALK_ENV_FILE: "connect.env"
COMPOSE_PROFILES: "prd-scoutgame"
EBSTALK_ENV_FILE: "scoutgame.env"
SERVICE_ENV: "prd" # this sets the value of datadog env tag
SERVICE_NAME: "connect-app"
IMGNAME: "charmverse-connect"
SERVICE_NAME: "scoutgame"
IMGNAME: "scoutgame"
IMGTAG: ""
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Format of this file is <env_var>=<value> key/value pair
DATABASE_URL="{{pull:secretsmanager:/io.cv.app/prd/db:SecretString:database_url}}"
AUTH_COOKIE="connect-session"
AUTH_COOKIE="scoutgame-session"
AUTH_SECRET="{{pull:secretsmanager:/io.cv.app/prd/auth_secret:SecretString:auth_secret}}"
ALCHEMY_API_KEY="{{pull:secretsmanager:/io.cv.app/prd/alchemy:SecretString:alchemy_api_key}}"
NEYNAR_API_KEY="{{pull:secretsmanager:/io.cv.app/prd/neynar:SecretString:neynar_api_key}}"
Expand Down
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
scripts/
dist/

apps/connect/.next/
apps/scoutgame/.next/

background/ceramicServer/generated/
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"error",
{
"devDependencies": true,
"packageDir": ["./", "./apps/connect"]
"packageDir": ["./", "./apps/scoutgame"]
}
],
"import/order": [
Expand Down
3 changes: 1 addition & 2 deletions .github/actions/build_docker_image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@ outputs:
runs:
using: 'composite'
steps:

- name: Prune dev dependencies and calculate img tag
id: prune_dev_dep
shell: bash
run: |
npm prune --omit=dev
rm -rf .next/cache
rm -rf apps/connect/.next/cache
rm -rf apps/scoutgame/.next/cache
rm -rf apps/sunnyawards/.next/cache
rm -rf apps/farcaster/.next/cache
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Connect CI
name: Scoutgame CI

on:
push:
Expand All @@ -9,7 +9,7 @@ on:
- '.github/**'
- 'package.json'
- 'package-lock.json'
- 'apps/connect/**'
- 'apps/scoutgame/**'
- '@connect-shared/**'
- 'abis/**'
- 'adapters/**'
Expand All @@ -27,7 +27,7 @@ on:
- '.github/**'
- 'package.json'
- 'package-lock.json'
- 'apps/connect/**'
- 'apps/scoutgame/**'
- '@connect-shared/**'
- 'abis/**'
- 'adapters/**'
Expand All @@ -43,7 +43,7 @@ on:
required: true

concurrency:
group: ci-connect-${{ github.event_name }}-${{ github.ref }}
group: ci-scoutgame-${{ github.event_name }}-${{ github.ref }}

jobs:
build-app:
Expand Down Expand Up @@ -71,14 +71,14 @@ jobs:
- name: Build app
uses: ./.github/actions/build_app
with:
app_name: connect
app_name: scoutgame

# source https://github.com/orgs/community/discussions/28474
- name: Print head git commit message
id: get_head_commit_message
run: echo "commit_message=$(git show -s --format=%s)" >> "$GITHUB_OUTPUT"

test-connect:
test-scoutgame:
name: Test apps
runs-on: ubuntu-latest
needs: build-app
Expand Down Expand Up @@ -112,15 +112,15 @@ jobs:
- name: Restore app from cache
uses: ./.github/actions/build_app
with:
app_name: connect
app_name: scoutgame

- name: Validate Webapp
- name: Validate Scoutgame app
run: |
npm run lint -w apps/connect
npm run typecheck -w apps/connect
npm run lint -w apps/scoutgame
npm run typecheck -w apps/scoutgame
test-connect-e2e:
name: Test Connect e2e
test-scoutgame-e2e:
name: Test Scoutgame e2e
runs-on: ubuntu-latest
needs: build-app
if: ${{ github.event.action != 'labeled' && !contains(needs.build-app.outputs.head-commit-message, 'skip-tests') }}
Expand Down Expand Up @@ -153,19 +153,19 @@ jobs:
- name: Restore app from cache
uses: ./.github/actions/build_app
with:
app_name: connect
app_name: scoutgame

- name: Start connect app
- name: Start scoutgame app
run: |
npm run connect:start:test:ci &> connect.log &
npm run scoutgame:start:test:ci &> connect.log &
sleep_loop_ct=0
until curl localhost:3337/api/health || [[ $sleep_loop_ct > 30 ]]; do
echo "webapp not up in loop $sleep_loop_ct ... sleeping"
sleep_loop_ct=$((sleep_loop_ct + 1))
sleep 1
done
- name: Run Connect E2E tests
- name: Run Scoutgame E2E tests
env:
REACT_APP_APP_ENV: 'test'
# we have to run docker command ourselves to set network=host so that playwright can access the server
Expand All @@ -182,16 +182,16 @@ jobs:
--network "host" \
--ipc=host \
mcr.microsoft.com/playwright:v1.42.1-jammy \
npm run connect:test:e2e:ci
npm run scoutgame:test:e2e:ci
upload-docker:
name: Upload Docker image
runs-on: ubuntu-latest
# run whether previous jobs were successful or skipped
if: |
github.ref == 'refs/heads/main' ||
(github.event.action == 'labeled' && github.event.label.name == ':rocket: deploy-connect') ||
(github.event.action != 'labeled' && (contains(github.event.pull_request.labels.*.name, ':rocket: deploy-connect')))
(github.event.action == 'labeled' && github.event.label.name == ':rocket: deploy-scoutgame') ||
(github.event.action != 'labeled' && (contains(github.event.pull_request.labels.*.name, ':rocket: deploy-scoutgame')))
needs: build-app
steps:
- uses: actions/checkout@v4
Expand All @@ -204,11 +204,11 @@ jobs:
- name: Restore app from cache
uses: ./.github/actions/build_app
with:
app_name: connect
app_name: scoutgame

- name: Update Dockerfile
run: |
rm Dockerfile && mv apps/connect/Dockerfile Dockerfile
rm Dockerfile && mv apps/scoutgame/Dockerfile Dockerfile
- name: Build and Push Docker image
id: docker_build_push
Expand All @@ -218,7 +218,7 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-east-1
with:
ecr_registry: charmverse-connect
ecr_registry: scoutgame

upload-static-assets:
name: Upload assets in production
Expand All @@ -243,7 +243,7 @@ jobs:
- name: Restore app from cache
uses: ./.github/actions/build_app
with:
app_name: connect
app_name: scoutgame

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
Expand All @@ -254,29 +254,29 @@ jobs:

- name: Upload static assets to S3
run: |
aws s3 sync apps/connect/.next/static/ s3://charm.cdn/webapp-assets/_next/static/
aws s3 sync apps/scoutgame/.next/static/ s3://charm.cdn/webapp-assets/_next/static/
- name: Upload JS source maps to Datadog
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
run: |
npm install -g @datadog/datadog-ci
datadog-ci sourcemaps upload apps/connect/.next/static \
--service=connect \
datadog-ci sourcemaps upload apps/scoutgame/.next/static \
--service=scoutgame \
--release-version=${{ steps.get_build_id.outputs.build_id }} \
--minified-path-prefix=https://cdn.charmverse.io/_next/static
deploy-production:
name: Deploy to production
# run whether previous jobs were successful or skipped
if: github.ref == 'refs/heads/main' && !(failure() || cancelled())
needs: [test-connect, test-connect-e2e, upload-docker, upload-static-assets]
needs: [test-scoutgame, test-scoutgame-e2e, upload-docker, upload-static-assets]
runs-on: ubuntu-latest
strategy:
matrix:
include:
- stack: prd-connect
ebextensions: connect
- stack: prd-scoutgame
ebextensions: scoutgame
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -315,8 +315,8 @@ jobs:
deploy-staging:
name: Deploy to staging
if: |
(github.event.action == 'labeled' && github.event.label.name == ':rocket: deploy-connect') ||
(github.event.action != 'labeled' && (contains(github.event.pull_request.labels.*.name, ':rocket: deploy-connect')))
(github.event.action == 'labeled' && github.event.label.name == ':rocket: deploy-scoutgame') ||
(github.event.action != 'labeled' && (contains(github.event.pull_request.labels.*.name, ':rocket: deploy-scoutgame')))
runs-on: ubuntu-latest
# prevent staging deploys + cleanup running in parallel
Expand All @@ -332,7 +332,7 @@ jobs:

- name: Calculate Stage env var
run: |
full_stage_name="stg-connect-${{ github.event.number }}-${{ env.GITHUB_HEAD_REF_SLUG }}"
full_stage_name="stg-scoutgame-${{ github.event.number }}-${{ env.GITHUB_HEAD_REF_SLUG }}"
# sanitize and trim string so that it can be used as a valid subdomain. Includes removing hyphens at the start and end of the name
stage_name=`echo "$full_stage_name" | sed -E -e 's/[^a-zA-Z0-9-]+//g' -e 's/(.{40}).*/\1/' -e 's/^-/0/' -e 's/-$/0/'`
Expand Down Expand Up @@ -384,7 +384,7 @@ jobs:
uses: mikefarah/yq@master
with:
cmd: |
mv .ebextensions .ebextensions_tmp && mv .ebextensions_tmp/connect .ebextensions
mv .ebextensions .ebextensions_tmp && mv .ebextensions_tmp/scoutgame .ebextensions
yq -I 4 -i '
with(.option_settings."aws:elasticbeanstalk:application:environment";
.COMPOSE_PROJECT_NAME = "pr${{ github.event.number }}" |
Expand Down Expand Up @@ -416,7 +416,7 @@ jobs:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && failure()
# pass in all steps so we can check if any failed
needs: [test-connect, test-connect-e2e, upload-docker, upload-static-assets, upload-docker, deploy-production]
needs: [test-scoutgame, test-scoutgame-e2e, upload-docker, upload-static-assets, upload-docker, deploy-production]
steps:
- name: If any of prev jobs failed notify discord
if: contains(needs.*.result, 'failure')
Expand All @@ -425,7 +425,7 @@ jobs:
webhook: ${{ secrets.DISCORD_WARNINGS_WEBHOOK }}
status: 'failure'
content: 'Hey <@&1027309276454207519>'
title: 'Connect deploy workflow failed'
title: 'Scoutgame deploy workflow failed'
description: |
Failed workflow URL: https://github.com/charmverse/app.charmverse.io/actions/runs/${{ github.run_id }}
color: '16515843'
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/destroy_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
clean-up:
if: |
(github.event.action == 'unlabeled' && startsWith(github.event.label.name, ':rocket: deploy')) ||
(github.event.action == 'closed' && (contains(github.event.pull_request.labels.*.name, ':rocket: deploy') || contains(github.event.pull_request.labels.*.name, ':rocket: deploy-ceramic') || contains(github.event.pull_request.labels.*.name, ':rocket: deploy-connect') || contains(github.event.pull_request.labels.*.name, ':rocket: deploy-sunnyawards') || contains(github.event.pull_request.labels.*.name, ':rocket: deploy-farcaster')))
(github.event.action == 'closed' && (contains(github.event.pull_request.labels.*.name, ':rocket: deploy') || contains(github.event.pull_request.labels.*.name, ':rocket: deploy-ceramic') || contains(github.event.pull_request.labels.*.name, ':rocket: deploy-scoutgame') || contains(github.event.pull_request.labels.*.name, ':rocket: deploy-sunnyawards') || contains(github.event.pull_request.labels.*.name, ':rocket: deploy-farcaster')))
runs-on: ubuntu-latest
steps:
- name: configure AWS credentials
Expand Down Expand Up @@ -46,12 +46,12 @@ jobs:
# we need to create a dummy zip file or else cdk throws an error it cannot find the asset
run: |
touch stg-webapp-${{ env.STAGE_SUFFIX }}.zip
touch stg-connect-${{ env.STAGE_SUFFIX }}.zip
touch stg-scoutgame-${{ env.STAGE_SUFFIX }}.zip
touch stg-sunnyawards-${{ env.STAGE_SUFFIX }}.zip
touch stg-farcaster-${{ env.STAGE_SUFFIX }}.zip
npm install aws-cdk-lib --no-audit --no-fund
npx cdk destroy -c name=stg-webapp-${{ env.STAGE_SUFFIX }} --force
npx cdk destroy -c name=stg-connect-${{ env.STAGE_SUFFIX }} --force
npx cdk destroy -c name=stg-scoutgame-${{ env.STAGE_SUFFIX }} --force
npx cdk destroy -c name=stg-sunnyawards-${{ env.STAGE_SUFFIX }} --force
npx cdk destroy -c name=stg-farcaster-${{ env.STAGE_SUFFIX }} --force
Expand All @@ -61,11 +61,11 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
environment: stg-webapp-${{ env.STAGE_SUFFIX }}

- name: delete the connect github deployment
- name: delete the scoutgame github deployment
uses: strumwolf/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
environment: stg-connect-${{ env.STAGE_SUFFIX }}
environment: stg-scoutgame-${{ env.STAGE_SUFFIX }}

- name: delete the sunnyawards github deployment
uses: strumwolf/[email protected]
Expand Down
14 changes: 7 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ serverless/*.node
/out/
/dist/

# connect app
/apps/connect/.next/
/apps/connect/dist/
/apps/connect/node_modules/
/apps/connect/public/sw*
/apps/connect/public/swe-worker*
# scoutgame app
/apps/scoutgame/.next/
/apps/scoutgame/dist/
/apps/scoutgame/node_modules/
/apps/scoutgame/public/sw*
/apps/scoutgame/public/swe-worker*

# farcaster app
/apps/farcaster/.next/
Expand Down Expand Up @@ -66,7 +66,7 @@ cdk.context.json

# generated by react-env for frontend env vars
public/__ENV.js
apps/connect/public/__ENV.js
apps/scoutgame/public/__ENV.js
apps/sunnyawards/public/__ENV.js
apps/farcaster/public/__ENV.js

Expand Down
2 changes: 0 additions & 2 deletions __e2e__/po/login.po.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// playwright-dev-page.ts
import { expect } from '@playwright/test';
import type { Locator, Page } from '@playwright/test';

import { baseUrl } from '@root/config/constants';

// capture actions on the pages in signup flow
Expand Down
Loading

0 comments on commit 01891b3

Please sign in to comment.