Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging #34

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ workflows:
branches:
only:
- main
- beta-1-support
- deploy_explorer0:
filters:
branches:
only:
- explorer0

# Just for reusing below
step_defs:
Expand All @@ -23,6 +27,41 @@ step_defs:
command: node -v | grep v16

jobs:
deploy_explorer0:
machine:
image: ubuntu-2204:2022.04.1
resource_class: large
steps:
- checkout
- run: *node_version
- run: *check_version
- run:
name: Install
command: yarn
- run:
name: Build backend image
command: docker build . -t jchancehud/unirep-explorer:explorer0
- run:
name: Push backend image
command: |
echo $DOCKER_TOKEN | docker login -u jchancehud --password-stdin
docker push jchancehud/unirep-explorer:explorer0
rm /home/circleci/.docker/config.json
- run:
name: Trigger service update
command: curl -X POST https://devops.unirep.io/api/webhooks/ad77ca9a-3bfa-474a-bb6c-83293773d440
- run:
name: Set frontend config
command: echo 'export const SERVER = "https://api.explorer0.unirep.io"' > packages/frontend/src/config.js
- run:
name: Build frontend
command: yarn frontend build --mode production
- run:
name: Publish frontend
command: |
cd packages/frontend
npx [email protected] publish --env explorer0

deploy:
machine:
image: ubuntu-2204:2022.04.1
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/src/buildnum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 17
2 changes: 1 addition & 1 deletion packages/frontend/src/components/ConfigInfoItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default observer(({ item, info, text }) => {
<>
<div className="flex">
<h5>{item}</h5>
<Tooltip text={text} maxWidth={200} />
{text ? <Tooltip text={text} maxWidth={200} /> : null}
</div>
<h6 className="break">{info}</h6>
</>
Expand Down
6 changes: 4 additions & 2 deletions packages/frontend/src/components/UnirepInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useState } from 'react'
import { observer } from 'mobx-react-lite'
import ConfigInfoItem from './ConfigInfoItem'
import './infoCard.css'
import buildNumber from '../buildnum'

export default observer(({ info }) => {
const [circuitExpanded, setCircuitExpanded] = useState(false)
Expand Down Expand Up @@ -42,7 +43,7 @@ export default observer(({ info }) => {
{circuitExpanded ? (
<>
<div className="flex card-heading">
<h4>Circuit Config</h4>
<h4>Config</h4>
<div
onClick={() => setCircuitExpanded(false)}
style={{ cursor: 'pointer' }}
Expand Down Expand Up @@ -71,11 +72,12 @@ export default observer(({ info }) => {
info={info.EPOCH_KEY_NONCE_COUNT}
text="The number of unique epoch keys given to each user per epoch."
/>
<ConfigInfoItem item="Build Number" info={buildNumber} />
</>
) : (
<>
<div className="flex card-heading">
<h4>Circuit Config</h4>
<h4>Config</h4>
<div
onClick={() => setCircuitExpanded(true)}
style={{ cursor: 'pointer' }}
Expand Down
18 changes: 18 additions & 0 deletions packages/frontend/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin')
const path = require('path')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const webpack = require('webpack')
const fs = require('fs/promises')

module.exports = (env) => ({
entry: ['./src/index.jsx'],
Expand Down Expand Up @@ -65,6 +66,23 @@ module.exports = (env) => ({
],
},
plugins: [
{
apply: (compiler) =>
compiler.hooks.watchRun.tapAsync('watchRun', async (params, cb) => {
const currentBuild = (
await fs.readFile(path.join(__dirname, 'src/buildnum.js'))
).toString()
const [, num] = currentBuild.match(/export default (\d+)/)
await fs.writeFile(
path.join(__dirname, 'src/buildnum.js'),
`export default ${+num + 1}`
)
cb()
}),
},
new webpack.WatchIgnorePlugin({
paths: [path.join(__dirname, 'src/buildnum.js')],
}),
new HtmlWebpackPlugin({
template: 'public/index.html',
filename: 'index.html',
Expand Down
8 changes: 8 additions & 0 deletions packages/frontend/wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,13 @@ name = "unirep-explorer"
main = "worker.js"
compatibility_date = "2022-10-18"

[env.production]
name = "production"
route = { pattern = "explorer.unirep.io/*", zone_name = "unirep.io" }

[env.explorer0]
name = "explorer0"
route = { pattern = "explorer0.unirep.io/*", zone_name = "unirep.io" }

[site]
bucket = "./build"