mirror of
https://github.com/screenci/screenci.git
synced 2026-09-19 08:57:46 +08:00
180 lines
9.4 KiB
YAML
180 lines
9.4 KiB
YAML
name: ScreenCI CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
quality:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version-file: '.nvmrc'
|
|
cache: npm
|
|
cache-dependency-path: package-lock.json
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Check formatting
|
|
run: npm run format:check
|
|
|
|
- name: Run linting
|
|
run: npm run lint
|
|
|
|
- name: Run type checking
|
|
run: npm run type-check
|
|
|
|
- name: Run unit tests
|
|
run: npm run test:run
|
|
|
|
smoke-test:
|
|
name: Init + Test (${{ matrix.name }})
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- name: ubuntu / bash
|
|
os: ubuntu-latest
|
|
shell_name: bash
|
|
- name: macos / bash
|
|
os: macos-latest
|
|
shell_name: bash
|
|
- name: windows / powershell
|
|
os: windows-latest
|
|
shell_name: pwsh
|
|
- name: windows / cmd
|
|
os: windows-latest
|
|
shell_name: cmd
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v6
|
|
with:
|
|
# pnpm 11 uses syntax that Node.js 18 cannot parse. Keep smoke tests on
|
|
# the minimum supported pnpm release so the Node.js 18 baseline remains
|
|
# covered end to end.
|
|
version: 10.26.0
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
# Smoke tests stay on the minimum supported runtime so CLI init/test flows
|
|
# are continuously verified against the Node.js 18 baseline.
|
|
node-version: 18
|
|
cache: pnpm
|
|
cache-dependency-path: pnpm-lock.yaml
|
|
|
|
- name: Install package dependencies
|
|
env:
|
|
HUSKY: 0
|
|
npm_config_strict_dep_builds: false
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Install Yarn
|
|
shell: bash
|
|
run: |
|
|
corepack enable yarn
|
|
corepack prepare yarn@stable --activate
|
|
# bash -lc (used by ci-run-in-shell.js) rebuilds PATH from profile files,
|
|
# which can put pre-installed yarn 1.x before the corepack shim. Prepend
|
|
# the Node.js bin dir so login shells always find the corepack yarn first.
|
|
printf 'export PATH="%s:$PATH"\n' "$(dirname "$(which node)")" >> ~/.bash_profile
|
|
|
|
- name: Build package
|
|
run: pnpm run build
|
|
|
|
- name: Pack local screenci package
|
|
run: npm pack
|
|
|
|
- name: Set local screenci dependency for init
|
|
run: node -e "const fs=require('node:fs'); const path=require('node:path'); const pkg=require('./package.json'); const tarballPath=path.resolve(process.cwd(), pkg.name + '-' + pkg.version + '.tgz'); fs.appendFileSync(process.env.GITHUB_ENV, 'SCREENCI_INIT_SCREENCI_DEPENDENCY=file:' + tarballPath + '\n')"
|
|
|
|
- name: Pack local create-screenci package
|
|
working-directory: create-screenci
|
|
env:
|
|
SCREENCI_INIT_SCREENCI_DEPENDENCY: ${{ env.SCREENCI_INIT_SCREENCI_DEPENDENCY }}
|
|
run: >-
|
|
node -e "const fs=require('node:fs'); const pkg=require('./package.json'); pkg.dependencies = { ...pkg.dependencies, screenci: process.env.SCREENCI_INIT_SCREENCI_DEPENDENCY }; fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2) + '\n')" && npm pack
|
|
|
|
- name: Set smoke project directories
|
|
run: >-
|
|
node -e "const fs=require('node:fs'); const path=require('node:path'); const base=path.join(process.env.RUNNER_TEMP, 'screenci-smoke'); const entries={SMOKE_DIRECT_NPM:path.join(base,'smoke-direct-npm'),SMOKE_DIRECT_PNPM:path.join(base,'smoke-direct-pnpm'),SMOKE_CREATE_NPM:path.join(base,'smoke-create-npm'),SMOKE_CREATE_PNPM:path.join(base,'smoke-create-pnpm'),SMOKE_DIRECT_YARN:path.join(base,'smoke-direct-yarn'),SMOKE_PNPM_WORKSPACE:path.join(base,'smoke-pnpm-workspace')}; fs.appendFileSync(process.env.GITHUB_ENV, Object.entries(entries).map(([key, value]) => key + '=' + value).join('\n') + '\n')"
|
|
|
|
- name: Prepare smoke projects
|
|
run: >-
|
|
node -e "const fs=require('node:fs'); const path=require('node:path'); const screenciPkg=require('./package.json'); const createPkg=require('./create-screenci/package.json'); const screenciTarball=screenciPkg.name + '-' + screenciPkg.version + '.tgz'; const createTarball=createPkg.name + '-' + createPkg.version + '.tgz'; for (const dir of [process.env.SMOKE_DIRECT_NPM, process.env.SMOKE_DIRECT_PNPM, process.env.SMOKE_CREATE_NPM, process.env.SMOKE_CREATE_PNPM, process.env.SMOKE_DIRECT_YARN, process.env.SMOKE_PNPM_WORKSPACE]) { fs.mkdirSync(dir, { recursive: true }); fs.copyFileSync(path.join(process.cwd(), screenciTarball), path.join(dir, screenciTarball)); fs.copyFileSync(path.join(process.cwd(), 'create-screenci', createTarball), path.join(dir, createTarball)); }"
|
|
|
|
- name: Set local create-screenci dependency for smoke tests
|
|
run: node -e "const fs=require('node:fs'); const path=require('node:path'); const pkg=require('./create-screenci/package.json'); const tarballPath=path.resolve(process.cwd(), 'create-screenci', pkg.name + '-' + pkg.version + '.tgz'); fs.appendFileSync(process.env.GITHUB_ENV, 'CREATE_SCREENCI_DEPENDENCY=file:' + tarballPath + '\n')"
|
|
|
|
- name: Run screenci init with npm
|
|
working-directory: ${{ env.SMOKE_DIRECT_NPM }}
|
|
run: node ${{ github.workspace }}/scripts/ci-run-in-shell.js ${{ matrix.shell_name }} node ${{ github.workspace }}/bin/screenci.js init smoke-project --package-manager npm --yes --verbose
|
|
|
|
- name: Run screenci test with npm
|
|
working-directory: ${{ env.SMOKE_DIRECT_NPM }}
|
|
run: node ${{ github.workspace }}/scripts/ci-run-in-shell.js ${{ matrix.shell_name }} npx screenci test
|
|
|
|
- name: Run screenci init with pnpm
|
|
working-directory: ${{ env.SMOKE_DIRECT_PNPM }}
|
|
run: node ${{ github.workspace }}/scripts/ci-run-in-shell.js ${{ matrix.shell_name }} node ${{ github.workspace }}/bin/screenci.js init smoke-project --package-manager pnpm --yes --verbose
|
|
|
|
- name: Run screenci test with pnpm
|
|
working-directory: ${{ env.SMOKE_DIRECT_PNPM }}
|
|
run: node ${{ github.workspace }}/scripts/ci-run-in-shell.js ${{ matrix.shell_name }} pnpm exec screenci test
|
|
|
|
- name: Run create-screenci with npm
|
|
working-directory: ${{ env.SMOKE_CREATE_NPM }}
|
|
run: node ${{ github.workspace }}/scripts/ci-run-in-shell.js ${{ matrix.shell_name }} npm exec --yes --package=${{ env.CREATE_SCREENCI_DEPENDENCY }} --package=${{ env.SCREENCI_INIT_SCREENCI_DEPENDENCY }} -- create-screenci smoke-project --package-manager npm --yes --verbose
|
|
|
|
- name: Run generated screenci test with npm
|
|
working-directory: ${{ env.SMOKE_CREATE_NPM }}
|
|
run: node ${{ github.workspace }}/scripts/ci-run-in-shell.js ${{ matrix.shell_name }} npx screenci test
|
|
|
|
- name: Run create-screenci with pnpm
|
|
working-directory: ${{ env.SMOKE_CREATE_PNPM }}
|
|
run: node ${{ github.workspace }}/scripts/ci-run-in-shell.js ${{ matrix.shell_name }} pnpm dlx --package=${{ env.CREATE_SCREENCI_DEPENDENCY }} --package=${{ env.SCREENCI_INIT_SCREENCI_DEPENDENCY }} create-screenci smoke-project --package-manager pnpm --yes --verbose
|
|
|
|
- name: Run generated screenci test with pnpm
|
|
working-directory: ${{ env.SMOKE_CREATE_PNPM }}
|
|
run: node ${{ github.workspace }}/scripts/ci-run-in-shell.js ${{ matrix.shell_name }} pnpm exec screenci test
|
|
|
|
- name: Run screenci init with yarn
|
|
working-directory: ${{ env.SMOKE_DIRECT_YARN }}
|
|
run: node ${{ github.workspace }}/scripts/ci-run-in-shell.js ${{ matrix.shell_name }} node ${{ github.workspace }}/bin/screenci.js init smoke-project --package-manager yarn --yes --verbose
|
|
|
|
- name: Run screenci test with yarn
|
|
working-directory: ${{ env.SMOKE_DIRECT_YARN }}
|
|
run: node ${{ github.workspace }}/scripts/ci-run-in-shell.js ${{ matrix.shell_name }} yarn screenci test
|
|
|
|
- name: Create pnpm workspace scaffold
|
|
env:
|
|
npm_config_strict_dep_builds: false
|
|
run: >-
|
|
node -e "const fs=require('node:fs'); const path=require('node:path'); const {spawnSync}=require('node:child_process'); const dir=process.env.SMOKE_PNPM_WORKSPACE; fs.writeFileSync(path.join(dir,'pnpm-workspace.yaml'),'packages:\n - packages/*\n'); fs.writeFileSync(path.join(dir,'package.json'),JSON.stringify({name:'smoke-workspace',private:true,version:'0.0.1'})+'\n'); const r=spawnSync('pnpm',['install'],{cwd:dir,stdio:'inherit',shell:true,env:{...process.env,npm_config_strict_dep_builds:'false'}}); if(r.status!==0) process.exit(r.status??1)"
|
|
|
|
- name: Run screenci init in pnpm workspace
|
|
working-directory: ${{ env.SMOKE_PNPM_WORKSPACE }}
|
|
env:
|
|
# Clear the user agent so PM detection falls through to lockfile sniffing.
|
|
npm_config_user_agent: ''
|
|
npm_config_strict_dep_builds: false
|
|
run: node ${{ github.workspace }}/scripts/ci-run-in-shell.js ${{ matrix.shell_name }} node ${{ github.workspace }}/bin/screenci.js init smoke-project --yes --verbose
|
|
|
|
- name: Run screenci test in pnpm workspace
|
|
working-directory: ${{ env.SMOKE_PNPM_WORKSPACE }}
|
|
run: node ${{ github.workspace }}/scripts/ci-run-in-shell.js ${{ matrix.shell_name }} pnpm exec screenci test
|