Skip to content

Commit

Permalink
Code static analysis per project (#21)
Browse files Browse the repository at this point in the history
* Add make recipe to lint & format code per project

* Format the whole codebase

* Remove main Makefile from CIs trigger target files

* Fix orchestration E2E tests
  • Loading branch information
wcalderipe authored Jan 19, 2024
1 parent d6e4673 commit 8276fd4
Show file tree
Hide file tree
Showing 33 changed files with 360 additions and 272 deletions.
6 changes: 3 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: "weekly"
interval: 'weekly'
9 changes: 4 additions & 5 deletions .github/workflows/authz_ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
name: "@app/authz CI"
name: '@app/authz CI'

on:
push:
paths:
- apps/authz/**
- .github/workflows/authz_ci.yml
- Makefile
- jest.config.ts
- jest.preset.js
- .eslintrc.json
Expand Down Expand Up @@ -60,8 +59,8 @@ jobs:
- name: Code format
shell: bash
run: |
make format/check
make lint/check
make authz/format/check
make authz/lint/check
# TODO: Finish once the authz-node has a database.
- name: Setup database and Prisma types
Expand Down Expand Up @@ -101,7 +100,7 @@ jobs:
uses: 8398a7/action-slack@v3
with:
username: GitHub
author_name: "@app/authz CI failed"
author_name: '@app/authz CI failed'
status: ${{ job.status }}
fields: message,commit,author
env:
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/authz_shared_ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
name: "@narval/authz-shared CI"
name: '@narval/authz-shared CI'

on:
push:
paths:
- packages/authz-shared/**
- .github/workflows/authz_shared_ci.yml
- Makefile
- jest.config.ts
- jest.preset.js
- .eslintrc.json
Expand Down Expand Up @@ -35,22 +34,21 @@ jobs:
- name: Code format
shell: bash
run: |
make format/check
make lint/check
make authz-shared/format/check
make authz-shared/lint/check
- name: Test unit
shell: bash
run: |
make authz-shared/test/unit
make authz-shared/test/unit
- name: Send Slack notification on failure
if: failure()
uses: 8398a7/action-slack@v3
with:
username: GitHub
author_name: "@narval/authz-shared CI failed"
author_name: '@narval/authz-shared CI failed'
status: ${{ job.status }}
fields: message,commit,author
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

9 changes: 4 additions & 5 deletions .github/workflows/orchestration_ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
name: "@app/orchestration CI"
name: '@app/orchestration CI'

on:
push:
paths:
- apps/orchestration/**
- .github/workflows/orchestration_ci.yml
- Makefile
- jest.config.ts
- jest.preset.js
- .eslintrc.json
Expand Down Expand Up @@ -60,8 +59,8 @@ jobs:
- name: Code format
shell: bash
run: |
make format/check
make lint/check
make orchestration/format/check
make orchestration/lint/check
- name: Setup database and Prisma types
shell: bash
Expand Down Expand Up @@ -97,7 +96,7 @@ jobs:
uses: 8398a7/action-slack@v3
with:
username: GitHub
author_name: "@app/orchestration CI failed"
author_name: '@app/orchestration CI failed'
status: ${{ job.status }}
fields: message,commit,author
env:
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/transaction_request_intent_ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
name: "@narval/transaction-request-intent CI"
name: '@narval/transaction-request-intent CI'

on:
push:
paths:
- packages/transaction-request-intent/**
- .github/workflows/transaction_request_intent_ci.yml
- Makefile
- jest.config.ts
- jest.preset.js
- .eslintrc.json
Expand Down Expand Up @@ -35,22 +34,21 @@ jobs:
- name: Code format
shell: bash
run: |
make format/check
make lint/check
make transaction-request-intent/format/check
make transaction-request-intent/lint/check
- name: Test unit
shell: bash
run: |
make transaction-request-intent/test/unit
make transaction-request-intent/test/unit
- name: Send Slack notification on failure
if: failure()
uses: 8398a7/action-slack@v3
with:
username: GitHub
author_name: "@narval/transaction-request-intent CI failed"
author_name: '@narval/transaction-request-intent CI failed'
status: ${{ job.status }}
fields: message,commit,author
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

17 changes: 11 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ include ./packages/transaction-request-intent/Makefile
TERM_NO_COLOR := \033[0m
TERM_GREEN := \033[0;32m

# == Install ==

install:
npm install

install/ci:
npm ci

# == Setup ==

setup:
make install
make docker/up
Expand All @@ -22,25 +26,26 @@ setup:
@echo "${TERM_GREEN}Orchestration & AuthZ applications are ready 🐋${TERM_NO_COLOR}"
@echo "${TERM_GREEN}Run 'make orchestration/start/dev' or/and 'make authz/start/dev' to get them running.${TERM_NO_COLOR}"

# == Docker ==

docker/stop:
docker-compose stop

docker/up:
docker-compose up --detach

# == Code format ==

format:
npx prettier \
--write "apps/**/*.ts" "packages/**/*.ts" "./*.{js,json}"
npx nx format:write --all

format/check:
npx prettier \
--check "apps/**/*.ts" "packages/**/*.ts" "./*.{js,json}"
npx nx format:check --all

lint:
npx nx run-many \
--target lint \
--fix

lint/check:
npx nx run-many \
--target lint
npx nx run-many --target lint
14 changes: 14 additions & 0 deletions apps/authz/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ authz/copy-default-env:
cp ${AUTHZ_PROJECT_DIR}/.env.default ${AUTHZ_PROJECT_DIR}/.env
cp ${AUTHZ_PROJECT_DIR}/.env.test.default ${AUTHZ_PROJECT_DIR}/.env.test

# == Code format ==

authz/format:
npx nx format:write --projects ${AUTHZ_PROJECT_NAME}

authz/lint:
npx nx lint ${AUTHZ_PROJECT_NAME} -- --fix

authz/format/check:
npx nx format:check --projects ${AUTHZ_PROJECT_NAME}

authz/lint/check:
npx nx lint ${AUTHZ_PROJECT_NAME}

# === Testing ===

authz/test/type:
Expand Down
10 changes: 10 additions & 0 deletions apps/authz/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,13 @@ make authz/test/unit
make authz/test/integration
make authz/test/e2e
```

## Formatting

```bash
make authz/format
make authz/lint

make authz/format/check
make authz/lint/check
```
130 changes: 67 additions & 63 deletions apps/authz/src/app/opa/poc/entities.json
Original file line number Diff line number Diff line change
@@ -1,65 +1,69 @@
{
"entities":{
"users": {
"test-bob-uid": {
"uid": "test-bob-uid",
"role": "root"
},
"test-alice-uid": {
"uid": "test-alice-uid",
"role": "member"
},
"test-foo-uid": {
"uid": "test-foo-uid",
"role": "admin"
},
"0xaaa8ee1cbaa1856f4550c6fc24abb16c5c9b2a43": {
"uid": "0xaaa8ee1cbaa1856f4550c6fc24abb16c5c9b2a43",
"role": "admin"
}
},
"wallets": {"eip155:eoa:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e": {
"uid": "eip155:eoa:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"address": "0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"accountType": "eoa",
"assignees": ["test-bob-uid", "test-bar-uid"]
}},
"user_groups": {
"test-user-group-one-uid": {
"uid": "test-user-group-one-uid",
"name": "dev",
"users": ["test-bob-uid", "test-bar-uid"]
},
"test-user-group-two-uid": {
"uid": "test-user-group-two-uid",
"name": "finance",
"users": ["test-bob-uid", "test-bar-uid"]
}
},
"wallet_groups": {"test-wallet-group-one-uid": {
"uid": "test-wallet-group-one-uid",
"name": "dev",
"wallets": ["eip155:eoa:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e"]
}},
"address_book": {
"eip155:137:0xa45e21e9370ba031c5e1f47dedca74a7ce2ed7a3": {
"uid": "eip155:137:0xa45e21e9370ba031c5e1f47dedca74a7ce2ed7a3",
"address": "0xa45e21e9370ba031c5e1f47dedca74a7ce2ed7a3",
"chain_id": 137,
"classification": "internal"
},
"eip155:137:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e": {
"uid": "eip155:137:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"address": "0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"chain_id": 137,
"classification": "wallet"
},
"eip155:1:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e": {
"uid": "eip155:1:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"address": "0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"chain_id": 1,
"classification": "wallet"
}
}
"entities": {
"users": {
"test-bob-uid": {
"uid": "test-bob-uid",
"role": "root"
},
"test-alice-uid": {
"uid": "test-alice-uid",
"role": "member"
},
"test-foo-uid": {
"uid": "test-foo-uid",
"role": "admin"
},
"0xaaa8ee1cbaa1856f4550c6fc24abb16c5c9b2a43": {
"uid": "0xaaa8ee1cbaa1856f4550c6fc24abb16c5c9b2a43",
"role": "admin"
}
},
"wallets": {
"eip155:eoa:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e": {
"uid": "eip155:eoa:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"address": "0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"accountType": "eoa",
"assignees": ["test-bob-uid", "test-bar-uid"]
}
},
"user_groups": {
"test-user-group-one-uid": {
"uid": "test-user-group-one-uid",
"name": "dev",
"users": ["test-bob-uid", "test-bar-uid"]
},
"test-user-group-two-uid": {
"uid": "test-user-group-two-uid",
"name": "finance",
"users": ["test-bob-uid", "test-bar-uid"]
}
},
"wallet_groups": {
"test-wallet-group-one-uid": {
"uid": "test-wallet-group-one-uid",
"name": "dev",
"wallets": ["eip155:eoa:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e"]
}
},
"address_book": {
"eip155:137:0xa45e21e9370ba031c5e1f47dedca74a7ce2ed7a3": {
"uid": "eip155:137:0xa45e21e9370ba031c5e1f47dedca74a7ce2ed7a3",
"address": "0xa45e21e9370ba031c5e1f47dedca74a7ce2ed7a3",
"chain_id": 137,
"classification": "internal"
},
"eip155:137:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e": {
"uid": "eip155:137:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"address": "0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"chain_id": 137,
"classification": "wallet"
},
"eip155:1:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e": {
"uid": "eip155:1:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"address": "0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"chain_id": 1,
"classification": "wallet"
}
}
}
}
}
Loading

0 comments on commit 8276fd4

Please sign in to comment.