-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #866 from Giveth/staging
Release 19 Feb 2023
- Loading branch information
Showing
239 changed files
with
28,890 additions
and
38,874 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,8 +43,10 @@ jobs: | |
run: npm ci | ||
- name: Run tslint | ||
run: npm run tslint | ||
- name: Run build | ||
run: npm run build | ||
- name: Run migrations | ||
run: npm run typeorm:cli:test -- migration:run | ||
run: npm run db:migrate:run:test | ||
- name: Run tests | ||
run: npm run test | ||
env: | ||
|
@@ -105,3 +107,24 @@ jobs: | |
username: ${{ secrets.PRODUCTION_USERNAME }} | ||
privateKey: ${{ secrets.PRODUCTION_PRIVATE_KEY}} | ||
|
||
|
||
deploy-k8s: | ||
if: github.ref == 'refs/heads/main'|| github.ref == 'refs/heads/staging' | ||
needs: publish | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@master | ||
- name: Deploy to Staging Cluster | ||
if: github.ref == 'refs/heads/staging' | ||
uses: steebchen/[email protected] | ||
with: # defaults to latest kubectl binary version | ||
config: ${{ secrets.KUBE_CONFIG }} | ||
command: rollout restart deployments/impact-graph -n backend | ||
# - name: Verify Staging Deployment | ||
# if: github.ref == 'refs/heads/staging' | ||
# uses: steebchen/[email protected] | ||
# with: | ||
# config: ${{ secrets.KUBE_CONFIG }} | ||
# version: v1.24.2 # specify kubectl binary version explicitly | ||
# command: rollout status deployments/impact-graph -n backend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,4 @@ src/scripts/*.json | |
*.DS_Store | ||
|
||
.adminbro | ||
.adminjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extension": ["ts"], | ||
"spec": [ | ||
"./test/pre-test-scripts.ts", | ||
"./src/**/*.test.ts", | ||
"./src/**/**/*.test.ts" | ||
], | ||
"timeout": 90000, | ||
"exit": true, | ||
"require": ["ts-node/register"], | ||
"retries": 2 | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extension": ["ts"], | ||
"timeout": 30000, | ||
"exit": true, | ||
"require": ["ts-node/register"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ ImpactQL is a GraphQL server, that enables rapid development of serverless impac | |
git clone [email protected]:topiahq/impact-graph.git | ||
cd impact-graph | ||
// we specief version in .nvmrc file, so when you just enter nvm use it will use exact version of required npm | ||
// we specified version in .nvmrc file, so when you just enter nvm use it will use exact version of required npm | ||
nvm use | ||
// You should have installed chromium on your system, it can be installed by your or package maneger (apt,brew, ..) | ||
|
@@ -111,10 +111,14 @@ If you want to see examples you can read test cases or see [Graphql queries](./t | |
### Admin panel | ||
We use [Admin Bro](https://github.com/SoftwareBrothers/adminjs) for Admin dashboard | ||
You should navigate to `/admin` for browsing admin panel. | ||
in your local database you can hash a desired password with `BCRYPT_SALT` that is in your `config/development.env` with | ||
in your local database you can hash a desired password with `BCRYPT_SALT` that is in your `config/development.env` with | ||
[bcrypt](https://github.com/kelektiv/node.bcrypt.js) then you set that value in `encryptedPassword` of your user in DB and | ||
change `role` of user to `admin` in db | ||
Now you can login in admin dashboard with your user's `email` and the `password` you already set | ||
Now you can login in admin dashboard with your user's `email` and the `password` you already set | ||
|
||
We wrote a migration file to create an admin user in local DB to can test it easily, | ||
so after executing migrations and run application you can navigate to http://localhost:4000/admin and login | ||
with this data `username`: **[email protected]**, `password`: **admin** | ||
|
||
**PS**: | ||
A simple script for create encryptedPassword | ||
|
@@ -156,39 +160,37 @@ After a site is live or if you want to keep your database you need to use databa | |
|
||
This can be done either by creating a new migration file with: | ||
|
||
``` | ||
npm run typeorm:cli migration:create -- -n UpdateUserEmailUnique -d migration | ||
``` | ||
#### Create new Migration file | ||
|
||
Or by changing the entities and generating the migrations with: | ||
``` | ||
npm run typeorm:cli migration:generate -- -n UpdateUserEmailUnique | ||
``` | ||
npx typeorm-ts-node-esm migration:create ./migration/create_organization_tokens_token_table | ||
Then you need to run the migrations like so: | ||
``` | ||
|
||
#### Run migrations | ||
``` | ||
npm run typeorm:cli -- migration:run | ||
npm run db:migrate:run:local | ||
``` | ||
|
||
#### Revert migrations | ||
If you want to revert last migration : | ||
|
||
``` | ||
npm run typeorm:cli -- migration:revert | ||
npm run db:migrate:revert:local | ||
``` | ||
|
||
### TEST | ||
For running tests you need to register infura and etherscan api-key, and you should pass this environment variables | ||
|
||
`PINATA_API_KEY=0000000000000 PINATA_SECRET_API_KEY=00000000000000000000000000000000000000000000000000000000 ETHERSCAN_API_KEY=0000000000000000000000000000000000 XDAI_NODE_HTTP_URL=https://xxxxxx.xdai.quiknode.pro INFURA_API_KEY=0000000000000000000000000000000000 ETHEREUM_NODE_ID=INFURA_API_KEY npm run test` | ||
`PINATA_API_KEY=0000000000000 PINATA_SECRET_API_KEY=00000000000000000000000000000000000000000000000000000000 ETHERSCAN_API_KEY=0000000000000000000000000000000000 XDAI_NODE_HTTP_URL=https://xxxxxx.xdai.quiknode.pro INFURA_API_KEY=0000000000000000000000000000000000 ETHEREUM_NODE_ID=INFURA_API_KEY npm run test` | ||
|
||
### PRE_COMMITS | ||
Please before committing your changes run | ||
`npm run prettify` to fix eslint and prettify warnings | ||
|
||
You will need to add the above command to your build process so that all database migrations are run upon deployments. | ||
|
||
### Statuses | ||
### Statuses | ||
You can generate table with this site | ||
https://www.tablesgenerator.com/markdown_tables | ||
|
||
|
@@ -203,7 +205,7 @@ https://www.tablesgenerator.com/markdown_tables | |
| 7 | cancelled | cancelled | Cancelled by Giveth Admin | admin | | ||
| 8 | drafted | drafted | This project is created as a draft for a potential new project, but can be discarded | project owner | | ||
|
||
**PS** | ||
**PS** | ||
* If a project is **cancelled** just admin can activate that | ||
* If project is **deactive** both admins and project owner can activate it | ||
* Both admins and project owner can deactivate an **active** project | ||
|
@@ -222,14 +224,14 @@ in below image links | |
|
||
### Power Snapshot | ||
|
||
Impact graph supports ranking projects based on power boosted by users. | ||
Impact graph supports ranking projects based on power boosted by users. | ||
Users who have GIVpower, can boost a project by allocating a portion (percentage) of their GIVpower to that project and after that impact-graph regularly takes snapshot of user GIVpower balance and boost percentages. | ||
At the end of each givback round (14 days), average of allocated power will be the effective power balance of each project. | ||
At the end of each givback round (14 days), average of allocated power will be the effective power balance of each project. | ||
|
||
Snapshotting mechanism is implemented in by the hlp of database cron job and impact graph support of historic user balance on blockchain. | ||
##### Database Snapshot | ||
Snapshot taking on database is implemented by the help `pg_cron` extension on Postgres database. | ||
On regular interval (defined by cron job expression), calls a db procedure called public."TAKE_POWER_BOOSTING_SNAPSHOT". | ||
On regular interval (defined by cron job expression), calls a db procedure called public."TAKE_POWER_BOOSTING_SNAPSHOT". | ||
This procedure creates a new record of power_snapshot and copies power boosting percentages content to another table and associates them to the new power_snapshot record. | ||
###### Cron Job Creation | ||
Cron job creation for test environment is already implemented in dbCronRepository.ts and a modified docker with enabled `pg_cron` extension. | ||
|
@@ -251,15 +253,15 @@ The cronjob expression above `*/5 * * * *` is for getting snapshot every 5 minut | |
3. Find created job id by running | ||
```sql | ||
SELECT * FROM cron.job | ||
ORDER BY jobid DESC | ||
ORDER BY jobid DESC | ||
``` | ||
![img.png](docs/img/pg_cron_jobs.png) | ||
4. Alter the job (found its id above, supposed here 1) database to whatever is set for impact-graph, here `deveop`. | ||
4. Alter the job (found its id above, supposed here 1) database to whatever is set for impact-graph, here `deveop`. | ||
```sql | ||
select cron.alter_job(job_id:=1,database:='develop'); | ||
``` | ||
|
||
For archiving old givpower snapshots data we must follow the same structure above, except in the 2nd step we must this command instead | ||
For archiving old givpower snapshots data we must follow the same structure above, except in the 2nd step we must this command instead | ||
```postgresql | ||
CREATE EXTENSION IF NOT EXISTS PG_CRON; | ||
SELECT CRON.schedule( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
migration-old-backup/1632203974464-addSlugHistoryColumnToProjects.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
migration-old-backup/1634808878248-makeWalletAddressNotNull.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
// tslint:disable-next-line:class-name | ||
export class makeWalletAddressNotNull1634808878248 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
'ALTER TABLE "project" ALTER COLUMN "walletAddress" SET NOT NULL', | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> {} | ||
// tslint:disable-next-line:no-empty | ||
async down(queryRunner: QueryRunner): Promise<void> {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.