Skip to content

Commit 6082f1d

Browse files
committed
ci: improve dep handling in the reusable test workflow
1 parent 44d212a commit 6082f1d

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

.github/workflows/test.reusable.yaml

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,12 @@ name: Test
33
on:
44
workflow_call:
55
inputs:
6-
jsr_dependencies:
7-
type: string
8-
npm_dependencies:
9-
type: string
106
deno_versions:
117
type: string
128
node_versions:
139
type: string
1410
bun_versions:
1511
type: string
16-
test_targets:
17-
type: string
18-
default: '**/*.test.ts'
1912

2013
jobs:
2114
test:
@@ -40,33 +33,38 @@ jobs:
4033
echo "Testing on Deno version $version"
4134
deno upgrade ${version}
4235
deno -v
43-
deno test -A ${{ inputs.test_targets }}
36+
deno test -A **/*.test.ts
4437
done
4538
39+
NPM_DEPS=$(jq -r '.imports | to_entries[] | select(.value | startswith("npm:")) | .value[4:]' deno.json)
40+
JSR_DEPS=$(jq -r '.imports | to_entries[] | select(.value | startswith("jsr:")) | .value' deno.json)
41+
42+
if [ -d "./dist" ]; then
43+
(cd dist && pnpm pack --out=pkg.tgz)
44+
NPM_DEPS="dist/pkg.tgz $NPM_DEPS"
45+
fi
46+
4647
for version in ${{ inputs.node_versions }}; do
4748
echo '{ "type": "module" }' >package.json
4849
echo "Testing on Node.js version $version"
4950
pnpm env use ${version}
5051
node -v
51-
if [ -n "${{ inputs.npm_dependencies }}" ]; then
52-
pnpm add ${{ inputs.npm_dependencies }}
53-
fi
54-
if [ -n "${{ inputs.jsr_dependencies }}" ]; then
55-
pnpm add $(sed 's/^/jsr:/' <<<"${{ inputs.jsr_dependencies }}")
52+
if [ -n "$NPM_DEPS" ] || [ -n "$JSR_DEPS" ]; then
53+
pnpm add $NPM_DEPS $JSR_DEPS
5654
fi
57-
pnpx tsx --test ${{ inputs.test_targets }}
55+
pnpx tsx --test **/*.test.ts
5856
done
5957
6058
for version in ${{ inputs.bun_versions }}; do
6159
echo '{ "type": "module" }' >package.json
6260
echo "Testing on Bun version $version"
6361
pnpm add --dangerously-allow-all-builds -g bun@${version}
6462
bun -v
65-
if [ -n "${{ inputs.npm_dependencies }}" ]; then
66-
bun add ${{ inputs.npm_dependencies }}
63+
if [ -n "$NPM_DEPS" ]; then
64+
bun add $NPM_DEPS
6765
fi
68-
if [ -n "${{ inputs.jsr_dependencies }}" ]; then
69-
bunx jsr add ${{ inputs.jsr_dependencies }}
66+
if [ -n "$JSR_DEPS" ]; then
67+
bunx jsr add $(echo $JSR_DEPS | sed 's/^jsr://')
7068
fi
71-
bun test ${{ inputs.test_targets }}
69+
bun test **/*.test.ts
7270
done

0 commit comments

Comments
 (0)