Skip to content

Commit 9cf880a

Browse files
committed
chore: add new PR workflow
1 parent 6f65523 commit 9cf880a

File tree

2 files changed

+257
-1
lines changed

2 files changed

+257
-1
lines changed

.github/workflows/pr-test.yml

Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
name: Pull Request Tests
2+
on:
3+
pull_request:
4+
# TODO: remove it
5+
branches: [main]
6+
7+
jobs:
8+
build-and-cache:
9+
strategy:
10+
fail-fast: false
11+
runs-on: ubuntu-latest
12+
env:
13+
NPM_CONFIG_UNSAFE_PERM: true
14+
NODE_OPTIONS: --max-old-space-size=4096
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
# Use the same Node.js version used for `release-please` workflow.
21+
- uses: actions/setup-node@v4
22+
with:
23+
node-version: 18
24+
- name: Install
25+
run: npm ci
26+
# TODO: check if compiling only the affected modules is correct
27+
- name: Compile (Delta)
28+
run: npm run compile:ci:changed
29+
- name: Upload Build Artifacts
30+
uses: actions/upload-artifact@v4
31+
with:
32+
name: tests-build-cache-${{ github.run_number }}
33+
path: .nx
34+
include-hidden-files: true
35+
if-no-files-found: error
36+
retention-days: 1
37+
38+
unit-and-tav-test:
39+
needs: build-and-cache
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
node:
44+
- "18.19.0"
45+
- "18"
46+
- "20.6.0"
47+
- "20"
48+
- "22"
49+
runs-on: ubuntu-latest
50+
services:
51+
memcached:
52+
image: memcached:1.6.37-alpine
53+
ports:
54+
- 11211:11211
55+
mongo:
56+
image: mongo
57+
ports:
58+
- 27017:27017
59+
mssql:
60+
image: mcr.microsoft.com/mssql/server:2022-latest
61+
env:
62+
MSSQL_SA_PASSWORD: mssql_passw0rd
63+
ACCEPT_EULA: Y
64+
ports:
65+
- 1433:1433
66+
options: >-
67+
--health-cmd "/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P $MSSQL_SA_PASSWORD -C -Q 'select 1' -b -o /dev/null"
68+
--health-interval 1s
69+
--health-timeout 30s
70+
--health-start-period 10s
71+
--health-retries 20
72+
mysql:
73+
image: mysql:5.7
74+
env:
75+
MYSQL_USER: otel
76+
MYSQL_PASSWORD: secret
77+
MYSQL_DATABASE: otel_mysql_database
78+
MYSQL_ROOT_PASSWORD: rootpw
79+
ports:
80+
- 3306:3306
81+
options: >-
82+
--health-cmd="mysqladmin ping"
83+
--health-interval 10s
84+
--health-timeout 5s
85+
--health-retries 5
86+
oracledb:
87+
image: gvenzl/oracle-free:slim
88+
env:
89+
APP_USER: otel
90+
APP_USER_PASSWORD: secret
91+
ORACLE_PASSWORD: oracle
92+
ports:
93+
- 1521:1521
94+
options: >-
95+
--health-cmd "sqlplus system/oracle@//localhost/FREEPDB1"
96+
--health-interval 10s
97+
--health-timeout 5s
98+
--health-retries 5
99+
postgres:
100+
image: postgres:16-alpine
101+
env:
102+
POSTGRES_USER: postgres
103+
POSTGRES_DB: otel_pg_database
104+
POSTGRES_PASSWORD: postgres
105+
ports:
106+
- 5432:5432
107+
options: >-
108+
--health-cmd pg_isready
109+
--health-interval 10s
110+
--health-timeout 5s
111+
--health-retries 5
112+
redis:
113+
image: redis
114+
ports:
115+
- 6379:6379
116+
options: >-
117+
--health-cmd "redis-cli ping"
118+
--health-interval 10s
119+
--health-timeout 5s
120+
--health-retries 5
121+
cassandra:
122+
image: bitnami/cassandra:3
123+
ports:
124+
- 9042:9042
125+
rabbitmq:
126+
image: rabbitmq:3
127+
ports:
128+
- 22221:5672
129+
env:
130+
RABBITMQ_DEFAULT_USER: username
131+
RABBITMQ_DEFAULT_PASS: password
132+
env:
133+
RUN_CASSANDRA_TESTS: 1
134+
RUN_MEMCACHED_TESTS: 1
135+
RUN_MONGODB_TESTS: 1
136+
RUN_MYSQL_TESTS: 1
137+
RUN_MSSQL_TESTS: 1
138+
RUN_ORACLEDB_TESTS: 1
139+
RUN_POSTGRES_TESTS: 1
140+
RUN_REDIS_TESTS: 1
141+
RUN_RABBIT_TESTS: 1
142+
CASSANDRA_HOST: localhost
143+
MONGODB_DB: opentelemetry-tests
144+
MONGODB_HOST: 127.0.0.1
145+
MONGODB_PORT: 27017
146+
MSSQL_PASSWORD: mssql_passw0rd
147+
MYSQL_DATABASE: otel_mysql_database
148+
MYSQL_HOST: 127.0.0.1
149+
MYSQL_PASSWORD: secret
150+
MYSQL_ROOT_PASSWORD: rootpw
151+
MYSQL_PORT: 3306
152+
MYSQL_USER: otel
153+
OPENTELEMETRY_MEMCACHED_HOST: localhost
154+
OPENTELEMETRY_MEMCACHED_PORT: 11211
155+
OPENTELEMETRY_REDIS_HOST: localhost
156+
OPENTELEMETRY_REDIS_PORT: 6379
157+
ORACLE_HOSTNAME: localhost
158+
ORACLE_PORT: 1521
159+
ORACLE_CONNECTSTRING: localhost:1521/freepdb1
160+
ORACLE_USER: otel
161+
ORACLE_PASSWORD: secret
162+
ORACLE_SERVICENAME: FREEPDB1
163+
POSTGRES_DB: otel_pg_database
164+
POSTGRES_HOST: localhost
165+
POSTGRES_PORT: 5432
166+
POSTGRES_USER: postgres
167+
POSTGRES_PASSWORD: postgres
168+
NPM_CONFIG_UNSAFE_PERM: true
169+
steps:
170+
- name: Checkout
171+
uses: actions/checkout@v4
172+
with:
173+
fetch-depth: 0
174+
- uses: actions/setup-node@v4
175+
with:
176+
node-version: ${{ matrix.node }}
177+
- name: Set MySQL variables
178+
run: mysql --user=root --password=${MYSQL_ROOT_PASSWORD} --host=${MYSQL_HOST} --port=${MYSQL_PORT} -e "SET GLOBAL log_output='TABLE'; SET GLOBAL general_log = 1;" mysql
179+
- name: Install
180+
run: npm ci
181+
- name: Download Build Artifacts
182+
uses: actions/download-artifact@v4
183+
with:
184+
name: tests-build-cache-${{ github.run_number }}
185+
path: .nx
186+
# TODO: check if compiling only the affected modules is correct
187+
- name: Compile (Delta)
188+
run: npm run compile:ci:changed
189+
- name: Unit tests (Delta)
190+
run: npm run test:ci:changed
191+
- name: Unit tests (Delta)
192+
run: npm run test-all-versions:ci:changed
193+
# TODO: save coverage for later
194+
# - name: Upload Test Artifacts
195+
# uses: actions/upload-artifact@v4
196+
# with:
197+
# name: tests-coverage-cache-${{ github.run_number }}-${{ matrix.node }}
198+
# path: .nx
199+
# include-hidden-files: true
200+
# if-no-files-found: error
201+
# retention-days: 1
202+
# TODO: how to put back everythign in coverage???
203+
# test-coverage-report:
204+
# runs-on: ubuntu-latest
205+
# steps:
206+
# - name: Download Test Artifacts
207+
# uses: actions/download-artifact@v4
208+
# with:
209+
# name: tests-build-cache-${{ github.run_number }}
210+
# path: .nx
211+
212+
# - name: Report Coverage
213+
# uses: codecov/codecov-action@v5
214+
# env:
215+
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
216+
# with:
217+
# verbose: true
218+
219+
# browser-test:
220+
# needs: build-and-cache
221+
# strategy:
222+
# fail-fast: false
223+
# matrix:
224+
# node: ["22"]
225+
# runs-on: ubuntu-latest
226+
# env:
227+
# NPM_CONFIG_UNSAFE_PERM: true
228+
# NODE_OPTIONS: --max-old-space-size=4096
229+
# steps:
230+
# - name: Checkout
231+
# uses: actions/checkout@v4
232+
# with:
233+
# fetch-depth: 0
234+
# - uses: actions/setup-node@v4
235+
# with:
236+
# node-version: ${{ matrix.node }}
237+
# - name: Install
238+
# run: npm ci
239+
# - name: Download Build Artifacts
240+
# uses: actions/download-artifact@v4
241+
# with:
242+
# name: tests-build-cache-${{ github.run_number }}
243+
# path: .nx
244+
# - name: Build
245+
# run: npm run compile
246+
# - name: Unit tests
247+
# run: npm run test:browser
248+
# - name: Report Coverage
249+
# uses: codecov/codecov-action@v5
250+
# env:
251+
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
252+
# with:
253+
# verbose: true

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@
1515
"clean": "nx run-many -t clean",
1616
"version:update": "nx run-many -t version:update",
1717
"compile": "nx run-many -t compile",
18+
"compile:ci:changed": "nx affected -t compile --base=origin/main --head=HEAD",
1819
"test": "nx run-many -t test",
19-
"test:browser": "nx run-many -t test:browser",
2020
"test:ci:changed": "nx affected -t test --base=origin/main --head=HEAD",
21+
"test:browser": "nx run-many -t test:browser",
22+
"test:browser:ci:changed": "nx affected -t test:browser --base=origin/main --head=HEAD",
2123
"test-all-versions": "nx run-many -t test-all-versions",
24+
"test-all-versions:ci:changed": "nx affected -t test-all-versions --base=origin/main --head=HEAD",
2225
"changelog": "lerna-changelog",
2326
"lint": "nx run-many -t lint && npm run lint:deps && npm run lint:readme && npm run lint:markdown && npm run lint:semconv-deps",
2427
"lint:fix": "nx run-many -t lint:fix && npm run lint:markdown:fix",

0 commit comments

Comments
 (0)