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

Add events committee to main branch #843

Merged
merged 38 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
30e183e
added config json file
Tguntenaar Jun 18, 2024
96f57e9
added widget folder + symlink
Tguntenaar Jun 18, 2024
7786d66
dry run bos diff github action
Tguntenaar Jul 2, 2024
a9ceb29
test events-committee portal only
Tguntenaar Jul 2, 2024
a82b9b7
update docs
Tguntenaar Jul 2, 2024
394b851
add playwright project for events-committee
Tguntenaar Jul 2, 2024
b1f9dc9
add playwright specific tests for events committee
Tguntenaar Jul 2, 2024
7e58643
npm clean install
Tguntenaar Jul 2, 2024
cc38d76
workflow changes, dry run, project=events, remove curl
Tguntenaar Jul 2, 2024
7417c4a
use single webserver
Tguntenaar Jul 2, 2024
2072677
move blog.spec to sunset
Tguntenaar Jul 2, 2024
3d269ff
wip can't use test.use inside a block
Tguntenaar Jul 3, 2024
fce2107
fmt
Tguntenaar Jul 3, 2024
b47ee0a
reverse storageState changes
Tguntenaar Jul 4, 2024
fca373d
Merge branch 'main' of github.com:NEAR-DevHub/neardevhub-bos into fea…
Tguntenaar Jul 5, 2024
790ef36
add proposalAuthorAccountId to events playwright project
Tguntenaar Jul 5, 2024
4053d32
Merge branch 'main' of github.com:NEAR-DevHub/neardevhub-bos into fea…
Tguntenaar Jul 9, 2024
5f2f712
added mocked access key.
Tguntenaar Jul 10, 2024
50578eb
fix: playwright config
Tguntenaar Jul 10, 2024
f09187f
fix: storage states
Tguntenaar Jul 10, 2024
5bfdd3f
fix: added access key to storage state
Tguntenaar Jul 10, 2024
a620594
align this PR with infra PR changes
Tguntenaar Jul 10, 2024
9695d84
Merge branch 'main' of github.com:NEAR-DevHub/neardevhub-bos into fea…
Tguntenaar Jul 10, 2024
8e25428
change dry run text
Tguntenaar Jul 10, 2024
654b269
test: all events test except the dont ask again
Tguntenaar Jul 10, 2024
ff8341f
fix: events tests
Tguntenaar Jul 10, 2024
87afacd
fmt
Tguntenaar Jul 10, 2024
21e8999
ci: fix action
Tguntenaar Jul 10, 2024
db3cb8f
Merge branch 'main' into feature/events-bos-ws
Megha-Dev-19 Jul 10, 2024
d2cbcb4
Update .github/workflows/deploy-dry-mainnet-events.yml
Tguntenaar Jul 10, 2024
d37852e
Merge branch 'main' into feature/events-bos-ws
Megha-Dev-19 Jul 11, 2024
2ea4b88
Update .github/workflows/deploy-dry-mainnet-events.yml
Tguntenaar Jul 15, 2024
cb2b892
Merge branch 'main' of github.com:Tguntenaar/neardevhub-widgets into …
Tguntenaar Jul 15, 2024
a6dc3fd
fix: stay consistent with deploy script
Tguntenaar Jul 16, 2024
4db3095
improve github workflow clear message in overview
Tguntenaar Jul 16, 2024
e0bd449
ci: bos-loader dependencies
Tguntenaar Jul 16, 2024
8128622
fix: test profile name instead of handle
Tguntenaar Jul 16, 2024
068def4
fix: dont ask again widget src doesn't start with a slash
Tguntenaar Jul 16, 2024
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
40 changes: 40 additions & 0 deletions .github/workflows/continuous-integration-workflow-events.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI - Events 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-events:
name: Events 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=events npx playwright test --project=events playwright-tests/tests/events
2 changes: 0 additions & 2 deletions .github/workflows/continuous-integration-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ jobs:
- 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
Expand All @@ -49,7 +48,6 @@ jobs:
- 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
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/deploy-dry-mainnet-events.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Dry-run Deploy Widgets to Mainnet
Tguntenaar marked this conversation as resolved.
Show resolved Hide resolved
on:
pull_request:
push:
branches-ignore:
- main
jobs:
deploy-widgets:
runs-on: ubuntu-latest
name: Diff from PR
Tguntenaar marked this conversation as resolved.
Show resolved Hide resolved
defaults:
run:
working-directory: ./instances/events-committee.near
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install dependencies
run: |
npm ci

