-
Notifications
You must be signed in to change notification settings - Fork 4
141 lines (120 loc) · 4.4 KB
/
Copy pathcode-quality.yaml
File metadata and controls
141 lines (120 loc) · 4.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Code Quality
on:
pull_request:
branches:
- main
- release/**
push:
branches:
- main
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
pages: write
id-token: write
jobs:
lint-test-build:
name: Lint, Test, and Build
runs-on: ubuntu-latest
services:
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.24.0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22.21"
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Run lint
run: pnpm check-types
- name: Run tests
env:
REDIS_URL: redis://localhost:6379
DATABASE_URL: postgres://postgres:password@localhost:5432/radix-incentives
TOKEN_PRICE_SERVICE_API_KEY: ${{ secrets.TOKEN_PRICE_SERVICE_API_KEY }}
NODE_ENV: test
SKIP_INTEGRATION_TESTS: true
run: pnpm test:ci
- name: Build applications
run: pnpm build --filter=workers --filter=streamer --filter=incentives --filter=admin
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/radix-incentives
WORKERS_API_BASE_URL: http://localhost:3003
- name: Upload test coverage
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage
path: packages/api/coverage
retention-days: 7
- name: Coverage Report as Comment
if: github.event_name == 'pull_request'
run: |
if [ -f packages/api/coverage/coverage-summary.json ]; then
COVERAGE=$(cat packages/api/coverage/coverage-summary.json | jq -r '
"## 📊 Test Coverage Report\n\n" +
"| Metric | Coverage |\n" +
"|--------|----------|\n" +
"| **Lines** | " + (.total.lines.pct|tostring) + "% |\n" +
"| **Functions** | " + (.total.functions.pct|tostring) + "% |\n" +
"| **Branches** | " + (.total.branches.pct|tostring) + "% |\n" +
"| **Statements** | " + (.total.statements.pct|tostring) + "% |\n\n" +
"### Summary\n" +
"- **Total Lines:** " + (.total.lines.covered|tostring) + "/" + (.total.lines.total|tostring) + "\n" +
"- **Total Functions:** " + (.total.functions.covered|tostring) + "/" + (.total.functions.total|tostring) + "\n" +
"- **Total Branches:** " + (.total.branches.covered|tostring) + "/" + (.total.branches.total|tostring) + "\n" +
"- **Total Statements:** " + (.total.statements.covered|tostring) + "/" + (.total.statements.total|tostring) + "\n\n" +
"📋 **[View Detailed HTML Coverage Report](https://radixdlt.github.io/radix-incentives/)**\n\n" +
"*Coverage report generated by Vitest*"
')
gh pr comment ${{ github.event.pull_request.number }} --body "$COVERAGE" || echo "Failed to post coverage comment"
else
echo "Coverage summary file not found"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# TODO: Uncomment this when we have a way to deploy the coverage report to GitHub Pages
# deploy-coverage:
# name: Deploy Coverage Report
# needs: lint-test-build
# runs-on: ubuntu-latest
# if: github.event_name == 'pull_request' && github.repository == 'radixdlt/radix-incentives'
# environment:
# name: github-pages
# url: ${{ steps.deployment.outputs.page_url }}
# steps:
# - name: Download coverage artifact
# uses: actions/download-artifact@v4
# with:
# name: coverage
# path: ./coverage
# - name: Setup Pages
# uses: actions/configure-pages@v4
# - name: Upload to GitHub Pages
# uses: actions/upload-pages-artifact@v3
# with:
# path: ./coverage
# - name: Deploy to GitHub Pages
# id: deployment
# uses: actions/deploy-pages@v4