Skip to content

Commit c2a3421

Browse files
committed
chore: made test workflow for PRs and push
1 parent c261518 commit c2a3421

File tree

2 files changed

+64
-46
lines changed

2 files changed

+64
-46
lines changed

.github/workflows/pr-test.yml renamed to .github/workflows/test.yml

Lines changed: 59 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
name: Pull Request Tests
1+
name: Test Packages
22
on:
3+
push:
4+
branches: [main]
35
pull_request:
4-
# TODO: remove it
56
branches: [main]
67

78
permissions:
@@ -26,7 +27,14 @@ jobs:
2627
node-version: 18
2728
- name: Install
2829
run: npm ci
29-
# TODO: check if compiling only the affected modules is correct
30+
# Defaults for base and head commits are okay for PRs but
31+
# for pushed commits to main we should take as base the commit before
32+
# ref: https://nx.dev/ci/features/affected#configure-affected-on-ci
33+
- name: Set base and head commits (Push)
34+
if: ${{ github.event_name == 'push' }}
35+
run: |
36+
export NX_BASE=origin/main~1
37+
export NX_HEAD=origin/main
3038
- name: Compile (Delta)
3139
run: npm run compile:ci:affected
3240
- name: Upload Build Artifacts
@@ -173,6 +181,7 @@ jobs:
173181
POSTGRES_USER: postgres
174182
POSTGRES_PASSWORD: postgres
175183
NPM_CONFIG_UNSAFE_PERM: true
184+
NODE_OPTIONS: --max-old-space-size=4096
176185
steps:
177186
- name: Checkout
178187
uses: actions/checkout@v4
@@ -188,9 +197,18 @@ jobs:
188197
with:
189198
name: compile-cache-${{ github.run_number }}
190199
path: .nx
200+
# See comment in the compile job
201+
- name: Set base and head commits (Push)
202+
if: ${{ github.event_name == 'push' }}
203+
run: |
204+
export NX_BASE=origin/main~1
205+
export NX_HEAD=origin/main
191206
- name: Compile (Delta)
192207
run: npm run compile:ci:affected
193-
- name: Unit tests (Delta)
208+
- name: Unit tests (Browser - Delta)
209+
if: ${{ matrix.node == '22' }}
210+
run: npm run test:browser:ci:affected
211+
- name: Unit tests (Nodejs - Delta)
194212
run: npm run test:ci:affected
195213
- name: Test All Versions (Delta)
196214
run: npm run test-all-versions:ci:affected
@@ -203,43 +221,44 @@ jobs:
203221
retention-days: 1
204222
path: |
205223
!node_modules
206-
**/.nyc_output/**
224+
packages/*/.nyc_output/**
225+
LICENSE
207226
208-
browser-test:
209-
needs: compile
210-
strategy:
211-
fail-fast: false
212-
matrix:
213-
node: ["22"]
214-
runs-on: ubuntu-latest
215-
env:
216-
NPM_CONFIG_UNSAFE_PERM: true
217-
NODE_OPTIONS: --max-old-space-size=4096
218-
steps:
219-
- name: Checkout
220-
uses: actions/checkout@v4
221-
with:
222-
fetch-depth: 0
223-
- uses: actions/setup-node@v4
224-
with:
225-
node-version: ${{ matrix.node }}
226-
- name: Install
227-
run: npm ci
228-
- name: Download Build Artifacts
229-
uses: actions/download-artifact@v4
230-
with:
231-
name: compile-cache-${{ github.run_number }}
232-
path: .nx
233-
- name: Build
234-
run: npm run compile
235-
- name: Unit tests
236-
run: npm run test:browser
237-
- name: Report Coverage
238-
uses: codecov/codecov-action@v5
239-
env:
240-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
241-
with:
242-
verbose: true
227+
# browser-test:
228+
# needs: compile
229+
# strategy:
230+
# fail-fast: false
231+
# matrix:
232+
# node: ["22"]
233+
# runs-on: ubuntu-latest
234+
# env:
235+
# NPM_CONFIG_UNSAFE_PERM: true
236+
# NODE_OPTIONS: --max-old-space-size=4096
237+
# steps:
238+
# - name: Checkout
239+
# uses: actions/checkout@v4
240+
# with:
241+
# fetch-depth: 0
242+
# - uses: actions/setup-node@v4
243+
# with:
244+
# node-version: ${{ matrix.node }}
245+
# - name: Install
246+
# run: npm ci
247+
# - name: Download Build Artifacts
248+
# uses: actions/download-artifact@v4
249+
# with:
250+
# name: compile-cache-${{ github.run_number }}
251+
# path: .nx
252+
# - name: Build
253+
# run: npm run compile
254+
# - name: Unit tests (Delta)
255+
# run: npm run test:browser:ci:affected
256+
# - name: Report Coverage
257+
# uses: codecov/codecov-action@v5
258+
# env:
259+
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
260+
# with:
261+
# verbose: true
243262

244263
test-coverage-report:
245264
runs-on: ubuntu-latest
@@ -290,4 +309,3 @@ jobs:
290309
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
291310
with:
292311
verbose: true
293-
dry_run: true

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
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:affected": "nx affected -t compile --base=origin/main --head=HEAD",
18+
"compile:ci:affected": "nx affected -t compile",
1919
"test": "nx run-many -t test",
20-
"test:ci:affected": "nx affected -t test --base=origin/main --head=HEAD",
20+
"test:ci:affected": "nx affected -t test",
2121
"test:browser": "nx run-many -t test:browser",
22-
"test:browser:ci:affected": "nx affected -t test:browser --base=origin/main --head=HEAD",
22+
"test:browser:ci:affected": "nx affected -t test:browser",
2323
"test-all-versions": "nx run-many --parallel=false -t test-all-versions",
24-
"test-all-versions:ci:affected": "nx affected --parallel=false -t test-all-versions --base=origin/main --head=HEAD",
25-
"test-merge-coverage:ci:affected": "nx affected -t test-merge-coverage --base=origin/main --head=HEAD",
24+
"test-all-versions:ci:affected": "nx affected --parallel=false -t test-all-versions",
25+
"test-merge-coverage:ci:affected": "nx affected -t test-merge-coverage",
2626
"test-services:start": "docker compose -f ./test/docker-compose.yaml up -d --wait",
2727
"test-services:stop": "docker compose -f ./test/docker-compose.yaml down",
2828
"test:with-services-env": "cross-env NODE_OPTIONS='-r dotenv/config' DOTENV_CONFIG_PATH=./test/test-services.env npm test",

0 commit comments

Comments
 (0)