feat: add sfw input to wrap vp install with Socket Firewall Free #249
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| merge_group: | |
| jobs: | |
| test: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| version: [latest, alpha] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2 | |
| - name: Setup Vite+ (${{ matrix.version }}) | |
| uses: ./ | |
| with: | |
| version: ${{ matrix.version }} | |
| run-install: false | |
| cache: false | |
| - name: Verify installation | |
| run: vp --version | |
| test-node-version: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| node-version: ["lts", "22", "24"] | |
| version: [latest, alpha] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2 | |
| - name: Setup Vite+ (${{ matrix.version }}) with Node.js ${{ matrix.node-version }} | |
| uses: ./ | |
| with: | |
| version: ${{ matrix.version }} | |
| node-version: ${{ matrix.node-version }} | |
| run-install: false | |
| cache: false | |
| - name: Verify installation | |
| run: vp --version | |
| - name: Verify Node.js version | |
| shell: bash | |
| run: | | |
| ACTUAL=$(node --version) | |
| echo "Node.js version: $ACTUAL" | |
| if [ "${{ matrix.node-version }}" != "lts" ]; then | |
| echo "$ACTUAL" | grep -q "^v${{ matrix.node-version }}\." || (echo "Expected Node.js v${{ matrix.node-version }}.x but got $ACTUAL" && exit 1) | |
| fi | |
| test-cache-pnpm: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| version: [latest, alpha] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2 | |
| - name: Create test project with pnpm-lock.yaml | |
| run: | | |
| mkdir -p test-project | |
| cd test-project | |
| echo '{"name":"test-project","private":true}' > package.json | |
| touch pnpm-lock.yaml | |
| - name: Setup Vite+ (${{ matrix.version }}) with pnpm cache | |
| uses: ./ | |
| id: setup | |
| with: | |
| version: ${{ matrix.version }} | |
| run-install: false | |
| cache: true | |
| cache-dependency-path: test-project/pnpm-lock.yaml | |
| - name: Verify installation | |
| run: | | |
| vp --version | |
| echo "Installed version: ${{ steps.setup.outputs.version }}" | |
| echo "Cache hit: ${{ steps.setup.outputs.cache-hit }}" | |
| test-cache-npm: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| version: [latest, alpha] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2 | |
| - name: Create test project with package-lock.json | |
| run: | | |
| mkdir -p test-project | |
| cd test-project | |
| echo '{"name":"test-project","private":true}' > package.json | |
| echo '{"name":"test-project","lockfileVersion":3}' > package-lock.json | |
| - name: Setup Vite+ (${{ matrix.version }}) with npm cache | |
| uses: ./ | |
| id: setup | |
| with: | |
| version: ${{ matrix.version }} | |
| run-install: false | |
| cache: true | |
| cache-dependency-path: test-project/package-lock.json | |
| - name: Verify installation | |
| run: | | |
| vp --version | |
| echo "Installed version: ${{ steps.setup.outputs.version }}" | |
| echo "Cache hit: ${{ steps.setup.outputs.cache-hit }}" | |
| test-cache-yarn: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| version: [latest, alpha] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2 | |
| - name: Create test project with yarn.lock | |
| run: | | |
| mkdir -p test-project | |
| cd test-project | |
| echo '{"name":"test-project","private":true}' > package.json | |
| touch yarn.lock | |
| - name: Setup Vite+ (${{ matrix.version }}) with yarn cache | |
| uses: ./ | |
| id: setup | |
| with: | |
| version: ${{ matrix.version }} | |
| run-install: false | |
| cache: true | |
| cache-dependency-path: test-project/yarn.lock | |
| - name: Verify installation | |
| run: | | |
| vp --version | |
| echo "Installed version: ${{ steps.setup.outputs.version }}" | |
| echo "Cache hit: ${{ steps.setup.outputs.cache-hit }}" | |
| test-cache-bun: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| version: [latest, alpha] | |
| lockfile: [bun.lock, bun.lockb] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2 | |
| - name: Create test project with ${{ matrix.lockfile }} | |
| run: | | |
| mkdir -p test-project | |
| cd test-project | |
| echo '{"name":"test-project","private":true}' > package.json | |
| touch ${{ matrix.lockfile }} | |
| - name: Setup Vite+ (${{ matrix.version }}) with bun cache (${{ matrix.lockfile }}) | |
| uses: ./ | |
| id: setup | |
| with: | |
| version: ${{ matrix.version }} | |
| run-install: false | |
| cache: true | |
| cache-dependency-path: test-project/${{ matrix.lockfile }} | |
| - name: Verify installation | |
| run: | | |
| vp --version | |
| echo "Installed version: ${{ steps.setup.outputs.version }}" | |
| echo "Cache hit: ${{ steps.setup.outputs.cache-hit }}" | |
| test-vp-exec: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| version: [latest, alpha] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2 | |
| - name: Setup Vite+ (${{ matrix.version }}) | |
| uses: ./ | |
| with: | |
| version: ${{ matrix.version }} | |
| run-install: false | |
| cache: false | |
| - name: Verify vp exec works | |
| run: vp exec node -e "console.log('vp exec works')" | |
| test-vp-install-and-exec: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| version: [latest, alpha] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2 | |
| - name: Create test project | |
| shell: bash | |
| run: | | |
| mkdir -p test-project | |
| cd test-project | |
| echo '{"name":"test-project","private":true,"scripts":{"hello":"node -e \"console.log(1+1)\""}}' > package.json | |
| - name: Setup Vite+ (${{ matrix.version }}) with install | |
| uses: ./ | |
| with: | |
| version: ${{ matrix.version }} | |
| run-install: | | |
| - cwd: test-project | |
| cache: false | |
| - name: Verify vp exec in project | |
| working-directory: test-project | |
| run: vp exec node -e "console.log('vp exec in project works')" | |
| - name: Verify vp run in project | |
| working-directory: test-project | |
| run: vp run hello | |
| test-registry-url: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| version: [latest, alpha] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2 | |
| - name: Setup Vite+ (${{ matrix.version }}) with registry-url | |
| uses: ./ | |
| with: | |
| version: ${{ matrix.version }} | |
| run-install: false | |
| cache: false | |
| registry-url: "https://npm.pkg.github.com" | |
| scope: "@voidzero-dev" | |
| - name: Verify .npmrc was created | |
| run: | | |
| echo "NPM_CONFIG_USERCONFIG=$NPM_CONFIG_USERCONFIG" | |
| cat "$NPM_CONFIG_USERCONFIG" | |
| grep -q "@voidzero-dev:registry=https://npm.pkg.github.com/" "$NPM_CONFIG_USERCONFIG" | |
| grep -q "_authToken=\${NODE_AUTH_TOKEN}" "$NPM_CONFIG_USERCONFIG" | |
| - name: Verify NODE_AUTH_TOKEN is exported | |
| run: | | |
| echo "NODE_AUTH_TOKEN is set: ${NODE_AUTH_TOKEN:+yes}" | |
| test-alpine-container: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| version: [latest, alpha] | |
| runs-on: ubuntu-latest | |
| container: | |
| image: alpine:3.23 | |
| steps: | |
| - name: Install Alpine dependencies | |
| run: apk add --no-cache bash curl gcompat libstdc++ | |
| - uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2 | |
| - name: Setup Vite+ (${{ matrix.version }}) | |
| uses: ./ | |
| with: | |
| version: ${{ matrix.version }} | |
| run-install: false | |
| cache: false | |
| - name: Verify installation | |
| run: vp --version | |
| - name: Verify vp exec works | |
| run: vp exec node -e "console.log('vp exec works in Alpine')" | |
| test-sfw: | |
| # On Linux: sfw wraps vp install end-to-end (sfw binary downloaded, | |
| # `sfw vp install` runs). | |
| # On macOS / Windows: sfw is temporarily unsupported because sfw v1.10.0 | |
| # issues a TLS cert with an empty EKU extension that vp's rustls rejects | |
| # (UnknownIssuer). The action emits a warning and falls back to plain | |
| # `vp install`; no sfw binary is downloaded. We assert that fallback by | |
| # checking `sfw` is NOT on PATH while the install still succeeds. | |
| # Tracking: https://github.com/voidzero-dev/setup-vp/issues/73 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| version: [latest, alpha] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2 | |
| - name: Create test project with a real dependency | |
| shell: bash | |
| run: | | |
| mkdir -p test-project | |
| cd test-project | |
| echo '{"name":"test-project","private":true,"dependencies":{"is-odd":"^3.0.1"}}' > package.json | |
| - name: Setup Vite+ (${{ matrix.version }}) with sfw | |
| uses: ./ | |
| with: | |
| version: ${{ matrix.version }} | |
| sfw: true | |
| run-install: | | |
| - cwd: test-project | |
| cache: false | |
| - name: Verify sfw is on PATH (Linux only) | |
| if: runner.os == 'Linux' | |
| run: sfw --version | |
| - name: Verify sfw fallback on non-Linux (sfw NOT installed) | |
| if: runner.os != 'Linux' | |
| shell: bash | |
| run: | | |
| if command -v sfw >/dev/null 2>&1; then | |
| echo "ERROR: expected sfw to be absent on ${{ runner.os }} (fallback path), but it is on PATH" | |
| exit 1 | |
| fi | |
| echo "OK: sfw is not on PATH; fallback to plain vp install confirmed" | |
| - name: Verify dependency installed | |
| working-directory: test-project | |
| run: vp exec node -e "console.log(require('is-odd')(3))" | |
| test-sfw-alpine: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| version: [latest, alpha] | |
| runs-on: ubuntu-latest | |
| container: | |
| image: alpine:3.23 | |
| steps: | |
| - name: Install Alpine dependencies | |
| run: apk add --no-cache bash curl gcompat libstdc++ | |
| - uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2 | |
| - name: Create test project with a real dependency | |
| run: | | |
| mkdir -p test-project | |
| cd test-project | |
| echo '{"name":"test-project","private":true,"dependencies":{"is-odd":"^3.0.1"}}' > package.json | |
| - name: Setup Vite+ (${{ matrix.version }}) with sfw (musl) | |
| uses: ./ | |
| with: | |
| version: ${{ matrix.version }} | |
| sfw: true | |
| run-install: | | |
| - cwd: test-project | |
| cache: false | |
| - name: Verify sfw is on PATH (musl) | |
| run: sfw --version | |
| - name: Verify dependency installed under sfw (musl) | |
| working-directory: test-project | |
| run: vp exec node -e "console.log(require('is-odd')(3))" | |
| test-sfw-blocks-malicious: | |
| # Verifies sfw actually intercepts a known-malicious package, not just | |
| # that it wraps the install. Uses `lodahs` (lodash typosquat), the same | |
| # canary SocketDev's own workflows use: | |
| # https://github.com/SocketDev/bun-security-scanner/blob/main/.github/workflows/test.yml | |
| # If this job ever stops blocking, either sfw is misconfigured or the | |
| # canary itself has been delisted — swap it for another Socket-flagged | |
| # package from https://socket.dev/blog/category/threat-research. | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| version: [latest, alpha] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2 | |
| - name: Create test project with a benign dependency | |
| shell: bash | |
| run: | | |
| mkdir -p test-project | |
| cd test-project | |
| echo '{"name":"test-project","private":true,"dependencies":{"is-odd":"^3.0.1"}}' > package.json | |
| - name: Setup Vite+ (${{ matrix.version }}) with sfw and install benign dep | |
| uses: ./ | |
| with: | |
| version: ${{ matrix.version }} | |
| sfw: true | |
| run-install: | | |
| - cwd: test-project | |
| cache: false | |
| - name: Assert sfw blocks malicious package (lodahs typosquat of lodash) | |
| shell: bash | |
| working-directory: test-project | |
| run: | | |
| if sfw vp install lodahs; then | |
| echo "ERROR: sfw failed to block lodahs (lodash typosquat)" | |
| exit 1 | |
| else | |
| echo "SUCCESS: sfw blocked lodahs as expected" | |
| fi | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2 | |
| - name: Setup Vite+ with cache | |
| uses: ./ | |
| id: setup | |
| with: | |
| cache: true | |
| node-version-file: .node-version | |
| - name: Type check | |
| run: vp run typecheck | |
| - name: Check | |
| run: vp run check | |
| - name: Unit tests | |
| run: vp run test | |
| - name: Build | |
| run: vp run build | |
| - name: Verify dist is up to date | |
| run: | | |
| git diff --exit-code dist/ || (echo "dist/ is out of date. Run 'vp run build' and commit." && exit 1) |