diff --git a/.github/workflows/unit-test-vp.yml b/.github/workflows/unit-test-vp.yml new file mode 100644 index 0000000..061b014 --- /dev/null +++ b/.github/workflows/unit-test-vp.yml @@ -0,0 +1,94 @@ +name: Unit Test Vite Plus + +on: + workflow_call: + inputs: + primary-os: + required: false + type: string + default: ubuntu-latest + + os-matrix: + required: false + type: string + default: '"ubuntu-latest", "windows-latest"' + + node-versions: + required: false + type: string + default: '22,24,26' + + check: + required: false + type: string + default: vp check + + build: + required: false + type: string + default: vp run build + + test: + required: false + type: string + default: vp test + + skip-check: + required: false + type: boolean + default: false + + skip-test: + required: false + type: boolean + default: false + + build-for-check: + required: false + type: boolean + default: false + + persist-credentials: + required: false + type: boolean + default: false + +jobs: + check: + runs-on: ${{ inputs.primary-os }} + if: ${{ !inputs.skip-check }} + steps: + - name: Setup Vite Plus + uses: sxzz/workflows/setup-vp@main + with: + persist-credentials: ${{ inputs.persist-credentials }} + + - name: Build + run: ${{ inputs.build }} + if: ${{ inputs.build-for-check }} + + - name: Check + run: ${{ inputs.check }} + if: ${{ inputs.check != '' }} + + test: + strategy: + matrix: + os: ${{ fromJson(format('[{0}]', inputs.os-matrix)) }} + node-version: ${{ fromJson(format('[{0}]', inputs.node-versions)) }} + fail-fast: false + + if: ${{ !inputs.skip-test }} + runs-on: ${{ matrix.os }} + steps: + - name: Setup Vite Plus + uses: sxzz/workflows/setup-vp@main + with: + node-version: ${{ matrix.node-version }} + persist-credentials: ${{ inputs.persist-credentials }} + + - name: Build + run: ${{ inputs.build }} + + - name: Unit Test + run: ${{ inputs.test }} diff --git a/setup-vp/action.yml b/setup-vp/action.yml new file mode 100644 index 0000000..b732622 --- /dev/null +++ b/setup-vp/action.yml @@ -0,0 +1,43 @@ +name: Setup Vite Plus +description: Setup Vite Plus environment + +inputs: + persist-credentials: + description: Whether to configure the token or SSH key with the local git config + default: 'false' + + fetch-all: + description: Whether to fetch all history for all branches and tags. + default: 'false' + + node-version: + description: 'Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0.' + default: 'lts/*' + + auto-install: + description: Whether to automatically install dependencies. + default: 'true' + + cache: + description: Whether to enable caching for node modules. + default: 'true' + +runs: + using: composite + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: ${{ inputs.persist-credentials }} + fetch-depth: "${{ inputs.fetch-all == 'true' && '0' || '1' }}" + + - name: Setup Vite Plus + uses: voidzero-dev/setup-vp@ca1c46663915d6c1042ae23bd39ab85718bfb0fa # v1.10.0 + with: + node-version: ${{ inputs.node-version }} + cache: ${{ inputs.cache }} + + - name: Install dependencies + shell: bash + run: vp install + if: ${{ inputs.auto-install }}