Skip to content

Commit

Permalink
feat: add github ci template and test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
sanyuan0704 committed Sep 17, 2022
1 parent ca79ceb commit bba0ccc
Show file tree
Hide file tree
Showing 10 changed files with 1,455 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .commitlintrc.cjs
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional']
};
59 changes: 59 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
@@ -0,0 +1,59 @@
name: "\U0001F41E Bug report"
description: Create a report to help us improve
labels: ['bug: pending triage']
body:
- type: markdown
attributes:
value: |
"Thanks for taking the time to fill out this bug report!
IslandJS is still WIP, and it is not compatible with VuePress.
Please do not open issue about default theme missing features or something doesn't work like IslandJS."
- type: textarea
id: bug-description
attributes:
label: Describe the bug
description: A clear and concise description of what the bug is. If you intend to submit a PR for this issue, tell us in the description. Thanks!
placeholder: Bug description
validations:
required: true
- type: textarea
id: reproduction
attributes:
label: Reproduction
description: Steps to reproduce the behavior
placeholder: Reproduction
validations:
required: true
- type: textarea
id: expected
attributes:
label: Expected behavior
description: A clear and concise description of what you expected to happen.
placeholder: Expected behavior
validations:
required: true
- type: textarea
id: system-info
attributes:
label: System Info
description: Output of `npx envinfo --system --npmPackages islandjs --binaries --browsers`
render: shell
placeholder: System, Binaries, Browsers
validations:
required: true
- type: textarea
id: additional-context
attributes:
label: Additional context
description: Add any other context or screenshots about the bug report here.
- type: checkboxes
id: checkboxes
attributes:
label: Validations
description: Before submitting the issue, please make sure you do the following
options:
required: true
- label: Read the [docs](https://island.sanyuan0704.top).
required: true
- label: Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
required: true
43 changes: 43 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
@@ -0,0 +1,43 @@
name: "\U0001F680 New feature proposal"
description: Suggest an idea for this project
body:
- type: markdown
attributes:
value: |
Thanks for your interest in the project and taking the time to fill out this feature report!
- type: textarea
id: feature-description
attributes:
label: Is your feature request related to a problem? Please describe.
description: "A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]"
validations:
required: true
- type: textarea
id: suggested-solution
attributes:
label: Describe the solution you'd like
description: A clear and concise description of what you want to happen.
validations:
required: true
- type: textarea
id: alternative
attributes:
label: Describe alternatives you've considered
description: A clear and concise description of any alternative solutions or features you've considered.
- type: textarea
id: additional-context
attributes:
label: Additional context
description: Add any other context or screenshots about the feature request here.
- type: checkboxes
id: checkboxes
attributes:
label: Validations
description: Before submitting the issue, please make sure you do the following
options:
- label: Read the [docs](https://island.sanyuan0704.top).
required: true
- label: Read the [Contributing Guidelines](https://github.com/sanyuan0704/island/blob/main/.github/contributing.md).
required: true
- label: Check that there isn't already an issue that asks for the same feature to avoid creating a duplicate.
required: true
91 changes: 91 additions & 0 deletions .github/commit-convention.md
@@ -0,0 +1,91 @@
## Git Commit Message Convention

> This is adapted from [Angular's commit convention](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular).
#### TL;DR:

Messages must be matched by the following regex:

```js
/^(revert: )?(feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip)(\(.+\))?: .{1,50}/
```

#### Examples

Appears under "Features" header, `theme` subheader:

```
feat(theme): add home page feature
```

Appears under "Bug Fixes" header, `theme` subheader, with a link to issue #28:

```
fix(theme): remove underline on sidebar hover style
close #28
```

Appears under "Performance Improvements" header, and under "Breaking Changes" with the breaking change explanation:

```
perf: improve store getters performance by removing 'foo' option
BREAKING CHANGE: The 'foo' option has been removed.
```

The following commit and commit `667ecc1` do not appear in the changelog if they are under the same release. If not, the revert commit appears under the "Reverts" header.

```
revert: feat(theme): add home page feature
This reverts commit 667ecc1654a317a13331b17617d973392f415f02.
```

### Full Message Format

A commit message consists of a **header**, **body** and **footer**. The header has a **type**, **scope** and **subject**:

```
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
```

The **header** is mandatory and the **scope** of the header is optional.

### Revert

If the commit reverts a previous commit, it should begin with `revert: `, followed by the header of the reverted commit. In the body, it should say: `This reverts commit <hash>.`, where the hash is the SHA of the commit being reverted.

### Type

If the prefix is `feat`, `fix` or `perf`, it will appear in the changelog. However, if there is any [BREAKING CHANGE](#footer), the commit will always appear in the changelog.

Other prefixes are up to your discretion. Suggested prefixes are `docs`, `chore`, `style`, `refactor`, and `test` for non-changelog related tasks.

### Scope

The scope could be anything specifying the place of the commit change. For example `theme`, `compiler`, `ssr`, etc...

### Subject

The subject contains a succinct description of the change:

- use the imperative, present tense: "change" not "changed" nor "changes"
- don't capitalize the first letter
- no dot (.) at the end

### Body

Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes".
The body should include the motivation for the change and contrast this with previous behavior.

### Footer

The footer should contain any information about **Breaking Changes** and is also the place to
reference GitHub issues that this commit **Closes**.

**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this.
48 changes: 48 additions & 0 deletions .github/contributing.md
@@ -0,0 +1,48 @@
# Island.js Contributing Guide

Hi! We're really excited that you are interested in contributing to Island.js. Before submitting your contribution, please make sure to take a moment and read through the following guidelines:

- [Pull Request Guidelines](#pull-request-guidelines)

## Pull Request Guidelines

- Checkout a topic branch from the relevant branch, e.g. `master`, and merge back against that branch.

- If adding a new feature:

- Provide a convincing reason to add this feature. Ideally, you should open a suggestion issue first and have it approved before working on it.

- If fixing bug:

- Provide a detailed description of the bug in the PR. Live demo preferred.

- It's OK to have multiple small commits as you work on the PR - GitHub can automatically squash them before merging.

- Commit messages must follow the [commit message convention](./commit-convention.md) so that changelogs can be automatically generated.

## Development Setup

You will need [pnpm](https://pnpm.io)

After cloning the repo, run:

```sh
# install the dependencies of the project
$ pnpm install
```

### Setup Island.js Dev Environment

You can run following command to build the island cli:

```sh
$ pnpm run dev
```

And then you can execute:

```sh
$ pnpm run docs:dev
```

Visit http://localhost:5173 and try modifying the source code. You'll get live update.
46 changes: 46 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,46 @@
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

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14, 16, 18]

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

- name: Install pnpm
uses: pnpm/action-setup@v2

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

- name: Install deps
run: pnpm install

- name: Build
run: pnpm run build

- name: Lint
run: pnpm run lint

- name: Test unit
run: pnpm run test
4 changes: 4 additions & 0 deletions .husky/commit-msg
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no -- commitlint --edit "$1"
4 changes: 4 additions & 0 deletions .husky/pre-commit
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no -- lint-staged
25 changes: 18 additions & 7 deletions package.json
@@ -1,5 +1,5 @@
{
"name": "island-ssg",
"name": "islandjs",
"version": "0.0.0-alpha.11",
"description": "Vite & Island architecture SSG framework",
"main": "dist/index.js",
Expand All @@ -21,17 +21,19 @@
"default": "./src/client/theme-default/index.ts"
}
},
"scripts": {
"scripts": {
"dev": "tsup --watch",
"build": "NODE_ENV=production tsup && tsx scripts/pre-bundle.cts",
"start:client": "cd src/client && tsc -w",
"start:node": "cd src/node && tsc -w",
"dev:docs": "node ./bin/island docs",
"build:docs": "node ./bin/island build docs",
"start:docs": "node ./bin/island start docs",
"lint": "eslint --ext .ts,.tsx,.js,.jsx ./",
"lint:fix": "eslint --fix --ext .js,.jsx,.ts,.tsx --quiet ./",
"test": "vitest run",
"prepublishOnly": "pnpm build"
"prepublishOnly": "pnpm build",
"postinstall": "husky install"
},
"keywords": [
"vite",
Expand All @@ -46,7 +48,6 @@
"@babel/core": "^7.19.0",
"@babel/helper-plugin-utils": "^7.19.0",
"@babel/preset-react": "^7.18.6",
"@babel/traverse": "^7.19.0",
"@loadable/component": "5.15.2",
"@mdx-js/mdx": "^2.1.3",
"@mdx-js/react": "^2.1.3",
Expand Down Expand Up @@ -85,10 +86,12 @@
"unified": "^10.1.2",
"unist-util-visit": "^4.1.1",
"unist-util-visit-children": "^2.0.0",
"vite": "^3.0.9",
"vite-plugin-chunk-split": "^0.3.0"
"vite": "^3.0.9"
},
"devDependencies": {
"@babel/traverse": "^7.19.0",
"@commitlint/cli": "^17.1.2",
"@commitlint/config-conventional": "^17.1.0",
"@loadable/babel-plugin": "^5.13.2",
"@types/babel__core": "^7.1.19",
"@types/babel__helper-plugin-utils": "^7.10.0",
Expand All @@ -107,12 +110,15 @@
"@types/resolve": "^1.20.2",
"@typescript-eslint/eslint-plugin": "^5.36.1",
"@typescript-eslint/parser": "^5.36.1",
"commitlint": "^17.1.2",
"es-module-lexer": "^1.0.3",
"eslint": "^8.23.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.31.1",
"eslint-plugin-react-hooks": "^4.6.0",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
"prettier": "^2.7.1",
"resolve": "^1.22.1",
"rollup": "^2.78.1",
Expand All @@ -127,5 +133,10 @@
"dist",
"vendors",
"template.html"
]
],
"lint-staged": {
"**/*.{js,jsx,tsx,ts,json}": [
"eslint --fix"
]
}
}

0 comments on commit bba0ccc

Please sign in to comment.