Skip to content

ci: fix

ci: fix #347

Workflow file for this run

name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
- name: oxLint
run: pnpm dlx oxlint@latest
- name: Set node
uses: actions/setup-node@v4
with:
node-version: 18.x
cache: pnpm
- name: Setup
run: npm i -g @antfu/ni
- name: Install
run: nci
- name: Lint
run: nr lint
typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
- name: Set node
uses: actions/setup-node@v4
with:
node-version: 18.x
cache: pnpm
- name: Setup
run: npm i -g @antfu/ni
- name: Install
run: nci
- name: Typecheck
run: nr typecheck
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node: [16.x]
os: [ubuntu-latest]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
- name: Set node ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: pnpm
- name: Setup
run: npm i -g @antfu/ni
- name: Install
run: nci
- name: Build
run: nr build
- uses: actions/cache/save@v4
id: cache
with:
path: dist/outfile.cjs
key: ${{ github.sha }}-${{ hashFiles('pnpm-lock.yaml') }}
test:
needs: build
strategy:
matrix:
flag-for-ts: ['', --ts]
flag-for-eslint: ['', -e]
flag-for-plugin-import: ['', -p import]
flag-for-module-pinia: ['', -m pinia]
flag-for-ui-uni: ['', -u uni]
include:
- node-version: 18
os: ubuntu-latest
flag-for-ts: --ts
flag-for-eslint: -e
flag-for-plugin-import: -p import
flag-for-plugin-pages: -p pages
flag-for-plugin-layouts: -p layouts
flag-for-plugin-manifest: -p manifest
flag-for-plugin-filePlatform: -p filePlatform
flag-for-plugin-platformModifier: -p platformModifier
flag-for-plugin-middleware: -p middleware
flag-for-module-pinia: -m pinia
flag-for-module-unocss: -m unocss
flag-for-module-uniNetwork: -m uniNetwork
flag-for-module-uniUse: -m uniUse
flag-for-module-uniPromises: -m uniPromises
flag-for-ui-uni: -u uni
- node-version: 18
os: ubuntu-latest
flag-for-template: -t vitesse
runs-on: ubuntu-latest
env:
FEATURE_FLAGS: ${{ matrix.flag-for-ts }} ${{ matrix.flag-for-eslint }} ${{ matrix.flag-for-plugin-import }} ${{ matrix.flag-for-plugin-pages }} ${{ matrix.flag-for-plugin-layouts }} ${{ matrix.flag-for-plugin-manifest }} ${{ matrix.flag-for-plugin-filePlatform }} ${{ matrix.flag-for-plugin-platformModifier }} ${{ matrix.flag-for-plugin-middleware }} ${{ matrix.flag-for-module-pinia }} ${{ matrix.flag-for-module-unocss }} ${{ matrix.flag-for-module-uniNetwork }} ${{ matrix.flag-for-module-uniUse }} ${{ matrix.flag-for-module-uniPromises }} ${{ matrix.flag-for-ui-uni }} ${{ matrix.flag-for-ui-ano }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: 18
cache: pnpm
- uses: actions/cache/save@v4
id: cache-restore
with:
path: dist/outfile.cjs
key: ${{ github.sha }}-${{ hashFiles('pnpm-lock.yaml') }}
- name: 当没有缓存时,执行构建
if: steps.cache-restore.outputs.cache-hit != 'true'
run: pnpm install && pnpm build
- if: ${{ (contains(env.FEATURE_FLAGS, '-')) }}
name: 创建多参数项目
working-directory: ../
run: node ./create-uni/dist/outfile.cjs sample-project ${{ env.FEATURE_FLAGS }}
- if: ${{ !(contains(env.FEATURE_FLAGS, '-')) }}
name: 创建基础项目
working-directory: ../
run: node ./create-uni/dist/outfile.cjs sample-project
- name: 安装项目依赖
working-directory: ../sample-project
run: pnpm install
- name: 打包项目
working-directory: ../sample-project
run: pnpm build