chore: split Github Actions workflows

This commit is contained in:
Harttle
2023-06-05 23:23:52 +08:00
parent 495bef2d0c
commit 417432fb8a
21 changed files with 304 additions and 108 deletions
+40
View File
@@ -0,0 +1,40 @@
name: Build
on:
workflow_call:
inputs:
os:
required: true
type: string
bundles:
required: false
type: string
env:
BUNDLES: ${{ inputs.bundles }}
jobs:
build:
name: Build
runs-on: ${{ inputs.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '14'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: dist-${{ inputs.os }}
path: dist
- name: Archive npm failure logs
uses: actions/upload-artifact@v3
if: failure()
with:
name: npm-logs
path: ~/.npm/_logs
-41
View File
@@ -1,41 +0,0 @@
name: Check
on: [push, pull_request]
jobs:
check:
name: Check
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Build
run: |
npm ci
npm run build
- name: Test
run: |
npm run lint
TZ=Etc/GMT npm run test
TZ=Asia/Shanghai npm run test
TZ=America/New_York npm run test
- name: Coverage
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Performance
run: |
npm run perf:diff
- name: Archive npm failure logs
uses: actions/upload-artifact@v2
if: failure()
with:
name: npm-logs
path: ~/.npm/_logs
+28
View File
@@ -0,0 +1,28 @@
name: CI Build
on:
push:
branches:
- 'master'
- 'test'
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
uses: ./.github/workflows/build.yml
with:
os: ${{ matrix.os }}
lint:
uses: ./.github/workflows/lint.yml
test:
needs: build
uses: ./.github/workflows/test.yml
coverage:
uses: ./.github/workflows/coverage.yml
performance:
needs: build
uses: ./.github/workflows/performance.yml
with:
os: ubuntu-latest
docs:
uses: ./.github/workflows/docs.yml
+29
View File
@@ -0,0 +1,29 @@
name: Test Coverage
on: [workflow_dispatch, workflow_call]
jobs:
coverage:
name: Test Coverage
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '14'
- name: Install dependencies
run: npm ci
- name: Test
run: npm run test:coverage
- name: Coverage
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Archive npm failure logs
uses: actions/upload-artifact@v3
if: failure()
with:
name: npm-logs
path: ~/.npm/_logs
+6 -8
View File
@@ -1,32 +1,30 @@
name: Docs name: Docs
on: on: [workflow_dispatch, workflow_call]
push:
branches:
- master
jobs: jobs:
docs: docs:
name: Docs name: Docs
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Setup Node.js - name: Setup Node.js
uses: actions/setup-node@v2 uses: actions/setup-node@v3
with: with:
node-version: '14' node-version: '14'
- name: Build - name: Build
run: | run: |
npm ci npm ci
npm run build npm run build:docs
- name: Publish - name: Publish
if: github.ref == 'refs/heads/master'
uses: JamesIves/[email protected] uses: JamesIves/[email protected]
with: with:
branch: gh-pages branch: gh-pages
folder: docs/public folder: docs/public
- name: Archive npm failure logs - name: Archive npm failure logs
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v3
if: failure() if: failure()
with: with:
name: npm-logs name: npm-logs
+25
View File
@@ -0,0 +1,25 @@
name: Lint
on: [workflow_dispatch, workflow_call]
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '14'
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Archive npm failure logs
uses: actions/upload-artifact@v3
if: failure()
with:
name: npm-logs
path: ~/.npm/_logs
+33
View File
@@ -0,0 +1,33 @@
name: Performance Check
on:
workflow_call:
inputs:
os:
required: true
type: string
jobs:
performance:
name: Performance
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '14'
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: dist-${{ inputs.os }}
path: dist
- name: Check Performance
run: npm run perf:diff
- name: Archive npm failure logs
uses: actions/upload-artifact@v3
if: failure()
with:
name: npm-logs
path: ~/.npm/_logs
+22
View File
@@ -0,0 +1,22 @@
name: PR Build
on: pull_request
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
uses: ./.github/workflows/build.yml
with:
os: ${{ matrix.os }}
lint:
uses: ./.github/workflows/lint.yml
test:
needs: build
uses: ./.github/workflows/test.yml
coverage:
uses: ./.github/workflows/coverage.yml
performance:
needs: build
uses: ./.github/workflows/performance.yml
with:
os: ubuntu-latest
@@ -1,15 +1,12 @@
name: "PR Title Checker" name: PR Check
on: on:
pull_request_target: pull_request_target:
types: types:
- opened - opened
- edited - edited
- synchronize
jobs: jobs:
main: title:
name: Validate PR title name: Check PR title
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: amannn/action-semantic-pull-request@v5 - uses: amannn/action-semantic-pull-request@v5
+27 -16
View File
@@ -1,37 +1,48 @@
name: Release name: Release
on: workflow_dispatch on: workflow_dispatch
jobs: jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
uses: ./.github/workflows/build.yml
with:
os: ${{ matrix.os }}
test:
needs: build
uses: ./.github/workflows/test.yml
release: release:
name: Release name: Release
needs: [build, test]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Setup Node.js - name: Setup Node.js
uses: actions/setup-node@v2 uses: actions/setup-node@v3
with: with:
node-version: '14' node-version: '18'
- name: Build - name: Install Dependencies
run: | run: npm ci
npm ci - name: Download artifacts
npm run build:dist uses: actions/download-artifact@v3
- name: Test
run: |
npm run lint
npm run test
- name: Coverage
uses: coverallsapp/[email protected]
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} name: dist-ubuntu-latest
path: dist
- name: Release - name: Release
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release run: |
if [ ${{ github.ref == 'refs/heads/master' }} ]; then
npx semantic-release
else
npx semantic-release --dry-run
fi
- name: Archive npm failure logs - name: Archive npm failure logs
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v3
if: failure() if: failure()
with: with:
name: npm-logs name: npm-logs
+34
View File
@@ -0,0 +1,34 @@
name: Test
on: [workflow_dispatch, workflow_call]
jobs:
test:
name: Test
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
timezone: [Etc/GMT, Asia/Shanghai, America/New_York]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '14'
- name: Install dependencies
run: npm ci
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: dist-${{ matrix.os }}
path: dist
- name: Run Test
run: TZ=${{ matrix.timezone }} npm test
- name: Archive npm failure logs
uses: actions/upload-artifact@v3
if: failure()
with:
name: npm-logs
path: ~/.npm/_logs
+3
View File
@@ -9,6 +9,9 @@ coverage/
# modules # modules
node_modules/ node_modules/
# tmp
docs/public/js/liquid.browser.min.js
dist/ dist/
demo/*/package-lock.json demo/*/package-lock.json
demo/*/yarn.json demo/*/yarn.json
+17 -25
View File
@@ -16,14 +16,14 @@
- Ensure the build runs because the Husky pre-commit hook checks it - Ensure the build runs because the Husky pre-commit hook checks it
- `npm run check` checks runs the build, tests, lint and perf tests - `npm run check` checks runs the build, tests, lint and perf tests
- `commitlint` checks the commit message format - `commitlint` checks the commit message format
If there is a problem you will see it in the pre-commit hook output. If there is a problem you will see it in the pre-commit hook output.
In VS Code, this output will be shown in a new file in a new tab if the In VS Code, this output will be shown in a new file in a new tab if the
pre-commit hook fails. pre-commit hook fails.
If you want to check the commit message without using the VS Code Source If you want to check the commit message without using the VS Code Source
Control UI, you can run `echo "feat: my commit message" > npx commitlint` Control UI, you can run `echo "feat: my commit message" > npx commitlint`
directly. directly.
- `git switch -c your_branch_name` (do this in your fork not the main repo) - `git switch -c your_branch_name` (do this in your fork not the main repo)
- `git add .` - `git add .`
- `git commit -m "feat: Adding my change"` - `git commit -m "feat: Adding my change"`
@@ -33,32 +33,24 @@
## Playground ## Playground
The Playground runs off the `docs` directory. The Playground runs off the `docs` directory.
`npm run:docs` is used to build it and that's included in `npm run build`. `npm run build:docs` is used to build it.
To start the site locally, go to `docs` and run `npm start`, then visit Then, to start the site locally, go to `docs` and run `npm start`, then visit
http://localhost:4000/playground.html. http://localhost:4000/playground.html.
At the moment, the Playground uses the latest NPM version of the LiquidJS The Playground uses a local built LiquidJS, which is created during `npm run build:docs`.
library instead of using the built artifact produced by `npm run build:dist` To update that, you'll need to run `./bin/build-docs-liquid.sh` each time after making changes.
(also included in `npm run build`). Then refresh the Playground site for the changes to take effect.
To use the Playground with the local build of the library, make these changes: ## Performance
- Copy `dist/liquid.browser.min.js` to `docs/public/js/liquid.browser.min.js` If your change can have a performance impact, you can update and run performance cases under `benchmark/`.
- Open `docs/themes/navy/layout/partial/after_footer.swig`
- Remove `https://cdn.jsdelivr.net/npm/liquidjs/dist/liquid.browser.min.js` line
- Add `{{ js('liquid.browser.min.js') }}` line before `{{ js('js/main') }}` line
- Refresh the Playground site for the changes to take effect
- Replace `liquid.browser.min.js` each time after making changes and building
```diff 1. `npm run build:cjs` to build a CommonJS bundle for the perf test.
{% if page.layout === 'playground' %} 2. `npm run perf:diff` to check whether there's a regression compared against `liquidjs@latest`
-<script src="https://cdn.jsdelivr.net/npm/liquidjs/dist/liquid.browser.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/ace-builds@1.4.8/src-min/ace.js"></script> Further more, `benchmark/` contains different cases to check its ops/sec. Useful when debugging perf regressions, to use it:
{% endif %}
- `cd benchmark` go into benchmark project
+{{ js('js/liquid.browser.min.js') }} - `npm ci` install dependencies
{{ js('js/main') }} - `npm start` run the cases
<script src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
```
+6
View File
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
BUNDLES=min npm run build
mkdir -p docs/public/js/
cp dist/liquid.browser.min.js docs/public/js/
+1
View File
@@ -2,6 +2,7 @@
set -ex set -ex
./bin/build-docs-liquid.sh
./bin/build-contributors.sh ./bin/build-contributors.sh
./bin/build-apidoc.sh ./bin/build-apidoc.sh
./bin/build-changelog.sh ./bin/build-changelog.sh
-4
View File
@@ -9,8 +9,4 @@ if [ ! -f $FILE_LATEST ]; then
curl $URL_LATEST > $FILE_LATEST curl $URL_LATEST > $FILE_LATEST
fi fi
# if [ ! -f $FILE_LOCAL ]; then
BUNDLES=cjs npm run build:dist
# fi
exec node benchmark/diff.js $FILE_LOCAL $FILE_LATEST exec node benchmark/diff.js $FILE_LOCAL $FILE_LATEST
+1 -1
View File
@@ -1,5 +1,5 @@
{% if page.layout === 'playground' %} {% if page.layout === 'playground' %}
<script src="https://cdn.jsdelivr.net/npm/liquidjs@latest/dist/liquid.browser.min.js"></script> {{ js('js/liquid.browser.min.js') }}
<script src="https://cdn.jsdelivr.net/npm/[email protected]/src-min/ace.js"></script> <script src="https://cdn.jsdelivr.net/npm/[email protected]/src-min/ace.js"></script>
{% endif %} {% endif %}
+6 -6
View File
@@ -15,16 +15,16 @@
}, },
"scripts": { "scripts": {
"lint": "eslint \"**/*.mjs\" \"**/*.ts\" .", "lint": "eslint \"**/*.mjs\" \"**/*.ts\" .",
"check": "npm run build && npm test && npm run lint && npm run perf:diff", "check": "npm run build && npm run build:docs && npm test && npm run lint && npm run perf:diff",
"test": "jest --coverage", "test": "jest",
"test:coverage": "jest --coverage src test/integration",
"test:e2e": "jest test/e2e", "test:e2e": "jest test/e2e",
"perf": "cd benchmark && npm ci && npm start",
"perf:diff": "bin/perf-diff.sh", "perf:diff": "bin/perf-diff.sh",
"perf:engines": "cd benchmark && npm run engines", "perf:engines": "cd benchmark && npm run engines",
"postversion": "npm run build:dist", "build": "rollup -c rollup.config.mjs",
"build": "npm run build:dist && npm run build:docs",
"build:dist": "rollup -c rollup.config.mjs",
"build:cjs": "BUNDLES=cjs rollup -c rollup.config.mjs", "build:cjs": "BUNDLES=cjs rollup -c rollup.config.mjs",
"build:min": "BUNDLES=min rollup -c rollup.config.mjs",
"build:umd": "BUNDLES=umd rollup -c rollup.config.mjs",
"build:docs": "bin/build-docs.sh" "build:docs": "bin/build-docs.sh"
}, },
"bin": { "bin": {
+5
View File
@@ -1,11 +1,16 @@
{ {
"extends": ["../.eslintrc.json"],
"env": { "env": {
"mocha": true "mocha": true
}, },
"plugins": [ "plugins": [
"mocha" "mocha"
], ],
"parserOptions": {
"project": "test/tsconfig.json"
},
"rules": { "rules": {
"deprecation/deprecation": "off",
"@typescript-eslint/no-var-requires": "off", "@typescript-eslint/no-var-requires": "off",
"no-unused-expressions": "off", "no-unused-expressions": "off",
"no-new": "off" "no-new": "off"
+17
View File
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"target": "es6",
"module":"CommonJS",
"lib": ["es2015", "es2016", "es2017", "dom"],
"sourceMap": true,
"outDir": "dist",
"declaration": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"downlevelIteration": true,
"strict": true,
"suppressImplicitAnyIndexErrors": true
},
"all": true
}
+1 -1
View File
@@ -14,5 +14,5 @@
"suppressImplicitAnyIndexErrors": true "suppressImplicitAnyIndexErrors": true
}, },
"all": true, "all": true,
"exclude": [ "node_modules", "dist", "demo" ] "exclude": [ "node_modules", "dist", "demo", "test" ]
} }