Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Commit

Permalink
feat: add github-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Aslemammad committed Aug 9, 2021
1 parent 0731a99 commit 00aa419
Show file tree
Hide file tree
Showing 11 changed files with 695 additions and 39 deletions.
120 changes: 120 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
// @ts-check
const { defineConfig } = require('eslint-define-config')

module.exports = defineConfig({
root: true,
extends: [
'eslint:recommended',
'plugin:node/recommended',
'plugin:@typescript-eslint/recommended'
],
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
},
rules: {
eqeqeq: ['warn', 'always', { null: 'never' }],
'no-debugger': ['error'],
'no-empty': ['warn', { allowEmptyCatch: true }],
'no-process-exit': 'off',
'no-useless-escape': 'off',
'prefer-const': [
'warn',
{
destructuring: 'all'
}
],

'node/no-missing-import': [
'error',
{
allowModules: ['types', 'estree', 'testUtils', 'stylus'],
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts']
}
],
'node/no-missing-require': [
'error',
{
// for try-catching yarn pnp
allowModules: ['pnpapi'],
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts']
}
],
'node/no-restricted-require': [
'error',
Object.keys(require('./packages/vitext/package.json').devDependencies).map(
(d) => ({
name: d,
message:
`devDependencies can only be imported using ESM syntax so ` +
`that they are included in the rollup bundle. If you are trying to ` +
`lazy load a dependency, use (await import('dependency')).default instead.`
})
)
],
'node/no-extraneous-import': [
'error',
{
allowModules: ['vite', 'less', 'sass']
}
],
'node/no-extraneous-require': [
'error',
{
allowModules: ['vite']
}
],
'node/no-deprecated-api': 'off',
'node/no-unpublished-import': 'off',
'node/no-unpublished-require': 'off',
'node/no-unsupported-features/es-syntax': 'off',

'@typescript-eslint/ban-ts-comment': 'off', // TODO: we should turn this on in a new PR
'@typescript-eslint/ban-types': 'off', // TODO: we should turn this on in a new PR
'@typescript-eslint/no-empty-function': [
'error',
{ allow: ['arrowFunctions'] }
],
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-explicit-any': 'off', // maybe we should turn this on in a new PR
'@typescript-eslint/no-extra-semi': 'off', // conflicts with prettier
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'off', // maybe we should turn this on in a new PR
'@typescript-eslint/no-unused-vars': 'off', // maybe we should turn this on in a new PR
'@typescript-eslint/no-var-requires': 'off'
},
overrides: [
{
files: ['packages/vite/src/node/**'],
rules: {
'no-console': ['error']
}
},
{
files: ['packages/playground/**'],
rules: {
'node/no-extraneous-import': 'off',
'node/no-extraneous-require': 'off'
}
},
{
files: ['packages/create-vite/template-*/**'],
rules: {
'node/no-missing-import': 'off'
}
},
{
files: ['*.js'],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off'
}
},
{
files: ['*.d.ts'],
rules: {
'@typescript-eslint/triple-slash-reference': 'off'
}
}
]
})
91 changes: 91 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: CI

env:
NODE_OPTIONS: --max-old-space-size=6144

on:
push:
branches:
- master
pull_request:

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node_version: [12, 14, 16]
include:
- os: macos-latest
node_version: 14
- os: windows-latest
node_version: 14
fail-fast: false

name: "Build&Test: node-${{ matrix.node_version }}, ${{ matrix.os }}"
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set node version to ${{ matrix.node_version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node_version }}

- name: Get yarn cache directory
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Set dependencies cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.node_version }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.node_version }}-${{ hashFiles('yarn.lock') }}
${{ runner.os }}-${{ matrix.node_version }}-
- name: Versions
run: yarn versions

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build vitext
run: yarn build

- name: Test serve
run: yarn test-serve --runInBand

- name: Test build
run: yarn test-build --runInBand

lint:
runs-on: ubuntu-latest
name: "Lint: node-14, ubuntu-latest"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set node version to 14
uses: actions/setup-node@v2
with:
node-version: 14

