Skip to content

Commit

Permalink
test: improve
Browse files Browse the repository at this point in the history
deploy
  • Loading branch information
hemengke1997 committed Oct 26, 2023
1 parent 1a9c46a commit 2935021
Show file tree
Hide file tree
Showing 47 changed files with 1,776 additions and 844 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Github Pages Deploy

on:
push:
branches:
- master

concurrency:
group: pages
cancel-in-progress: true

jobs:
deploy:
if: "contains(github.event.head_commit.message, 'deploy')"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
persist-credentials: false

- name: Install pnpm
uses: pnpm/action-setup@v2.0.1
with:
version: 8.7.0

- name: Install Dependencies
run: |
pnpm install
- name: Build
run: |
pnpm run build:pages
- name: Deploy
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
ACCESS_TOKEN: ${{ secrets.GHB_TOKEN }}
BRANCH: gh-pages
FOLDER: playground/spa/dist
27 changes: 10 additions & 17 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,25 @@ on:
jobs:
publish-npm:
if: "contains(github.event.head_commit.message, 'release')"
runs-on: ${{matrix.os}}

strategy:
matrix:
os: [ubuntu-latest]
node-version: [16.x]
fail-fast: false
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2.0.1
- name: Setup Node
uses: actions/setup-node@v3
with:
version: 6.31.0
node-version: 18.x
registry-url: https://registry.npmjs.org/

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
- name: Install pnpm
uses: pnpm/action-setup@v2.0.1
with:
node-version: ${{ matrix.node-version }}
registry-url: https://registry.npmjs.org/
cache: pnpm
version: 8.7.0

- name: Install Dependencies
run: pnpm install
run: pnpm install --no-frozen-lockfile

- name: Build
run: pnpm run build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 18.x

- run: npx changelogithub
env:
GITHUB_TOKEN: ${{ secrets.OPER_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GHB_TOKEN }}
101 changes: 92 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
name: Test

env:
# 7 GiB by default on GitHub, setting to 6 GiB
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
NODE_OPTIONS: --max-old-space-size=6144
# install playwright binary manually (because pnpm only runs install script once)
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
# Vitest auto retry on flaky segfault
VITEST_SEGFAULT_RETRY: 3

concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
cancel-in-progress: true

on:
push:
branches:
Expand All @@ -11,20 +24,90 @@ on:

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 20
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node_version: [16, 18, 20]
include:
# Active LTS + other OS
- os: macos-latest
node_version: 18
- os: windows-latest
node_version: 18
fail-fast: true

name: 'Build&Test: node-${{ matrix.node_version }}, ${{ matrix.os }}'

steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8.6.2

- name: Setup Node
- name: Set node version to ${{ matrix.node_version }}
uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: ${{ matrix.node_version }}
cache: pnpm

- name: Install dependencies
run: npx pnpm install --no-frozen-lockfile
- name: Install deps
run: pnpm install

- name: Lint
run: npm run lint
# Install playwright's binary under custom directory to cache
- name: Set Playwright path (non-windows)
if: runner.os != 'Windows'
run: echo "PLAYWRIGHT_BROWSERS_PATH=$HOME/.cache/playwright-bin" >> $GITHUB_ENV
- name: Set Playwright path (windows)
if: runner.os == 'Windows'
run: echo "PLAYWRIGHT_BROWSERS_PATH=$HOME\.cache\playwright-bin" >> $env:GITHUB_ENV

- name: Cache Playwright's binary
uses: actions/cache@v3
with:
# Playwright removes unused browsers automatically
# So does not need to add playwright version to key
key: ${{ runner.os }}-playwright-bin-v1
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}

- name: Build
run: pnpm run build

- name: Test
run: npm run test
run: pnpm run test:unit

- name: Test serve
run: pnpm run test:serve

- name: Test build
run: pnpm run test:build

lint:
timeout-minutes: 10
runs-on: ubuntu-latest
name: 'Lint: node-LTS, ubuntu-latest'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8.6.2

- name: Set node version to LTS
uses: actions/setup-node@v3
with:
node-version: lts/*
cache: pnpm

- name: Install deps
run: pnpm install

- name: Lint
run: pnpm run lint
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
dist
.idea
.DS_Store
playground-temp
3 changes: 3 additions & 0 deletions commitlint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@minko-fe'],
}
3 changes: 1 addition & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)

const { defineConfig } = require('@minko-fe/eslint-config')
export default defineConfig([])
export default defineConfig()
21 changes: 0 additions & 21 deletions example/index.ts

This file was deleted.

38 changes: 0 additions & 38 deletions example/main-rem.css

This file was deleted.

44 changes: 0 additions & 44 deletions example/main.css

This file was deleted.

28 changes: 23 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@
}
},
"scripts": {
"dev": "tsup --watch",
"dev": "simple-git-hooks && tsup --watch",
"build": "tsup",
"test": "vitest",
"build:pages": "pnpm run build && cd playground/spa && pnpm run build",
"test": "run-s test:unit test:serve test:build",
"test:unit": "vitest run",
"test:serve": "vitest run -c vitest.config.e2e.ts",
"test:build": "cross-env VITE_TEST_BUILD=1 vitest run -c vitest.config.e2e.ts",
"preinstall": "npx only-allow pnpm",
"lint": "eslint .",
"fix": "eslint --fix .",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
Expand All @@ -48,18 +53,31 @@
"postcss": ">=8.0.0"
},
"devDependencies": {
"@minko-fe/eslint-config": "^1.3.3",
"@minko-fe/tsconfig": "^1.3.3",
"@commitlint/cli": "^18.0.0",
"@minko-fe/commitlint-config": "^2.0.4",
"@minko-fe/eslint-config": "^2.0.4",
"@minko-fe/tsconfig": "^2.0.4",
"@types/decode-uri-component": "^0.2.0",
"bumpp": "^9.2.0",
"conventional-changelog-cli": "^2.2.2",
"cross-env": "^7.0.3",
"decode-uri-component": "^0.4.1",
"eslint": "^8.50.0",
"npm-run-all": "^4.1.5",
"postcss": "^8.4.30",
"postcss-nested": "^6.0.1",
"simple-git-hooks": "^2.9.0",
"split-on-first": "^3.0.0",
"tsup": "^7.2.0",
"typescript": "^5.2.2",
"vitest": "^0.29.7"
"vite": "^4.4.9",
"vitest": "^0.34.5",
"vitest-e2e": "^0.0.8"
},
"engines": {
"node": ">=16.0.0"
},
"simple-git-hooks": {
"commit-msg": "pnpm exec commitlint -e"
}
}
6 changes: 6 additions & 0 deletions playground/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@pxtorem/vite-playground",
"version": "1.0.0",
"private": true,
"devDependencies": {}
}
Loading

0 comments on commit 2935021

Please sign in to comment.