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

Release v0.12.0 #887

Merged
merged 46 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
31305d1
Bump undici from 5.28.3 to 5.28.4
dependabot[bot] Apr 4, 2024
9b56c00
Bump @solana/web3.js from 1.76.0 to 1.91.6
dependabot[bot] Apr 17, 2024
74f9fdc
start adding tenderly
tyler17 Apr 23, 2024
33d753b
add tenderly support, remove goerlifork
tyler17 Apr 23, 2024
9ca8782
fix env var
tyler17 Apr 24, 2024
0059265
show other networks on preview deployments
tyler17 Apr 24, 2024
d08bcb5
Get AVCs and delegates loading on tenderly
adamgoth Apr 24, 2024
886da40
Add tenderly spock URL
adamgoth Apr 24, 2024
c9f1993
Merge pull request #876 from makerdao/tenderly-delegates
tyler17 Apr 24, 2024
5a8e3ed
update chainIds
tyler17 Apr 24, 2024
4e77f6d
try to get some e2es working
tyler17 Apr 25, 2024
3733adf
use arbitrum sepolia polling contract for tenderly
tyler17 Apr 25, 2024
fdd1336
Merge pull request #869 from makerdao/dependabot/npm_and_yarn/solana/…
adamgoth Apr 26, 2024
ded66b4
Merge pull request #863 from makerdao/dependabot/npm_and_yarn/undici-…
adamgoth Apr 26, 2024
26d7311
Merge branch 'develop' of https://github.com/makerdao/governance-port…
adamgoth Apr 26, 2024
cbb84c6
Generate new network sdk
adamgoth Apr 26, 2024
52517d0
Start removing goerli
adamgoth Apr 26, 2024
1e66681
Merge pull request #878 from makerdao/update-testnet-sdk
tyler17 Apr 26, 2024
b696c22
fix chainId in CustomizedBridge
tyler17 Apr 26, 2024
b2ce440
Merge branch 'tenderly' of https://github.com/makerdao/governance-por…
adamgoth Apr 29, 2024
5bf0f12
Remove rest of goerli references
adamgoth Apr 29, 2024
2fc698a
Merge pull request #879 from makerdao/remove-goerli
tyler17 Apr 30, 2024
ee935d5
remove hardhat and cypress dependencies
tyler17 May 1, 2024
92ee535
remove remaining hardat and cypress code
tyler17 May 1, 2024
0e49122
fix test
tyler17 May 1, 2024
7b676bb
more goerli removals
tyler17 May 1, 2024
9b1992c
fix build
tyler17 May 1, 2024
17c322a
fix issue with active proposal
tyler17 May 1, 2024
bbe00f6
Merge pull request #881 from makerdao/hardhat-removal
adamgoth May 1, 2024
787e3f9
use correct defender relayer for tenderly
tyler17 May 1, 2024
464e5d2
handle sepolia contract, update address
tyler17 May 2, 2024
83c56d9
always create polls on v1 polling contract
tyler17 May 9, 2024
ec6f785
update aggregated polls tenderly files
tyler17 May 10, 2024
81599b0
Merge pull request #883 from makerdao/master
adamgoth May 13, 2024
4480800
Bump next, react versions
adamgoth May 13, 2024
33e192a
Merge branch 'develop' of https://github.com/makerdao/governance-port…
adamgoth May 13, 2024
a836758
Add network validation
adamgoth May 14, 2024
2d9efab
Remove goerli references
adamgoth May 14, 2024
3e569f9
Merge branch 'tenderly' of https://github.com/makerdao/governance-por…
adamgoth May 14, 2024
1de8eef
Fix build
adamgoth May 14, 2024
2e50e1c
Merge pull request #875 from makerdao/tenderly
adamgoth May 14, 2024
590f9cf
Merge branch 'develop' of https://github.com/makerdao/governance-port…
adamgoth May 14, 2024
872dd9a
Merge pull request #886 from makerdao/next-v14
adamgoth May 14, 2024
6549b1e
Remove deepsource
adamgoth May 15, 2024
e6410e8
remove gasless banner
tyler17 May 16, 2024
4b8489e
set showVoting to true on polling page for active polls
tyler17 May 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
14 changes: 0 additions & 14 deletions .deepsource.toml

This file was deleted.

