-
-
Notifications
You must be signed in to change notification settings - Fork 5
175 lines (148 loc) · 4.72 KB
/
node.yml
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: NestJS Tools CI
on:
push:
paths-ignore:
- 'README.md'
- '**/package-lock.json'
branches:
- main
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
paths-ignore:
- 'README.md'
- '**/package-lock.json'
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
NX_CLOUD_DISTRIBUTED_EXECUTION: false
NX_DISTRIBUTED_TASK_EXECUTION: false
CI: true
S3_BUCKET: ${{ vars.S3_BUCKET }}
S3_REGION: ${{ vars.S3_REGION }}
GC_BUCKET: ${{ vars.GC_BUCKET }}
GC_PROJECT_ID: ${{ vars.GC_PROJECT_ID }}
permissions:
contents: read
pull-requests: write
id-token: write
actions: read
jobs:
setup-and-test:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }}
timeout-minutes: 10
strategy:
matrix:
node-version: [18.x, 20.x]
services:
rabbitmq:
image: rabbitmq:3.13-management-alpine
options: >-
--health-cmd "rabbitmq-diagnostics status"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5672:5672
redis:
image: redis:7.4-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
- name: configure AWS credentials
uses: mcblair/[email protected]
with:
role-arn: arn:aws:iam::555175933160:role/Github_Actions_S3
profile-name: github-actions
region: ${{ env.S3_REGION }}
- name: configure Google Cloud credentials
uses: 'google-github-actions/auth@v2'
with:
project_id: ${{ env.GC_PROJECT_ID }}
workload_identity_provider: 'projects/686264090118/locations/global/workloadIdentityPools/github/providers/nestjs-tools'
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Derive appropriate SHAs for base and head for `nx affected` commands
id: set-sha
uses: nrwl/nx-set-shas@v4
- name: Install dependencies
run: npm ci
- uses: 8BitJonny/[email protected]
id: current-pr
- if: steps.current-pr.outputs.number != 'null' && github.ref_name != 'main'
# This line is needed for nx affected to work when CI is running on a PR
run: git branch --track main origin/main
# Boot package has issues with @asyncapi monorepo
# - name: Scan dependencies with Audit CI
# run: npm run scan:deps
- run: npx nx format:check
- name: Run checks
env:
CI: true
# S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
# S3_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
AWS_PROFILE: github-actions
S3_BUCKET: ${{ env.S3_BUCKET }}
S3_REGION: ${{ env.S3_REGION }}
GC_BUCKET: ${{ env.GC_BUCKET }}
GC_PROJECT_ID: ${{ env.GC_PROJECT_ID }}
PREFIX: ${{ matrix.node-version }}
run: npx nx affected -t lint,test,build --parallel=2
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.node-version }}
path: ./coverage
retention-days: 2
scan:
needs: setup-and-test
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
node-version: [20.x]
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Get current version
id: package-version
uses: martinbeentjes/npm-get-version-action@main
- name: Retrieve coverage
uses: actions/download-artifact@v4
with:
name: coverage-${{ matrix.node-version }}
path: ./coverage
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.projectVersion=${{ steps.package-version.outputs.current-version }}