Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add GitHub actions and husky setup #7

Merged
merged 2 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: 'npm' # See documentation for possible values
directory: '/' # Location of package manifests
schedule:
interval: 'weekly'
commit-message:
prefix: 'chore'
include: 'scope'
7 changes: 7 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Description

Describe what was changed in this pull request

## Example images/recordings

Include example images/recordings if the new feature introduces some visual changes
45 changes: 45 additions & 0 deletions .github/workflows/check_pr_title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Lint PR

on:
pull_request_target:
types:
- opened
- edited
- synchronize

permissions: write-all

jobs:
validate_pr_title:
name: 👌 Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
wip: true

- uses: marocchino/sticky-pull-request-comment@v2
# When the previous steps fails, the workflow would stop. By adding this
# condition you can continue the execution with the populated error message.
if: always() && (steps.lint_pr_title.outputs.error_message != null)
with:
header: pr-title-lint-error
message: |
Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted.

Details:

```
${{ steps.lint_pr_title.outputs.error_message }}
```

# Delete a previous comment when the issue has been resolved
- if: ${{ steps.lint_pr_title.outputs.error_message == null }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-title-lint-error
delete: true
27 changes: 27 additions & 0 deletions .github/workflows/rebase.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Automatic Rebase
on:
issue_comment:
types: [created]
jobs:
rebase:
name: 🌿 Rebase
runs-on: ubuntu-latest
if: >-
github.event.issue.pull_request != '' &&
(
contains(github.event.comment.body, '/rebase') ||
contains(github.event.comment.body, '/autosquash')
)
steps:
- name: 🛒 Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GH_TOKEN }}

- name: 🤖 Automatic Rebase
uses: cirrus-actions/[email protected]
with:
autosquash: ${{ contains(github.event.comment.body, '/autosquash') || contains(github.event.comment.body, '/rebase-autosquash') }}
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
28 changes: 28 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Typecheck

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

jobs:
typecheck:
name: 🔎 Typecheck
runs-on: ubuntu-latest
steps:
- name: 🛒 Checkout code
uses: actions/checkout@v3

- name: ⚙️ Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18

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

- name: 🔎 Run typecheck
run: yarn typecheck:all
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn lint-staged
17 changes: 9 additions & 8 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
{
"name": "example",
"version": "1.0.0",
"main": "index.ts",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
},
"dependencies": {
"expo": "~49.0.15",
"expo-status-bar": "~1.6.0",
Expand All @@ -19,5 +12,13 @@
"@types/react": "~18.2.14",
"typescript": "^5.1.3"
},
"private": true
"main": "index.ts",
"private": true,
"scripts": {
"android": "expo start --android",
"ios": "expo start --ios",
"start": "expo start",
"typecheck": "tsc -p tsconfig.json --noEmit",
"web": "expo start --web"
}
}
37 changes: 29 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,52 @@
{
"name": "react-native-skia-responsive-text",
"private": true,
"version": "1.0.0",
"main": "index.js",
"repository": "[email protected]:MatiPl01/react-native-skia-responsive-text.git",
"author": "Mateusz Łopaciński <[email protected]>",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"devDependencies": {
"eslint": "^8.52.0",
"eslint-config-react-native-matipl01": "^1.0.2",
"husky": "^8.0.0",
"jest": "^29.7.0",
"lint-staged": "^15.0.2",
"prettier": "^3.0.3",
"react": "^18.2.0",
"react-native": "^0.72.5",
"syncpack": "^11.2.1",
"typescript": "^5.2.2"
},
"license": "MIT",
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
"yarn lint:fix",
"bash -c tsc --noEmit",
"yarn format:code"
],
"package.json": [
"syncpack format"
]
},
"main": "index.js",
"private": true,
"publishConfig": {
"access": "public"
},
"repository": "[email protected]:MatiPl01/react-native-skia-responsive-text.git",
"resolutions": {
"react": "^18.2.0",
"react-native": "^0.72.5"
},
"scripts": {
"example": "yarn workspace example start",
"example:android": "yarn workspace example android",
"example:ios": "yarn workspace example ios"
"example:ios": "yarn workspace example ios",
"format:code": "prettier --write . --ignore-unknown",
"format:deps": "syncpack format",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"prepare": "husky install",
"typecheck": "tsc -p tsconfig.json --noEmit",
"typecheck:all": "yarn typecheck && yarn typecheck:example",
"typecheck:example": "yarn workspace example typecheck"
},
"workspaces": [
"example"
Expand Down
Loading