- name: Set dependencies cache
uses: actions/cache@v2
with:
path: ~/.cache/yarn
key: lint-dependencies-${{ hashFiles('yarn.lock') }}
restore-keys: |
lint-dependencies-${{ hashFiles('yarn.lock') }}
lint-dependencies-
- name: Prepare
run: |
yarn install --frozen-lockfile
- name: Lint
run: yarn lint
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"engines": {
"node": ">=12.0.0"
},
"scripts": {
"test": "run-s test-serve test-build",
"test-serve": "cross-env VITEXT_TEST=1 jest",
"test-build": "cross-env VITEXT_TEST=1 VITE_TEST_BUILD=1 jest",
"lint": "eslint packages/*/{src,types}/**",
"build": "yarn workspace rollup-plugin-esbuild build && yarn workspace vitext build",
"postinstall": ""
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.28.5",
"@typescript-eslint/parser": "^4.28.5",
"eslint": "^7.32.0",
"eslint-define-config": "^1.0.9",
"eslint-plugin-node": "^11.1.0",
"@swc/jest": "^0.1.2",
"@trivago/prettier-plugin-sort-imports": "^2.0.2",
"@types/jest": "^26.0.19",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/intro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"react": "^17.0.2",
"react-dom": "^17.0.2",
"three": "^0.131.3",
"vitext": "0.0.1"
"vitext": "latest"
},
"devDependencies": {
"@tailwindcss/forms": "^0.3.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"react-dom": "^17.0.2",
"react-router-dom": "^5.2.0",
"vite": "^2.3.6",
"vitext": "0.0.1"
"vitext": "latest"
},
"devDependencies": {
"@babel/helper-compilation-targets": "^7.13.16",
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/css/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"react-dom": "^17.0.2",
"react-router-dom": "^5.2.0",
"vite": "^2.3.6",
"vitext": "0.0.1"
"vitext": "latest"
},
"devDependencies": {
"@babel/helper-compilation-targets": "^7.13.16",
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/custom-document-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"react-dom": "^17.0.2",
"react-router-dom": "^5.2.0",
"vite": "^2.3.6",
"vitext": "0.0.1"
"vitext": "latest"
},
"devDependencies": {
"@babel/helper-compilation-targets": "^7.13.16",
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/ssg-basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"react-dom": "^17.0.2",
"react-router-dom": "^5.2.0",
"vite": "^2.3.6",
"vitext": "0.0.1"
"vitext": "latest"
},
"devDependencies": {
"@babel/helper-compilation-targets": "^7.13.16",
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/ssr-basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"react-dom": "^17.0.2",
"react-router-dom": "^5.2.0",
"vite": "^2.3.6",
"vitext": "0.0.1"
"vitext": "latest"
},
"devDependencies": {
"@babel/helper-compilation-targets": "^7.13.16",
Expand Down
17 changes: 13 additions & 4 deletions packages/vitext/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"files": [
"**"
],
"engines": {
"node": ">=12.0.0"
},
"keywords": [
"vitext",
"vite",
Expand All @@ -25,15 +28,15 @@
},
"homepage": "https://github.com/aslemammad/vitext",
"scripts": {
"node": "NODE_ENV=production rollup -c rollup.config.vite.js",
"build-node": "NODE_ENV=production rollup -c rollup.config.vite.js",
"config:internal": "rollup -c --config-internal",
"config:components": "rollup -c --config-components",
"config:react": "rollup -c --config-react",
"config:dynamic": "rollup -c --config-dynamic",
"delete": "rollup -c --config-delete",
"concurrent-build": "concurrently 'yarn:config:*' 'yarn:config:* --config-declaration'",
"concurrent-dev": "concurrently 'yarn:config:*' 'yarn:config:* --config-declaration' 'NODE_ENV=development rollup -c rollup.config.vite.js' -w",
"build": "cross-env-shell NODE_ENV=production \"yarn concurrent-build\"",
"build": "cross-env-shell NODE_ENV=production \"yarn run build-node && yarn run concurrent-build\"",
"watch": "chokidar \"src/**/*.ts\" \"src/**/*.tsx\" -c \"yarn concurrent-build\"",
"watch-all": "chokidar \"src/**/*.ts\" \"src/**/*.tsx\" -c \"yarn concurrent-dev\"",
"dev": "cross-env-shell NODE_ENV=development \"yarn watch-all\""
Expand Down Expand Up @@ -91,7 +94,6 @@
"mitt": "^2.1.0",
"prop-types": "^15.7.2",
"querystring": "^0.2.1",
"react-helmet-async": "^1.0.9",
"react-ssr-prepass": "^1.4.0",
"read-pkg-up": "^7.0.1",
"rollup-plugin-delete": "^2.0.0",
Expand All @@ -102,7 +104,14 @@
"terser": "^5.7.1",
"tiny-invariant": "^1.1.0",
"tslib": "^2.3.0",
"typescript": "^4.3.3"
"typescript": "^4.3.3",
"use-subscription": "^1.5.1",
"react-helmet-async": "^1.0.9",
"esbuild": "^0.12.9",
"postcss": "^8.3.6",
"resolve": "^1.20.0",
"rollup": "^2.38.5",
"vite": "^2.4.2"
},
"dependencies": {
"use-subscription": "^1.5.1",
Expand Down
Loading

0 comments on commit 00aa419

Please sign in to comment.