Skip to content

Commit

Permalink
Add infrastructure-committee (#857)
Browse files Browse the repository at this point in the history
* fix solution action

* fix preview for proposals

* added infrastructure-committee code

* added tests

* update permissions

* added infrastructure-committee code

* added tests

* update permissions

* fix tests

* refactor code

* add instance env

* update scripts

* add access keys for RFP don't ask again test with infrastructure-committee.near

* fix infra tests

* fix date

---------

Co-authored-by: Peter Salomonsen <[email protected]>
  • Loading branch information
Megha-Dev-19 and petersalomonsen authored Jul 10, 2024
1 parent 12b2b06 commit bd8dbd0
Show file tree
Hide file tree
Showing 57 changed files with 11,854 additions and 8 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/continuous-integration-workflow-infra.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI - Infrastructure Committee
on:
pull_request:
push:
branches:
- main

jobs:
prettier:
name: Prettier
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Run code formatting check
run: npm run fmt:check

playwright-tests-infra:
name: Infrastructure Committee - Playwright tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
cache: "npm"
- name: Install dependencies
run: |
npm ci
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/mpeterdev/bos-loader/releases/download/v0.7.1/bos-loader-v0.7.1-installer.sh | sh
npx playwright install-deps
npx playwright install
- name: Run tests
run: |
INSTANCE=infrastructure npx playwright test --project=infrastructure playwright-tests/tests/infrastructure
10 changes: 5 additions & 5 deletions .github/workflows/continuous-integration-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
npx playwright install
- name: Run tests
run: |
npx playwright test playwright-tests/tests/blog
INSTANCE=devhub npx playwright test playwright-tests/tests/blog
playwright-tests-community:
name: Community - Playwright tests
runs-on: ubuntu-latest
Expand All @@ -54,7 +54,7 @@ jobs:
npx playwright install
- name: Run tests
run: |
npx playwright test playwright-tests/tests/community
INSTANCE=devhub npx playwright test playwright-tests/tests/community
playwright-tests-other:
name: Other - Playwright tests
runs-on: ubuntu-latest
Expand All @@ -72,7 +72,7 @@ jobs:
npx playwright install
- name: Run tests
run: |
npx playwright test playwright-tests/tests/other
INSTANCE=devhub npx playwright test playwright-tests/tests/other
playwright-tests-proposal:
name: Proposal - Playwright tests
runs-on: ubuntu-latest
Expand All @@ -90,7 +90,7 @@ jobs:
npx playwright install
- name: Run tests
run: |
npx playwright test playwright-tests/tests/proposal
INSTANCE=devhub npx playwright test playwright-tests/tests/proposal
playwright-tests-sunset:
name: Sunset - Playwright tests
runs-on: ubuntu-latest
Expand All @@ -108,4 +108,4 @@ jobs:
npx playwright install
- name: Run tests
run: |
npx playwright test playwright-tests/tests/sunset
INSTANCE=devhub npx playwright test playwright-tests/tests/sunset
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy Widgets to Mainnet
name: Deploy Widgets to Mainnet - Devhub
on:
pull_request:
push:
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/deploy-prod-mainnet-infra.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Deploy Widgets to Mainnet - Infrastructure
on:
pull_request:
push:
branches: [main]
jobs:
deploy-widgets:
runs-on: ubuntu-latest
name: Deploy ( or diff from PR )
env:
NEAR_SOCIAL_DEPLOY_ID: ${{ vars.NEAR_INFRA_SOCIAL_ACCOUNT_ID }}
NEAR_SOCIAL_ACCOUNT_ID: ${{ vars.NEAR_INFRA_SOCIAL_ACCOUNT_ID }}
NEAR_SOCIAL_ACCOUNT_PUBLIC_KEY: ${{ vars.NEAR_INFRA_SOCIAL_ACCOUNT_PUBLIC_KEY }}
NEAR_SOCIAL_ACCOUNT_PRIVATE_KEY: ${{ secrets.NEAR_INFRA_SOCIAL_ACCOUNT_PRIVATE_KEY }}
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
defaults:
run:
working-directory: ./instances/infrastructure-committee.near
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set replacements
id: set_replacements
run: |
echo "replacements=$(jq -r '[to_entries[] | .["find"] = "${" + .key + "}" | .["replace"] = .value | del(.key, .value), {"find": "${REPL_POSTHOG_API_KEY}", "replace": "'$POSTHOG_API_KEY'"}]' aliases.mainnet.json | tr -d "\n\r")" >> $GITHUB_OUTPUT
- name: Replace placeholders
uses: flcdrg/replace-multiple-action@v1
with:
files: "**/*.jsx"
find: "${{ steps.set_replacements.outputs.replacements }}"
prefix: "(^|.*)"
suffix: "($|.*)"

- name: Install bos CLI
run: |
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/FroVolod/bos-cli-rs/releases/download/v0.3.6/bos-cli-installer.sh | sh
- name: Deploy widgets
run: |
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
echo "on branch $BRANCH"
if [[ "$BRANCH" != "main" ]]; then
echo "Not on main branch, dry run by diff with infrastructure-committee.near"
bos components diff infrastructure-committee.near network-config mainnet
else
bos components deploy "$NEAR_INFRA_SOCIAL_DEPLOY_ID" sign-as "$NEAR_INFRA_SOCIAL_ACCOUNT_ID" network-config mainnet sign-with-plaintext-private-key --signer-public-key "$NEAR_INFRA_SOCIAL_ACCOUNT_PUBLIC_KEY" --signer-private-key "$NEAR_INFRA_SOCIAL_ACCOUNT_PRIVATE_KEY" send
fi
2 changes: 2 additions & 0 deletions instances/infrastructure-committee.near/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
dist
12 changes: 12 additions & 0 deletions instances/infrastructure-committee.near/aliases.mainnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"REPL_DEVHUB": "devhub.near",
"REPL_INFRASTRUCTURE_COMMITTEE": "infrastructure-committee.near",
"REPL_INFRASTRUCTURE_COMMITTEE_CONTRACT": "infrastructure-committee.near",
"REPL_NEAR": "near",
"REPL_RPC_URL": "https://rpc.mainnet.near.org",
"REPL_RFP_IMAGE": "https://ipfs.near.social/ipfs/bafkreicbygt4kajytlxij24jj6tkg2ppc2dw3dlqhkermkjjfgdfnlizzy",
"REPL_RFP_FEED_INDEXER_QUERY_NAME": "polyprogrammist_near_devhub_ic_v1_rfps_with_latest_snapshot",
"REPL_RFP_INDEXER_QUERY_NAME": "polyprogrammist_near_devhub_ic_v1_rfp_snapshots",
"REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME": "polyprogrammist_near_devhub_ic_v1_proposals_with_latest_snapshot",
"REPL_PROPOSAL_QUERY_NAME": "polyprogrammist_near_devhub_ic_v1_proposal_snapshots"
}
6 changes: 6 additions & 0 deletions instances/infrastructure-committee.near/bos.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"account": "infrastructure-committee.near",
"aliasPrefix": "REPL",
"aliasesContainsPrefix": true,
"aliases": ["./aliases.mainnet.json"]
}
3 changes: 3 additions & 0 deletions instances/infrastructure-committee.near/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"infrastructure-committee.near": {}
}
1 change: 1 addition & 0 deletions instances/infrastructure-committee.near/src
129 changes: 129 additions & 0 deletions instances/infrastructure-committee.near/widget/app.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/**
* This is the main entry point for the RFP application.
* Page route gets passed in through params, along with all other page props.
*/