- 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: Dry run deploying widgets
run: |
bos components diff events-commitee.near network-config mainnet
22 changes: 21 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ To initiate the development environment, you can use the following script. This
npm run bw:dev:devhub
```

Running another instance like `events-committee.near` or `infra-structure-committee.near` can be done by the following scripts

```sh
npm run bw:dev:events
```

```sh
npm run bw:dev:infra
```

#### Customizing Creator ID, Contract ID, or Network

If you need to customize the account ID, override the contract ID, or specify a different network for your development environment, you can use the `overrides` feature of [bos-workspace](https://github.com/NEARBuilders/bos-workspace?tab=readme-ov-file#configuration).
Expand Down Expand Up @@ -91,10 +101,20 @@ npm run fmt

#### Writing tests

We use [Playwright](https://playwright.dev) for tests, which are located in the [playwright-tests](./playwright-tests/) folder. For each change or addition to the codebase you should also make sure that your changes are covered by tests in order to ensure that other developers will not break it in the future. Also you should write tests to accelerate your own development, so that you don't have to do manual coding/test interations via the browser.
We use [Playwright](https://playwright.dev) for tests, which are located in the [playwright-tests](./playwright-tests/) folder. For each change or addition to the codebase you should also make sure that your changes are covered by tests in order to ensure that other developers will not break it in the future. Also you should write tests to accelerate your own development, so that you don't have to do manual coding/test interactions via the browser.

Use the [dev-container](#using-a-dev-container) setup mentioned above for getting quick access to a complete development environment with test dependencies included, or see the [test-pipeline](./.github/workflows/continuous-integration-workflow.yml) for what dependencies that needs to be installed on your workstation for tests to run.

Use the following script to run the test UI for `devhub.near` or `events-committee.near`.

```sh
npm test -- --ui
```
or
```sh
npm run test:events -- --ui
```

Currently, none of the tests post actual transactions to the smart contracts. Still you should try writing your tests so that they do the actual function call, but just skip the final step of sending the transaction. You can do this by capturing the transaction confirmation popup provided by the NEAR social VM.

Here is an example snippet to capture the VM confirmation popup:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const clickbaitPrompt =
props.clickbaitPrompt ??
`Check out this ${postType} on @NearSocial_\n#NearSocial #NEAR #BOS\n${externalLink}`;

const twitterUrl = new URL("https://twitter.com/intent/tweet");
twitterUrl.searchParams.set("text", clickbaitPrompt);
const xUrl = new URL("https://x.com/intent/tweet");
xUrl.searchParams.set("text", clickbaitPrompt);

const mailtoUrl = new URL("mailto:");
mailtoUrl.searchParams.set(
Expand Down Expand Up @@ -93,11 +93,11 @@ return (
<li className="dropdown-item">
<a
className="link-dark text-decoration-none"
href={twitterUrl.toString()}
href={xUrl.toString()}
target="_blank"
>
<i className="bi bi-twitter" />
Share on Twitter
Share on X
</a>
</li>
</ul>
Expand Down
2 changes: 2 additions & 0 deletions instances/events-committee.near/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
dist
11 changes: 11 additions & 0 deletions instances/events-committee.near/aliases.mainnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"REPL_DEVHUB": "events-committee.near",
"REPL_DEVHUB_LEGACY": "devgovgigs.near",
"REPL_DEVHUB_CONTRACT": "events-committee.near",
"REPL_NEAR": "near",
"REPL_MOB": "mob.near",
"REPL_EFIZ": "efiz.near",
"REPL_DEVS": "devs.near",
"REPL_SOCIAL_CONTRACT": "social.near",
"REPL_RPC_URL": "https://rpc.mainnet.near.org"
}
6 changes: 6 additions & 0 deletions instances/events-committee.near/bos.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"account": "events-committee.near",
"aliasPrefix": "REPL",
"aliasesContainsPrefix": true,
"aliases": ["./aliases.mainnet.json"]
}
3 changes: 3 additions & 0 deletions instances/events-committee.near/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"events-committee.near": {}
}
1 change: 1 addition & 0 deletions instances/events-committee.near/src
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const { href } = VM.require("${REPL_DEVHUB}/widget/core.lib.url") || (() => {});

if (!props.type) {
return "Loading ...";
}

const type = props.type.split("/")[1];
return props.type ? (
<>
{type == "like"
? "liked your"
: type == "reply"
? "replied to your"
: type == "edit"
? "edited your"
: type == "mention"
? "mentioned you in their"
: "???"}{" "}
<a
className="fw-bold text-muted"
href={href({
widgetSrc: "${REPL_DEVHUB}/widget/app",
params: {
page: "post",
id: props.post,
},
})}
>
DevHub post
</a>
</>
) : (
"Loading ..."
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { href } = VM.require("${REPL_DEVHUB}/widget/core.lib.url") || (() => {});

return props.post === undefined ? (
"Loading ..."
) : (
<>
<a
className="btn btn-outline-dark"
href={href({
widgetSrc: "${REPL_DEVHUB}/widget/app",
params: {
page: "post",
id: props.post,
},
})}
>
View DevHub post
</a>
</>
);
106 changes: 106 additions & 0 deletions instances/events-committee.near/widget/app.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/**
* This is the main entry point for the DevHub application.
* Page route gets passed in through params, along with all other page props.
*/

const { onDraftStateChange } = VM.require(
"${REPL_DEVHUB}/widget/devhub.entity.post.draft"
);

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

// Import our modules
const { AppLayout } = VM.require(
"${REPL_DEVHUB}/widget/devhub.components.templates.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 = "home";
}

// This is our navigation, rendering the page based on the page parameter
function Page() {
const routes = page.split(".");
switch (routes[0]) {
case "create-proposal": {
return (
<Widget
src={"${REPL_DEVHUB}/widget/devhub.entity.proposal.Editor"}
props={{ ...passProps }}
/>
);
}

case "proposals": {
return (
<Widget
src={"${REPL_DEVHUB}/widget/devhub.page.proposals"}
props={passProps}
/>
);
}
case "proposal": {
return (
<Widget
src={"${REPL_DEVHUB}/widget/devhub.entity.proposal.Proposal"}
props={passProps}
/>
);
}
// ?page=about
case "about": {
return (
<Widget
src={"${REPL_DEVHUB}/widget/devhub.page.about"}
props={passProps}
/>
);
}
case "admin": {
return (
<Widget
src={"${REPL_DEVHUB}/widget/devhub.page.admin.index"}
props={passProps}
/>
);
}
default: {
return (
<Widget
src={"${REPL_DEVHUB}/widget/devhub.page.proposals"}
props={passProps}
/>
);
}
}
}

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