Skip to content

Commit

Permalink
chore: scaffolding (#1)
Browse files Browse the repository at this point in the history
* chore: add package.json and license

* chore: add lint, husky and prettier

* docs: add contributing guide

* feat: add pull request template

* chore: setup hello world with react, redux toolkit and react router

* docs: add readme

* ci: add relase and deploy workflows

* chore: squash
  • Loading branch information
kieranroneill authored Feb 21, 2024
1 parent 981e3ca commit 64ad1a3
Show file tree
Hide file tree
Showing 95 changed files with 11,167 additions and 0 deletions.
1 change: 1 addition & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
defaults
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

# Matches the exact files either package.json or .travis.yml
[*.{json,yml}]
indent_style = space
indent_size = 2
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
coverage/
dist/
node_modules/
24 changes: 24 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
root: true,
env: {
jest: true,
},
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'react'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'prettier',
],
rules: {
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-namespace': ['error', { allowDeclarations: true }],
'prefer-const': 'off',
},
settings: {
react: {
version: 'detect',
},
},
};
22 changes: 22 additions & 0 deletions .github/actions/use-dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "Use Dependencies"

description: "Checks if the dependencies have been cached with the hash of the yarn.lock file."

runs:
using: "composite"
steps:
- name: "🔧 Setup"
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
cache: 'yarn'
- name: "💾 Cache dependencies"
uses: actions/cache@v3
id: cache-dependencies
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('yarn.lock') }}
- name: "📦 Install"
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: yarn install --ignore-scripts
shell: bash
23 changes: 23 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--
The title should summarise what the purpose of this change,
⚠️**NOTE:** The title must conform to the conventional commit message format outlined in CONTRIBUTING.md document, at the root of the project. This is to ensure the merge commit to the main branch is picked up by the CI and creates an entry in the CHANGELOG.md.
-->

# Description
<!-- Describe your changes in detail -->

# Type of change
<!-- What type of change does this change introduce? Put an 'x' in all the boxes that apply. -->

- [ ] 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] 🏗️ Build configuration (CI configuration, scaffolding etc.)
- [ ] 🐛 Bug fix (non-breaking change which fixes an issue)
- [ ] 📝 Documentation update(s)
- [ ] 📦 Dependency update(s)
- [ ] 👩🏽‍💻 Improve developer experience
- [ ] ⚡ Improve performance
- [ ] ✨ New feature (non-breaking change which adds functionality)
- [ ] ♻ Refactor
- [ ] ⏪ Revert changes
- [ ] 🧪 New tests or updates to existing tests
35 changes: 35 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: "Deploy"

on:
release:
types: [released] # triggered on main branch releases

jobs:
install:
name: "Install"
runs-on: ubuntu-latest
steps:
- name: "🛎 Checkout"
uses: actions/checkout@v4
- name: "🔧 Setup"
uses: ./.github/actions/use-dependencies

deploy:
name: "Deploy"
needs: install
runs-on: ubuntu-latest
steps:
- name: "🛎 Checkout"
uses: actions/checkout@v4
- name: "🔧 Setup"
uses: ./.github/actions/use-dependencies
- name: "🏗️ Build"
run: yarn build
- name: "🚀 Deploy"
uses: peaceiris/actions-gh-pages@v3
with:
personal_token: ${{ secrets.WRITE_REPOS_TOKEN }}
publish_branch: gh-pages
publish_dir: ./dist
user_name: agoralabs-bot
user_email: tech@agoralabs.sh
59 changes: 59 additions & 0 deletions .github/workflows/pull_request_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: "Pull Request Checks"

on:
pull_request:

jobs:
##
# install
##

install:
name: "Install"
runs-on: ubuntu-latest
steps:
- name: "🛎 Checkout"
uses: actions/checkout@v4
- name: "🔧 Setup"
uses: ./.github/actions/use-dependencies

##
# lint, build and test
##

lint:
name: "Lint"
needs: install
runs-on: ubuntu-latest
steps:
- name: "🛎 Checkout"
uses: actions/checkout@v4
- name: "🔧 Setup"
uses: ./.github/actions/use-dependencies
- name: "👕 Lint"
run: yarn lint

build:
name: "Build"
needs: install
runs-on: ubuntu-latest
environment: development
steps:
- name: "🛎 Checkout"
uses: actions/checkout@v4
- name: "🔧 Setup"
uses: ./.github/actions/use-dependencies
- name: "🏗️ Build"
run: yarn build

test:
name: "Test"
needs: install
runs-on: ubuntu-latest
steps:
- name: "🛎 Checkout"
uses: actions/checkout@v4
- name: "🔧 Setup"
uses: ./.github/actions/use-dependencies
- name: "🧪 Test"
run: yarn test
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "Release"

on:
push:
branches:
- main