const { page, ...passProps } = props;

// Import our modules
const { AppLayout } = VM.require(
`${REPL_INFRASTRUCTURE_COMMITTEE}/widget/components.template.AppLayout`
);

if (!AppLayout) {
return <p>Loading modules...</p>;
}

// CSS styles to be used across the app.
// Define fonts here, as well as any other global styles.
const Theme = styled.div`
a {
color: inherit;
}
.attractable {
box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
transition: box-shadow 0.6s;
&:hover {
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}
}
`;

if (!page) {
// If no page is specified, we default to the feed page TEMP
page = "about";
}

// This is our navigation, rendering the page based on the page parameter
function Page() {
const routes = page.split(".");
switch (routes[0]) {
case "about": {
return (
<Widget
src={`${REPL_INFRASTRUCTURE_COMMITTEE}/widget/components.pages.about`}
props={passProps}
/>
);
}
case "rfps": {
return (
<Widget
src={`${REPL_INFRASTRUCTURE_COMMITTEE}/widget/components.rfps.Feed`}
props={passProps}
/>
);
}
case "rfp": {
return (
<Widget
src={`${REPL_INFRASTRUCTURE_COMMITTEE}/widget/components.rfps.Rfp`}
props={passProps}
/>
);
}
case "create-rfp": {
return (
<Widget
src={`${REPL_INFRASTRUCTURE_COMMITTEE}/widget/components.rfps.Editor`}
props={passProps}
/>
);
}
case "create-proposal": {
return (
<Widget
src={`${REPL_INFRASTRUCTURE_COMMITTEE}/widget/components.proposals.Editor`}
props={{ ...passProps }}
/>
);
}

case "proposals": {
return (
<Widget
src={`${REPL_INFRASTRUCTURE_COMMITTEE}/widget/components.proposals.Feed`}
props={passProps}
/>
);
}
case "proposal": {
return (
<Widget
src={`${REPL_INFRASTRUCTURE_COMMITTEE}/widget/components.proposals.Proposal`}
props={passProps}
/>
);
}
case "about": {
return (
<Widget
src={`${REPL_INFRASTRUCTURE_COMMITTEE}/widget/components.pages.about`}
props={passProps}
/>
);
}
case "admin": {
return (
<Widget
src={`${REPL_INFRASTRUCTURE_COMMITTEE}/widget/components.pages.admin`}
props={passProps}
/>
);
}
default: {
// TODO: 404 page
return <p>404</p>;
}
}
}

return (
<Theme>
<AppLayout page={page}>
<Page />
</AppLayout>
</Theme>
);
Loading

0 comments on commit bd8dbd0

Please sign in to comment.