Skip to content

Commit fd066f4

Browse files
authored
♻️ Run bin for pipeline tests (#34)
Installs the packed `css-typed` package from CI Build into a sandbox for the pipeline tests and switches to using `npx css-typed`. This uses the actual `bin` entry point instead of emulating it with `node dist/main.js`. In addition to matching the real world use case better, this ensures that we do not break the bin configuration again. (It broke in the 0.5.0 release.)
1 parent c9aa453 commit fd066f4

File tree

2 files changed

+32
-19
lines changed

2 files changed

+32
-19
lines changed

.github/workflows/pipeline.yaml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
Publish:
1515
name: Publish
1616
needs:
17-
- CiBuild # For version variable
17+
- CiBuild
1818
- PipelineTests # Requires passing tests
1919

2020
uses: connorjs/github-workflows/.github/workflows/npm-publish~v1.yaml@main
@@ -30,10 +30,14 @@ jobs:
3030

3131
PipelineTests:
3232
name: Test (${{ matrix.node }} | ${{ matrix.platform.os }})
33+
needs:
34+
- CiBuild
35+
36+
runs-on: ${{ matrix.platform.os }}-latest
3337
defaults:
3438
run:
3539
shell: bash
36-
runs-on: ${{ matrix.platform.os }}-latest
40+
3741
strategy:
3842
matrix:
3943
node:
@@ -49,17 +53,21 @@ jobs:
4953
- name: Checkout
5054
uses: actions/checkout@v4
5155

56+
- uses: actions/download-artifact@v4
57+
with:
58+
name: ${{ needs.CiBuild.outputs.npmPackFilename }}
59+
5260
- name: Use Node.js ${{ matrix.node }}
5361
uses: actions/setup-node@v4
5462
with:
5563
cache: npm
5664
node-version: ${{ matrix.node }}
5765

58-
- name: Install
59-
run: npm install
60-
61-
- name: Build
62-
run: npm run build
66+
- name: Install css-typed
67+
run: |
68+
mkdir -p sandbox
69+
cd sandbox
70+
npm install ../${{ needs.CiBuild.outputs.npmPackFilename }}
6371
6472
- name: "Test 1: default case"
6573
run: |
@@ -83,7 +91,7 @@ jobs:
8391
- name: "Test 5: absolute outdir"
8492
if: success() || failure()
8593
run: |
86-
scripts/test.sh foo "" "-o $GITHUB_WORKSPACE/generated *.css" "" "$GITHUB_WORKSPACE"/generated/
94+
scripts/test.sh foo "" "-o $RUNNER_TEMP/generated *.css" "" "$RUNNER_TEMP"/generated/
8795
# Note: This test uses double quotes, which expands differently.
8896

8997
- name: "Test 6: json file config"

scripts/test.sh

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,28 @@ output=${4:-$1}
1717
# $5 is the path prefix for output. Defaults to "".
1818
prefix=${5:-}
1919

20-
# Run from $RUNNER_TEMP for auto-cleanup.
21-
cp fixtures/${input}.css $RUNNER_TEMP/test.css
22-
cp fixtures/${output}.d.css.ts $RUNNER_TEMP/expected.d.css.ts
20+
# `sandbox` is where we installed css-typed.
21+
# Create fresh tmp directory under it each time (under for npx usage).
22+
TEST_DIR=sandbox/tmp
23+
rm -rf $TEST_DIR
24+
mkdir -p $TEST_DIR
25+
26+
cp fixtures/${input}.css $TEST_DIR/test.css
27+
cp fixtures/${output}.d.css.ts $TEST_DIR/expected.d.css.ts
2328

24-
rm -rf "${RUNNER_TEMP:?}/.config"
2529
if [ -f fixtures/config/${config} ]; then
26-
mkdir -p $RUNNER_TEMP/.config
27-
cp fixtures/config/${config} $RUNNER_TEMP/.config/${config}
30+
mkdir -p $TEST_DIR/.config
31+
cp fixtures/config/${config} $TEST_DIR/.config/${config}
2832
fi
2933

30-
pushd $RUNNER_TEMP > /dev/null || exit
34+
pushd $TEST_DIR > /dev/null || exit
35+
36+
set -x # Print the css-typed command exactly as executed
3137

32-
# `./dist/main.js` is executing local `css-typed` as if installed (same as `bin`).
33-
# But it is `$GITHUB_WORKSPACE/dist/main.js` b/c we `cd $RUNNER_TEMP`.
34-
echo "css-typed " "${options[@]}"
3538
# shellcheck disable=SC2068
36-
$GITHUB_WORKSPACE/dist/main.js ${options[@]}
39+
npx css-typed ${options[@]}
40+
41+
{ set +x; } 2>/dev/null # Turn off command printing, and do not print set +X
3742

3843
# Use `diff` to compare the files.
3944
# Use `-I '//.*'` to ignore the first line (comment) which has generated path and timestamp.

0 commit comments

Comments
 (0)