3 changes: 2 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ INFURA_KEY=
ALCHEMY_KEY=
ETHERSCAN_KEY=
POCKET_KEY=
GOERLI_FORK_API_KEY=
GITHUB_TOKEN=
MONGODB_URI=
MONGODB_COMMENTS_DB=
Expand All @@ -14,6 +13,8 @@ MIGRATION_WEBHOOK_URL=
GASLESS_WEBHOOK_URL=
GASLESS_DISABLED=false
DASHBOARD_PASSWORD=
NEXT_PUBLIC_TENDERLY_RPC_KEY=
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=

# this is used to determine which database to fetch data from
NEXT_PUBLIC_VERCEL_ENV=development
1 change: 0 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jest-dom/recommended",
"plugin:cypress/recommended"
],
"globals": {
"cy": true
Expand Down
68 changes: 0 additions & 68 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -1,68 +0,0 @@
name: E2E Tests

on:
push:
branches:
- master
- develop
pull_request:
# Sequence of patterns matched against refs/heads
branches:
- master
- develop
jobs:
ui-chrome-tests:
runs-on: ubuntu-latest
container: cypress/browsers:node16.18.0-chrome107-ff106-edge
strategy:
fail-fast: false
env:
INFURA_KEY: ${{ secrets.INFURA_KEY }}
MONGODB_COMMENTS_DB: ${{ secrets.MONGODB_COMMENTS_DB }}
MONGODB_URI: ${{ secrets.MONGODB_URI }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOERLI_FORK_API_KEY: ${{ secrets.GOERLI_FORK_API_KEY }}
ETHERSCAN_KEY: ${{ secrets.ETHERSCAN_KEY }}
POCKET_KEY: ${{ secrets.POCKET_KEY }}
ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}
REDIS_URL: ${{ secrets.REDIS_URL }}
USE_CACHE: true

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install node packages
run: yarn

## Download prebuilt next data
# - name: Download the build folders
# uses: actions/download-artifact@v2
# with:
# name: build

- name: 'UI Tests - Chrome'
uses: cypress-io/github-action@v3
with:
# we have already installed all dependencies above
# use (install: false) if you want to do parallel jobs.
install: false
start: yarn start:ci
## command: yarn run e2e:ci
wait-on: 'http://localhost:3000'
wait-on-timeout: 120
browser: chrome
record: true
parallel: false
group: 'UI - Chrome'
spec: cypress/integration/**
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# Recommended: pass the GitHub token lets this action correctly
# determine the unique run id necessary to re-run the checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Codecov
run: |
yarn add --dev codecov
./node_modules/.bin/codecov -f combined-coverage/lcov.info
106 changes: 3 additions & 103 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ While the portal is hosted by MakerDAO at https://vote.makerdao.com, it can also

In order to run the project locally, you must have the following installed on the machine:

- Node, version 14 or greater ([install](https://nodejs.dev/learn/how-to-install-nodejs))
- Node, version 18.17 or greater ([install](https://nodejs.dev/learn/how-to-install-nodejs))

To get started, clone the repository to the desired directory and then navigate into the project folder:

Expand Down Expand Up @@ -115,8 +115,6 @@ The following configuration values can be added to the `.env` file:

#### Optional (DUX-specific config, no performance improvements):

- Set `GOERLI_FORK_API_KEY` to a valid [Infura](https://docs.infura.io/infura/networks/ethereum/how-to/secure-a-project/project-id) API key for Hardhat to use during e2e testing

- Set `MIGRATION_WEBHOOK_URL` for sending migration requests to discord

- Set `GASLESS_WEBHOOK_URL` for sending gasless vote requests to discord
Expand All @@ -135,9 +133,9 @@ The following configuration values can be added to the `.env` file:

### Tests

The Governance portal includes two test suites: Jest and Cypress
The Governance portal includes two test suites: Jest and E2E (TODO)

Jest tests under the folder `__tests__` currently execute unit tests of the platform. The e2e Cypress tests are under the `cypress` folder.
Jest tests under the folder `__tests__` currently execute unit tests of the platform.

#### Test commands

Expand All @@ -151,100 +149,6 @@ npm run test
npm run test:ci
```

Cypress:

```bash
# opens a cypress browser for the e2e
npm run e2e

# runs e2e tests in a headless manner, for CI systems
npm run e2e:headless
```

#### Goerli fork

By default, e2e tests run on a fork of Goerli. We do this because the governance contracts are deployed in Goerli for testing purposes. We also need to start the governance polling database services in a docker container so that the database and the forked chains are in sync. Please follow these steps:

1. First we want to spin up our networks: the forked Goerli and the forked Arbitrum Testnet (for testing gasless voting). The following command will start the two networks on ports 8545 and 8546 respectively.

```bash
npm run hardhat:gasless:config
```

2. When you see the accounts & keys displayed in the terminal, you can now start the dockerized database services. You may need to pull down the latest images from docker if you don't have them. In a new terminal window type these two commands:

```bash
docker-compose pull

docker-compose up
```

This will download two images, the first is a pre-seeded postgres database containing all the data you need to get started. The second one contains the API and ETL services required to work with our tests. This allows the test database to listen for events on the testchain, and return the requested data to the frontend, just as it is done in production. Wait a few minutes for the images to download and the services to start. When you see the following message displayed it means the services are ready and you can proceed to the next step:

`"Running a GraphQL API server at http://localhost:3001"`

Note: when you're finished running tests, you can remove the docker images by running `docker-compose down`. This will reset the database to its original state the next time you run the tests.

3. Now that our testchains and our database services are running, we can start the e2e tests. Run the following command in yet another new terminal window to start cypress:

```
npm run e2e
```

Note: Make sure to fill in the `GOERLI_FORK_API_KEY` environment variable.

You can use this local network from MetaMask, by switching to the "localhost:8545" network, with chain ID: `31337`. In order to get a wallet with some MKR and ETH you can run the script: `npm run fund` that will send some MKR and ETH to the first 50 wallets under the `/cypress/support/constants/keypairs.json`.

For more information about the fund process, take a look at `/scripts/setup.js`

**Writing e2e**:

Please refer to: https://docs.cypress.io/guides/references/best-practices and check current test examples under the cypress folder.

At the beginning of each test or describe-block, we run two commands to fork the hardhat networks & reset the database. This ensures that the tests are run from a clean slate and using the same blockchain and database state beforehand. Add the functions into a `before` or `beforeEach` block like this:

```js
before(() => {
forkNetwork(); // Restarts the blockchain & re-funds all the accounts
resetDatabase(); // Wipes the db and starts over from its initial state
});
```

**Windows support**

If you are using Windows and WSL you will need to install XLaunch to be able to launch a client for the UI, remember to disable access control.

#### Adding Data to the DB for Tests

The docker image of the gov polling db starts out with a very minimal amount of data (to conserve space), but you may require some extra data for tests. For example, you may want to add some additional polls, or add some delegates. Most of the tables in the DB have primary key constraints to other tables, which makes manually adding data via an `UPDATE` query time consuming and unstable. The easiest way to add data in a safe way is to have the gov polling db add this data on its own, the way it's done in production. The process works like this:

1. Spock adds block information (number & hash) to a row in a database.
2. Spock extracts the transactions from the block and scans these for specific events.
3. If an event is found, the corresponding event transformer is run to handle the event data, inserting the data into tables.

So, if we want to add a specific poll, first we locate the block in which the event was emitted (use Etherscan). We add the blocknumber to the list of blocknumbers in the `docker-compose.yml` file. Adding it to the `SEED_BLOCKS` environmental var (see example below).

```yml
spock:
image: makerdaodux/govpolldb-app:latest
container_name: spock-test-container
command: ['yarn', 'start-all']
environment:
- SEED_BLOCKS=5815619,6495082
depends_on:
postgres:
condition: service_healthy
ports: - '3001:3001'
```

Now, when the docker image is started or restarted, spock looks for the environmental variable and parses the block numbers that have been added. It then runs the process described above on each block, adding any events it finds to the respective tables.

NB: This data will not be persisted in the docker image when the image is shut down using the `docker-compose stop` command, but it will be recreated every time the ETL service is restarted, as long as it remains part of the `SEED_BLOCKS` env var.

**Future Enhancements:**

In time, this list of blocks will grow too large to maintain in this file. We can either permanently update the image with the data from these blocks, or move this list to an external file and load it into the env var that way.

### CI/CD

The CI/CD system is integrated with Github Actions.
Expand All @@ -255,14 +159,10 @@ After each push the system will execute:

- Unit test, execute Jest test suite

- E2E, executy cypress test suite and record results at https://dashboard.cypress.io/projects/uckcr1/runs

```bash
npm run start:ci
```

The command `npm run start:ci` launches a detached process with hardhat, executes e2e in a headless mode and kills the hardhat process.

### Contributing

See our [contributing guide](./CONTRIBUTING.md).
26 changes: 0 additions & 26 deletions cypress.config.ts

This file was deleted.

104 changes: 0 additions & 104 deletions cypress/e2e/account.spec.ts

This file was deleted.

Loading
Loading