diff --git a/.github/workflows/pipeline.yaml b/.github/workflows/pipeline.yaml index 2fe9c4b..7d64e51 100644 --- a/.github/workflows/pipeline.yaml +++ b/.github/workflows/pipeline.yaml @@ -14,7 +14,7 @@ jobs: Publish: name: Publish needs: - - CiBuild # For version variable + - CiBuild - PipelineTests # Requires passing tests uses: connorjs/github-workflows/.github/workflows/npm-publish~v1.yaml@main @@ -30,10 +30,14 @@ jobs: PipelineTests: name: Test (${{ matrix.node }} | ${{ matrix.platform.os }}) + needs: + - CiBuild + + runs-on: ${{ matrix.platform.os }}-latest defaults: run: shell: bash - runs-on: ${{ matrix.platform.os }}-latest + strategy: matrix: node: @@ -49,17 +53,21 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: + name: ${{ needs.CiBuild.outputs.npmPackFilename }} + - name: Use Node.js ${{ matrix.node }} uses: actions/setup-node@v4 with: cache: npm node-version: ${{ matrix.node }} - - name: Install - run: npm install - - - name: Build - run: npm run build + - name: Install css-typed + run: | + mkdir -p sandbox + cd sandbox + npm install ../${{ needs.CiBuild.outputs.npmPackFilename }} - name: "Test 1: default case" run: | @@ -83,7 +91,7 @@ jobs: - name: "Test 5: absolute outdir" if: success() || failure() run: | - scripts/test.sh foo "" "-o $GITHUB_WORKSPACE/generated *.css" "" "$GITHUB_WORKSPACE"/generated/ + scripts/test.sh foo "" "-o $RUNNER_TEMP/generated *.css" "" "$RUNNER_TEMP"/generated/ # Note: This test uses double quotes, which expands differently. - name: "Test 6: json file config" diff --git a/scripts/test.sh b/scripts/test.sh index 4f2f526..0d21581 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -17,23 +17,28 @@ output=${4:-$1} # $5 is the path prefix for output. Defaults to "". prefix=${5:-} -# Run from $RUNNER_TEMP for auto-cleanup. -cp fixtures/${input}.css $RUNNER_TEMP/test.css -cp fixtures/${output}.d.css.ts $RUNNER_TEMP/expected.d.css.ts +# `sandbox` is where we installed css-typed. +# Create fresh tmp directory under it each time (under for npx usage). +TEST_DIR=sandbox/tmp +rm -rf $TEST_DIR +mkdir -p $TEST_DIR + +cp fixtures/${input}.css $TEST_DIR/test.css +cp fixtures/${output}.d.css.ts $TEST_DIR/expected.d.css.ts -rm -rf "${RUNNER_TEMP:?}/.config" if [ -f fixtures/config/${config} ]; then - mkdir -p $RUNNER_TEMP/.config - cp fixtures/config/${config} $RUNNER_TEMP/.config/${config} + mkdir -p $TEST_DIR/.config + cp fixtures/config/${config} $TEST_DIR/.config/${config} fi -pushd $RUNNER_TEMP > /dev/null || exit +pushd $TEST_DIR > /dev/null || exit + +set -x # Print the css-typed command exactly as executed -# `./dist/main.js` is executing local `css-typed` as if installed (same as `bin`). -# But it is `$GITHUB_WORKSPACE/dist/main.js` b/c we `cd $RUNNER_TEMP`. -echo "css-typed " "${options[@]}" # shellcheck disable=SC2068 -$GITHUB_WORKSPACE/dist/main.js ${options[@]} +npx css-typed ${options[@]} + +{ set +x; } 2>/dev/null # Turn off command printing, and do not print set +X # Use `diff` to compare the files. # Use `-I '//.*'` to ignore the first line (comment) which has generated path and timestamp.