Skip to content

Commit 06c6a18

Browse files
committed
ci: run only relevant test
Signed-off-by: Pritam Singh <pkspritam16@gmail.com>
1 parent 3ac7551 commit 06c6a18

1 file changed

Lines changed: 32 additions & 7 deletions

File tree

.github/workflows/build.yml

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,48 @@ jobs:
3333
- name: "Run npm build"
3434
run: npm run build
3535

36+
integration-tests-matrix-generator:
37+
name: Detect changes & generate matrix
38+
runs-on: ubuntu-latest
39+
outputs:
40+
matrix: ${{ steps.generate.outputs.matrix }}
41+
42+
steps:
43+
- uses: actions/checkout@v4
44+
45+
- id: filter
46+
uses: dorny/paths-filter@v3
47+
with:
48+
filters: |
49+
esm: 'esm/**'
50+
cjs: 'cjs/**'
51+
52+
- id: generate
53+
run: |
54+
MATRIX="[]"
55+
56+
if [ "${{ steps.filter.outputs.esm }}" = "true" ]; then
57+
MATRIX=$(jq '. + [{"name":"esm","test_directory":"esm"}]' <<< "$MATRIX")
58+
fi
59+
60+
if [ "${{ steps.filter.outputs.cjs }}" = "true" ]; then
61+
MATRIX=$(jq '. + [{"name":"cjs","test_directory":"cjs"}]' <<< "$MATRIX")
62+
fi
63+
64+
echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT"
65+
3666
integration-tests:
3767
name: Integration Tests (${{ matrix.name }})
3868
runs-on: ubuntu-latest
39-
needs: build
69+
needs: [build, integration-tests-matrix-generator]
4070

4171
env:
4272
ORACLE_TESTS: "DIDModule|DID Key Operations|OracleModule|ResourceModule"
4373

4474
strategy:
4575
fail-fast: false
4676
matrix:
47-
include:
48-
- name: esm
49-
test_directory: esm
50-
51-
- name: cjs
52-
test_directory: cjs
77+
include: ${{ fromJSON(needs.integration-tests-matrix-generator.outputs.matrix) }}
5378

5479
steps:
5580
- uses: actions/checkout@v5

0 commit comments

Comments
 (0)