jobs:
release:
name: "Release"
runs-on: ubuntu-latest
steps:
- name: "🛎 Checkout"
uses: actions/checkout@v4
- name: "🔧 Setup"
uses: actions/setup-node@v4
with:
node-version: '20.9.0'
cache: yarn
- name: "📦 Install"
run: yarn global add semantic-release @semantic-release/commit-analyzer @semantic-release/release-notes-generator @semantic-release/npm @semantic-release/github @semantic-release/git @semantic-release/changelog
- name: "🔖 Release"
env:
# appears on the release commits
GIT_AUTHOR_NAME: agoralabs-bot
GIT_AUTHOR_EMAIL: tech@agoralabs.sh
GIT_COMMITTER_NAME: agoralabs-bot
GIT_COMMITTER_EMAIL: tech@agoralabs.sh
# used to push the release commit and create the tags
GITHUB_TOKEN: ${{ secrets.WRITE_REPOS_TOKEN }}
run: semantic-release
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn commitlint --edit "$1"
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged
6 changes: 6 additions & 0 deletions .huskyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-commit": "lint-staged"
}
}
4 changes: 4 additions & 0 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
'**/*.{js,json,ts,tsx}': (filenames) =>
`prettier --write ${filenames.join(' ')}`,
};
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
coverage/
dist/
node_modules/
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"endOfLine": "lf",
"arrowParens": "always",
"singleQuote": true,
"trailingComma": "es5"
}
22 changes: 22 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"branches": "main",
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/npm",
[
"@semantic-release/git",
{
"assets": ["package.json", "CHANGELOG.md"],
"message": "chore(release): ${nextRelease.version}\n\n${nextRelease.notes}"
}
],
[
"@semantic-release/github",
{
"releasedLabels": ["🚀 released"]
}
]
]
}
80 changes: 80 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Contributing guide

### Table of contents

* [1. Commit messages](#1-commit-messages)
* [1.1. Type](#11-type)
* [1.2. Scope](#12-scope)
* [1.3. Subject](#13-subject)
* [2. Pull requests](#2-pull-requests)
* [2.1 Branching strategy](#21-branching-strategy)
* [2.2 Merge to main](#22-merge-to-main)

## 1. Commit messages

Commit messages lean heavily towards the convention set out by [conventional commits][conventional-commits].

Each commit message must be in the format that includes a **type**, an optional **scope** and a **subject**:
```
type(scope?): subject #scope is optional
```

Limit the whole message to 72 characters or less!

Example:

```
build(terraform): burn it all down
```

### 1.1. Type

Must be one of the following:

* **build**: Changes that affect the build system or external dependencies (example scopes: npm)
* **chore**: Changes that don't really fall under any other type
* **ci**: Changes to the CI configuration files and scripts
* **docs**: Documentation only changes
* **feat**: A new feature
* **fix**: A bug fix
* **perf**: A code change that improves performance
* **refactor**: A code change that neither fixes a bug nor adds a feature
* **revert**: Revert a previous commit
* **test**: Adding missing tests or correcting existing tests

### 1.2. Scope

A scope may be provided to a commit’s type, to provide additional contextual information and is contained within a parenthesis

### 1.3. Subject

The subject contains a succinct description of the change:

* use the present tense ("Add feature" not "Added feature")
* use the imperative mood ("Move cursor to..." not "Moves cursor to...")
* don't capitalise the first letter
* don't use a fullstop (.) at the end. <- Not this

<sup>[Back to top ^](#table-of-contents)</sup>

## 2. Pull requests

### 2.1 Branching strategy

This repo uses a [trunk-based][trunk-based] development workflow. There is one permanent branch, the `main` branch, which contains stable code and all releases are based off of any commits to this branch.

In order to make updates, a feature branch is made from the `main` branch and when it is ready to be merged, it can be brought back into the `main` branch which trigger a release (if necessary).

<sup>[Back to top ^](#table-of-contents)</sup>

### 2.2 Merge to main

1. Create a branch from the `main` branch and use the convention: `<feat|fix|ci>/name-of-issue`.
2. Once the code is ready to be merged into `main`, open a pull request.
> ⚠️**NOTE:** The title must conform to the conventional commit message format outlined above. This is to ensure the merge commit to the main branch is picked up by the CI and creates a release (if necessary).
3. To merge the PR, use the "Squash and merge" option. This is to keep the commit history clean and keep the commits on `main` with a 1:1 ratio with previous PRs.

<sup>[Back to top ^](#table-of-contents)</sup>

[conventional-commits]: https://www.conventionalcommits.org
[trunk-based]: https://www.atlassian.com/continuous-delivery/continuous-integration/trunk-based-development
9 changes: 9 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) 2024 Agora Labs

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Loading

0 comments on commit 64ad1a3

Please sign in to comment.