Skip to content

Commit

Permalink
Configure sandbox deployment (#7)
Browse files Browse the repository at this point in the history
* Bump @babel/traverse from 7.23.0 to 7.23.2 in /frontend

Bumps [@babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) from 7.23.0 to 7.23.2.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse)

---
updated-dependencies:
- dependency-name: "@babel/traverse"
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

* fix build

* fix build

* allow-empty

* fix server and build

* fix feedback

* fix feedback

* fix keys

* remove login

* fix actions

* empty commit

* empty commit

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
asavienko and dependabot[bot] authored Nov 16, 2023
1 parent c1a86d8 commit 3c85549
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 184 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/build-deploy-by-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ jobs:
HOST=$(printf "pr-%s.%s" ${{ github.event.number }} ${{ vars.HOST }})
IMAGE_TAG=$(printf "pr-%s" ${{ github.event.number }})
DB_PORT=$(printf "%d" $(expr 20000 + $PULL_REQUEST_NUMBER))
DB_NAME=$(printf "simbolik-db-pr-%s" $PULL_REQUEST_NUMBER)
DB_NAME=$(printf "kasmer-db-pr-%s" $PULL_REQUEST_NUMBER)
echo "HOST=$HOST" >> $GITHUB_OUTPUT
echo "DB_PORT=$DB_PORT" >> $GITHUB_OUTPUT
echo "DB_NAME=$DB_NAME" >> $GITHUB_OUTPUT
echo "FRONTEND_PORT=$FRONTEND_PORT" >> $GITHUB_OUTPUT
echo "BACKEND_PORT=$BACKEND_PORT" >> $GITHUB_OUTPUT
echo "HOST=$HOST" >> $GITHUB_OUTPUT
echo "IMAGE_PREFIX=ghcr.io/runtimeverification/simbolik" >> $GITHUB_OUTPUT
echo "IMAGE_PREFIX=ghcr.io/runtimeverification/kasmer" >> $GITHUB_OUTPUT
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_OUTPUT
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
nginx_main_config="$(cat ${{ github.workspace }}/configs/nginx/nginx.conf)"
Expand Down Expand Up @@ -102,8 +102,8 @@ jobs:
script: |
source "/home/ubuntu/.acme.sh/acme.sh.env"
PULL_REQUEST_NAME=$(printf "pr-%s" ${{ github.event.number }})
mkdir -p ~/opt/deployments/simbolik-$PULL_REQUEST_NAME
cd ~/opt/deployments/simbolik-$PULL_REQUEST_NAME
mkdir -p ~/opt/deployments/kasmer-$PULL_REQUEST_NAME
cd ~/opt/deployments/kasmer-$PULL_REQUEST_NAME
# Frontend
docker pull ${{ needs.build.outputs.IMAGE_PREFIX }}/frontend:$PULL_REQUEST_NAME
Expand Down Expand Up @@ -145,7 +145,7 @@ jobs:
--name kasmer-backend-$PULL_REQUEST_NAME \
-d --restart=always \
--network=${{ needs.build.outputs.DB_NAME }} \
-e DATABASE_URL="postgresql://${{ secrets.DB_USER }}:${{ secrets.DB_PASSWORD }}@${{ needs.build.outputs.DB_NAME }}/simbolik?schema=$PULL_REQUEST_NAME&connection_limit=40&pool_timeout=30" \
-e DATABASE_URL="postgresql://${{ secrets.DB_USER }}:${{ secrets.DB_PASSWORD }}@${{ needs.build.outputs.DB_NAME }}/postgres?schema=$PULL_REQUEST_NAME&connection_limit=40&pool_timeout=30" \
-e FRONTEND_URL=https://${{ needs.build.outputs.HOST }} \
-e GITHUB_CLIENT_ID=${{ secrets.GH_CLIENT_ID }} \
-e GITHUB_CLIENT_SECRET=${{ secrets.GH_CLIENT_SECRET }} \
Expand All @@ -154,8 +154,8 @@ jobs:
-e GOOGLE_CLIENT_ID=${{ secrets.GOOGLE_CLIENT_ID }} \
-e GOOGLE_CLIENT_SECRET=${{ secrets.GOOGLE_CLIENT_SECRET }} \
-e GOOGLE_CALLBACK_HOST=${{ needs.build.outputs.HOST }} \
-e EMAIL_HOST=${{ vars.EMAIL_HOST }} \
-e EMAIL_USER=${{ vars.EMAIL_USER }} \
-e EMAIL_HOST=${{ secrets.EMAIL_HOST }} \
-e EMAIL_USER=${{ secrets.EMAIL_USER }} \
-e BRANCH_NAME=$PULL_REQUEST_NAME \
-e EMAIL_PASSWORD=${{ secrets.EMAIL_PASSWORD }} \
-e JWT_SECRET=${{ secrets.JWT_SECRET }} \
Expand Down Expand Up @@ -263,6 +263,6 @@ jobs:
uses: bots-house/[email protected]
with:
owner: ${{ github.repository_owner }}
name: kasmer/frontend
name: kasmer/web
token: ${{ secrets.GITHUB_TOKEN }}
untagged-keep-latest: 1
8 changes: 4 additions & 4 deletions .github/workflows/build-deploy-by-push-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ jobs:
${{ needs.build.outputs.FRONTEND_IMAGE_URL }}
# Backend
DATABASE_URL=$(printf "postgresql://%s:%s@%s/%s/simbolik?schema=${{ github.ref_name }}&connection_limit=40&pool_timeout=30" \
DATABASE_URL=$(printf "postgresql://%s:%s@%s/%s/kasmer?schema=${{ github.ref_name }}&connection_limit=40&pool_timeout=30" \
${{ secrets.DB_USER }} \
${{ secrets.DB_PASSWORD }} \
${{ secrets.DB_HOST_PORT }} \
Expand All @@ -136,8 +136,8 @@ jobs:
-e GOOGLE_CLIENT_ID=${{ secrets.GOOGLE_CLIENT_ID }} \
-e GOOGLE_CLIENT_SECRET=${{ secrets.GOOGLE_CLIENT_SECRET }} \
-e GOOGLE_CALLBACK_HOST=${{ needs.build.outputs.HOST }} \
-e EMAIL_HOST=${{ vars.EMAIL_HOST }} \
-e EMAIL_USER=${{ vars.EMAIL_USER }} \
-e EMAIL_HOST=${{ secrets.EMAIL_HOST }} \
-e EMAIL_USER=${{ secrets.EMAIL_USER }} \
-e BRANCH_NAME=${{ github.ref_name }} \
-e EMAIL_PASSWORD=${{ secrets.EMAIL_PASSWORD }} \
-e JWT_SECRET=${{ secrets.JWT_SECRET }} \
Expand Down Expand Up @@ -245,6 +245,6 @@ jobs:
uses: bots-house/[email protected]
with:
owner: ${{ github.repository_owner }}
name: kasmer/frontend
name: kasmer/web
token: ${{ secrets.GITHUB_TOKEN }}
untagged-keep-latest: 1
10 changes: 5 additions & 5 deletions .github/workflows/close-pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: "Close Pull Request"
on:
pull_request:
types: [closed]
types: [ closed ]
concurrency:
group: ${{ github.event.number }}

jobs:
close-pull-request:
runs-on: [self-hosted, linux, normal]
runs-on: [ self-hosted, linux, normal ]
environment: develop
steps:
# - name: Get GitHub payload
Expand All @@ -22,7 +22,7 @@ jobs:
FRONTEND_PORT=$(printf "%d" $(expr 9000 + $PULL_REQUEST_NUMBER))
BACKEND_PORT=$(printf "%d" $(expr 10000 + $PULL_REQUEST_NUMBER))
HOST=$(printf "pr-%s.%s" ${{ github.event.number }} ${{ vars.HOST }})
echo "IMAGE_PREFIX=ghcr.io/runtimeverification/simbolik" >> $GITHUB_OUTPUT
echo "IMAGE_PREFIX=ghcr.io/runtimeverification/kasmer" >> $GITHUB_OUTPUT
echo "FRONTEND_PORT=$FRONTEND_PORT" >> $GITHUB_OUTPUT
echo "BACKEND_PORT=$BACKEND_PORT" >> $GITHUB_OUTPUT
echo "HOST=$HOST" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -52,8 +52,8 @@ jobs:
docker image rm ${{ steps.process-outputs.outputs.IMAGE_PREFIX }}/backend:$PULL_REQUEST_NAME
docker image prune -f
cleanup:
runs-on: [self-hosted, linux, flyweight]
needs: [close-pull-request]
runs-on: [ self-hosted, linux, flyweight ]
needs: [ close-pull-request ]
if: always()
steps:
- name: Clean PR backend image
Expand Down
6 changes: 3 additions & 3 deletions backend/sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ POSTGRES_USER=some_user
POSTGRES_PASSWORD=some_password

# Postgres connection string.
# "simbolik" is the name of the database. See https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING.
DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/simbolik?schema=${BRANCH_NAME}&connection_limit=40&pool_timeout=30
# "kasmer" is the name of the database. See https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING.
DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/postgres?schema=${BRANCH_NAME}&connection_limit=40&pool_timeout=30


# Password to encrypt the JWT tokens
Expand All @@ -41,7 +41,7 @@ GOOGLE_CLIENT_SECRET=xxxx # The client secret of the Google OAuth app.
# The key below is for local development:
RECAPTCHA_SECRET_KEY=6Ld9pOUjAAAAAGIDO3K3KSrYomGt4ty0SXRpCHTz

GITHUB_WORKFLOW_TRIGGER_TOKEN=xxxx # The rv-auditor GitHub token. Used to dispatch the GitHub workflow in runtimeverification/simbolik repository.
GITHUB_WORKFLOW_TRIGGER_TOKEN=xxxx # The rv-auditor GitHub token. Used to dispatch the GitHub workflow in runtimeverification/kasmer repository.

# SMTP server configuration.
EMAIL_HOST=smtp.google.com
Expand Down
2 changes: 1 addition & 1 deletion backend/src/config/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default () => ({
GITHUB_CLIENT_SECRET: process.env.GITHUB_CLIENT_SECRET,

GOOGLE_CALLBACK_HOST:
process.env.GOOGLE_CALLBACK_HOST || 'simbolik.runtimeverification.com',
process.env.GOOGLE_CALLBACK_HOST || 'kasmer.runtimeverification.com',
GOOGLE_CALLBACK_EXTRA: process.env.GOOGLE_CALLBACK_EXTRA || '',
GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID,
GOOGLE_CLIENT_SECRET: process.env.GOOGLE_CLIENT_SECRET,
Expand Down
48 changes: 28 additions & 20 deletions backend/src/github/github.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,31 +126,39 @@ ${description}

async postFeedback(createFeedbackInput: CreateFeedbackInput) {
const branchName = this.configService.get<string>('BRANCH_NAME');
let issueNumber = 16; // master
if (branchName === 'master') {
issueNumber = 16;
} else if (branchName === 'develop' || /^pr-/i.test(branchName ?? '')) {
issueNumber = 15; // develop or PRs
} else {
issueNumber = 14;
}

// TODO: refactor the code. move Magic string -> Confing
try {
const PROD_ISSUE_NUMBER = 6;
const DEV_ISSUE_NUMBER = 5;
const TEST_ISSUE_NUMBER = 4;

let issueNumber: number;

return this.octokit.request(
'POST /repos/{owner}/{repo}/issues/{issue_number}/comments',
{
owner: 'runtimeverification',
repo: 'simbolik',
issue_number: issueNumber,
body: this.feedBackInputToMdAdapter(createFeedbackInput),
},
);
switch (branchName) {
case 'master':
issueNumber = PROD_ISSUE_NUMBER;
break;
case 'develop':
issueNumber = DEV_ISSUE_NUMBER;
break;
default:
issueNumber = /^pr-/i.test(branchName ?? '')
? DEV_ISSUE_NUMBER
: TEST_ISSUE_NUMBER;
break;
}

try {
return await this.octokit.request(
'POST /repos/{owner}/{repo}/issues/{issue_number}/comments',
{
owner: 'runtimeverification',
repo: 'kasmer',
issue_number: issueNumber,
body: this.feedBackInputToMdAdapter(createFeedbackInput),
},
);
} catch (e) {
console.log(e);
console.error(e);
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion backend/src/graphql/graphql.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class GqlOptionsService implements GqlOptionsFactory {
return {
driver: ApolloDriver,
debug: process.env.NODE_ENV !== 'production',
playground: { title: 'simbolik GraphQL Playground' },
playground: { title: 'kasmer GraphQL Playground' },
subscriptions: {
'graphql-ws': this.subscriptionConfig,
'subscriptions-transport-ws': this.subscriptionConfig,
Expand Down
8 changes: 4 additions & 4 deletions frontend/components/HeadWithMetas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface Props {
}

export const defaultMetaKeywords =
'Simbolik, ERC-20, ERC20, ERC-721, ERC721, ERC-777, ERC777, ERC-1155, ERC1155, ERC-4626, ERC4626, ERC-3668, ERC3668, ERC conformance, ERC testing, ERC token, ERC contracts, ERC development, ERC standards, ERC compliance, Ethereum Request for Comments';
'kasmer, ERC-20, ERC20, ERC-721, ERC721, ERC-777, ERC777, ERC-1155, ERC1155, ERC-4626, ERC4626, ERC-3668, ERC3668, ERC conformance, ERC testing, ERC token, ERC contracts, ERC development, ERC standards, ERC compliance, Ethereum Request for Comments';

export default function HeadWithMetas({
title,
Expand All @@ -25,11 +25,11 @@ export default function HeadWithMetas({
preventRobotCrawler
}: Props) {
const canonicalUrl = process.env.NEXT_PUBLIC_SITE_URL + useRouter().asPath;
const defaultTitle = 'Simbolik | Runtime Verification';
const defaultTitle = 'kasmer | Runtime Verification';
const defaultDescription =
'ERC token development, testing, compliance, and conformance for ERC smart contracts from the Kasmer developers at Runtime Verification.';
const defaultOgImage =
process.env.NEXT_PUBLIC_SITE_URL + '/assets/img/simbolik-logo.png';
process.env.NEXT_PUBLIC_SITE_URL + '/assets/img/kasmer-logo.png';

return (
<Head>
Expand Down Expand Up @@ -86,7 +86,7 @@ export default function HeadWithMetas({
/>
<meta
name="author"
content="Simbolik development team from Runtime Verification"
content="kasmer development team from Runtime Verification"
></meta>
<link key="canonical" rel="canonical" href={canonicalUrl} />
{extraElements}
Expand Down
89 changes: 0 additions & 89 deletions frontend/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,8 @@ import Icon from '@mdi/react';
import { mdiClose, mdiMenu } from '@mdi/js';
import { useRouter } from 'next/router';
import { navigation } from '@/constants/naviagation';
import UserMenu from '@/components/Header/UserMenu';
import GuestMenu from '@/components/Header/GuestMenu';
import AuthContainer from '@/containers/auth';
import { containerWrapper } from '@/constants/sharedStyles';
import {
ACCOUNT_URL,
ADMIN_URL,
LOGIN_WITH_GITHUB_URL,
LOGIN_WITH_GOOGLE_URL
} from '@/constants/routing';
import { removeAuth } from '@/lib/auth';
import { KASMER_LOGO_SRC } from '@/constants/sources';

Expand Down Expand Up @@ -81,40 +73,6 @@ export default function Header() {
</a>
);
})}
{/* Profile dropdown */}
<div
className={
'inline-flex items-center border-b-2 border-transparent dark:hover:border-gray-600 hover:border-gray-300'
}
>
<div className="dropdown dropdown-end">
<label
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
tabIndex={0}
className={classNames(
'text-yellow-400',
'font-extrabold cursor-pointer'
)}
>
{authContainer.isLoggedin ? (
<span>Account</span>
) : (
<span>Log in</span>
)}
</label>
<ul
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
tabIndex={0}
className="dropdown-content menu p-2 shadow rounded-box w-52 bg-blue-950"
>
{authContainer.isLoggedin ? (
<UserMenu />
) : (
<GuestMenu />
)}
</ul>
</div>
</div>
</div>
</div>
</div>
Expand All @@ -141,53 +99,6 @@ export default function Header() {
</Disclosure.Button>
);
})}

{authContainer.isLoggedin ? (
<>
<Disclosure.Button
as="a"
href={ACCOUNT_URL}
className={classNames(nonActiveMenuClasses, menuClasses)}
>
Settings
</Disclosure.Button>

{isAdmin && (
<Disclosure.Button
as="a"
href={ADMIN_URL}
className={classNames(nonActiveMenuClasses, menuClasses)}
>
Admin
</Disclosure.Button>
)}

<Disclosure.Button
as="a"
onClick={handleLogOut}
className={classNames(nonActiveMenuClasses, menuClasses)}
>
Sign out
</Disclosure.Button>
</>
) : (
<>
<Disclosure.Button
as="a"
href={LOGIN_WITH_GITHUB_URL}
className={classNames(nonActiveMenuClasses, menuClasses)}
>
Log In with GitHub
</Disclosure.Button>
<Disclosure.Button
as="a"
href={LOGIN_WITH_GOOGLE_URL}
className={classNames(nonActiveMenuClasses, menuClasses)}
>
Log In with Google
</Disclosure.Button>
</>
)}
</div>
</Disclosure.Panel>
</>
Expand Down
3 changes: 2 additions & 1 deletion frontend/next-sitemap.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
siteUrl:
process.env.NEXT_PUBLIC_SITE_URL || 'https://simbolik.runtimeverification.com',
process.env.NEXT_PUBLIC_SITE_URL ||
'https://kasmer.runtimeverification.com',
generateRobotsTxt: true,
exclude: ['/account', '/access-token']
};
26 changes: 0 additions & 26 deletions frontend/pages/access-token.tsx

This file was deleted.

Loading

0 comments on commit 3c85549

Please sign in to comment.