Skip to content

Commit

Permalink
ci: add github test action
Browse files Browse the repository at this point in the history
  • Loading branch information
shaodahong committed Jun 18, 2020
1 parent 4c83dcd commit 23fe776
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 12 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Tester

on: push

env:
PRIMARY_NODE_VERSION: 12

jobs:
Tester:
name: Run Tester
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x, 14.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: |
yarn --ignore-engines --frozen-lockfile
- name: Test
run: |
yarn test
env:
CI: true
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ node_modules
.vscode
demo
/lib
src/
/example/ts
22 changes: 12 additions & 10 deletions bin/Build.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
const webpack = require('webpack')
const ora = require('ora')
const chalk = require('chalk')
const rm = require('rimraf')
const path = require('path')
const merge = require('webpack-merge')
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')

module.exports = options => {
const webpack = require('webpack')
const config = require('./build/config')
let webpackConfig = require('./build/build')
const ora = require('ora')
const chalk = require('chalk')
const rm = require('rimraf')
const path = require('path')
const merge = require('webpack-merge')
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
const formatStats = require('./lib/formatStats')

const { APP_CONFIG } = config
const formatStats = require('./lib/formatStats')
const logWithExit = require('./lib/logWithExit')
let webpackConfig = require('./build/build')

const setting = {
test: '测试环境',
Expand Down Expand Up @@ -41,7 +43,7 @@ module.exports = options => {
}

if (stats.hasErrors()) {
return console.log('构建出现错误')
return logWithExit('构建出现错误')
}

console.log()
Expand Down
24 changes: 24 additions & 0 deletions example/appConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
// 一般情况下,它的值是 /${prodPathPrefix}/${prodPath}
basename: process.env.NODE_ENV === 'production' ? '/system/ts' : '',

// 打包出口目录的前缀,注意:不需要以/开头
prodPathPrefix: 'system',

// 打包的出口目录(默认dist目录)
prodPath: 'ts',

// syscode 就是打包出口目录的名称
syscode: 'ts',

// 本地测试端口
port: 3880,

// 本地代理环境地址
target: 'https://github.com/',

// html 文档的标题
title: 'example',

isSystem: true,
}
9 changes: 9 additions & 0 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "example",
"version": "1.0.0",
"main": "./src/main.ts",
"license": "MIT",
"devDependencies": {
"typescript": "^3.9.5"
}
}
5 changes: 5 additions & 0 deletions example/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
interface People {
name: string
}

console.log('hello world')
9 changes: 9 additions & 0 deletions example/src/template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body></body>
</html>
20 changes: 20 additions & 0 deletions example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"importHelpers": true,
"jsx": "react",
"esModuleInterop": true,
"sourceMap": true,
"baseUrl": "./",
"strict": true,
"allowJs": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"experimentalDecorators": true,
"noEmit": true,
"importsNotUsedAsValues": "preserve"
},
"exclude": ["node_modules"]
}
8 changes: 8 additions & 0 deletions example/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


typescript@^3.9.5:
version "3.9.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.5.tgz#586f0dba300cde8be52dd1ac4f7e1009c1b13f36"
integrity sha512-hSAifV3k+i6lEoCJ2k6R2Z/rp/H3+8sdmcn5NrS3/3kE7+RyZXm9aqvxWqjEXHAd8b0pShatpcdMTvEdvAJltQ==
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
"commit": "git-cz",
"version": "yarn changelog && git add CHANGELOG.md",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
"test": "cd ./example && yarn && node ../bin/index.js build",
"lint": "eslint . --ext .js",
"prettier": "prettier -c --write '**/*'",
"prepublishOnly": "yarn lint && np --no-cleanup --yolo --no-publish"
"prepublishOnly": "yarn lint && yarn test && np --no-cleanup --yolo --no-publish"
},
"husky": {
"hooks": {
Expand All @@ -38,6 +39,9 @@
"files": [
"bin"
],
"publishConfig": {
"registry": "https://registry.npmjs.org/"
},
"dependencies": {
"@babel/core": "^7.8.4",
"@pmmmwh/react-refresh-webpack-plugin": "^0.4.0-beta.4",
Expand Down

0 comments on commit 23fe776

Please sign in to comment.