Skip to content

Commit aebadac

Browse files
committed
chore: use script in the pipeline
1 parent 602ea54 commit aebadac

File tree

2 files changed

+62
-59
lines changed

2 files changed

+62
-59
lines changed

.github/workflows/lint.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 62 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,64 @@ concurrency:
1919
cancel-in-progress: true
2020

2121
jobs:
22+
detect-modules:
23+
runs-on: ubuntu-latest
24+
outputs:
25+
modules: ${{ steps.set-modified-modules.outputs.modules }}
26+
modules_count: ${{ steps.set-modified-modules-count.outputs.modules_count }}
27+
steps:
28+
- name: Check out code
29+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
30+
31+
- id: changed-files
32+
name: Get changed files
33+
uses: tj-actions/changed-files@4edd678ac3f81e2dc578756871e4d00c19191daf # v45.0.4
34+
35+
- id: set-modified-modules
36+
name: Set all modified modules
37+
env:
38+
ALL_CHANGED_FILES: "${{ steps.changed-files.outputs.all_changed_files }}"
39+
run: echo "modules=$(./.github/scripts/changed-modules.sh)" >> $GITHUB_OUTPUT
40+
41+
- id: set-modified-modules-count
42+
name: Set all modified modules count
43+
run: echo "modules_count=$(echo ${{ toJSON(steps.set-modified-modules.outputs.modules) }} | jq '. | length')" >> $GITHUB_OUTPUT
44+
45+
- name: Print out the modules to be used
46+
run: |
47+
echo "${{ steps.set-modified-modules-count.outputs.modules_count }} modules in the build"
48+
echo "${{ steps.set-modified-modules.outputs.modules }}"
49+
50+
lint:
51+
# only run if there are modules to lint
52+
if: ${{ needs.detect-modules.outputs.modules_count > 0 }}
53+
needs:
54+
- detect-modules
55+
strategy:
56+
matrix:
57+
module: ${{ fromJSON(needs.detect-modules.outputs.modules) }}
58+
runs-on: ubuntu-22.04
59+
steps:
60+
- name: Code checkout
61+
uses: actions/checkout@v4
62+
- name: Install Node and Dependencies
63+
uses: ./.github/actions/npm-setup
64+
with:
65+
runner: ubuntu-22.04
66+
node-version: 22.x
67+
workspace: "packages/testcontainers"
68+
- name: Code linting
69+
run: npm run lint:ci -- ${{ matrix.module }}
70+
2271
smoke-test:
72+
# only run if there are modules to lint
73+
if: ${{ needs.detect-modules.outputs.modules_count > 0 }}
2374
name: Smoke test
24-
runs-on: ${{ matrix.runner }}
2575
strategy:
2676
matrix:
2777
runner: [ ubuntu-22.04 ]
2878
node-version: [ 18.x, 20.x, 22.x ]
79+
runs-on: ${{ matrix.runner }}
2980
steps:
3081
- name: Code checkout
3182
uses: actions/checkout@v4
@@ -47,51 +98,27 @@ jobs:
4798
- name: Run ES module smoke test
4899
run: node packages/testcontainers/smoke-test.mjs
49100

50-
test-testcontainers:
51-
name: Testcontainers
52-
needs: smoke-test
53-
strategy:
54-
matrix:
55-
node-version: [ 18.x, 20.x, 22.x ]
56-
container-runtime: [ docker, podman ]
57-
include:
58-
- container-runtime: docker
59-
runner: ubuntu-22.04
60-
- container-runtime: podman
61-
runner: ubuntu-22.04
62-
uses: ./.github/workflows/test-template.yml
63-
with:
64-
runner: ${{ matrix.runner }}
65-
node-version: ${{ matrix.node-version }}
66-
container-runtime: ${{ matrix.container-runtime }}
67-
workspace: packages/testcontainers
68-
69-
list-modules:
70-
name: List modules
71-
runs-on: ubuntu-22.04
72-
needs: test-testcontainers
73-
outputs:
74-
modules: ${{ steps.list_modules.outputs.modules }}
75-
steps:
76-
- uses: actions/checkout@v2
77-
- id: list_modules
78-
run: echo "modules=$(ls packages/modules | jq -cnR '[inputs | select(length>0) | select(. != "couchbase")]')" >> $GITHUB_OUTPUT
79-
test-modules:
80-
name: Module (${{ matrix.module }})
81-
needs: [ test-testcontainers, list-modules ]
101+
test:
102+
name: Run tests
103+
# only run if there are modules to test
104+
if: ${{ needs.detect-modules.outputs.modules_count > 0 }}
105+
needs:
106+
- detect-modules
107+
- lint
108+
- smoke-test
82109
strategy:
83110
matrix:
111+
module: ${{ fromJSON(needs.detect-modules.outputs.modules) }}
84112
node-version: [ 18.x, 20.x, 22.x ]
85113
container-runtime: [ docker, podman ]
86114
include:
87115
- container-runtime: docker
88116
runner: ubuntu-22.04
89117
- container-runtime: podman
90118
runner: ubuntu-22.04
91-
module: ${{ fromJson(needs.list-modules.outputs.modules) }}
92119
uses: ./.github/workflows/test-template.yml
93120
with:
94121
runner: ${{ matrix.runner }}
95122
node-version: ${{ matrix.node-version }}
96123
container-runtime: ${{ matrix.container-runtime }}
97-
workspace: packages/modules/${{ matrix.module }}
124+
workspace: "${{ matrix.module }}"

0 commit comments

Comments
 (0)