forked from devhatt/pet-dex-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add build and code-style CI (devhatt#198)
* Add build and code-style CI * ajust action trigger * fix lock file * fix install deps * change pnpm version in install deps * lock pnpm version and node version * fix listed files * fix listed files * remove: test ci * ajust codestyle and fix prettier files * eof insert in .npmrc
- Loading branch information
Showing
13 changed files
with
1,850 additions
and
1,584 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Reusable install deps | ||
description: This workflow installs dependencies using PNPM and caches the store directory. It is meant to be used as a reusable workflow. | ||
inputs: | ||
NODE_VERSION: | ||
description: 'The version of Node.js to use' | ||
required: true | ||
default: '20.x' | ||
PNPM_VERSION: | ||
description: 'The version of PNPM to use' | ||
required: true | ||
default: '8.x' | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Code checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Use Node.js ${{ inputs.NODE_VERSION }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ inputs.NODE_VERSION }} | ||
|
||
- uses: pnpm/action-setup@v3 | ||
name: Install pnpm | ||
with: | ||
version: ${{ inputs.PNPM_VERSION }} | ||
run_install: false | ||
|
||
- name: Get PNPM store directory | ||
shell: bash | ||
run: | | ||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | ||
- uses: actions/cache@v4 | ||
name: Setup PNPM cache | ||
with: | ||
path: ${{ env.STORE_PATH }} | ||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store- | ||
- name: Install dependencies | ||
shell: bash | ||
run: pnpm install --frozen-lockfile -r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Build project | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Code Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup deps | ||
uses: ./.github/actions/install-deps | ||
|
||
- name: Build | ||
run: pnpm build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: Code Style | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
code-style: | ||
runs-on: ubuntu-latest | ||
name: code-style | ||
steps: | ||
- name: Code Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup deps | ||
uses: ./.github/actions/install-deps | ||
|
||
- name: Get all changed files | ||
id: all-changed-files | ||
uses: tj-actions/changed-files@v41 | ||
with: | ||
files: | | ||
!pnpm-lock.yaml | ||
- name: Run prettier in all files | ||
if: steps.all-changed-files.outputs.any_changed == 'true' | ||
env: | ||
files: ${{ steps.all-changed-files.outputs.all_changed_files }} | ||
run: pnpm exec prettier $files --check --ignore-unknown | ||
|
||
- name: Get specific changed files | ||
id: changed-files | ||
uses: tj-actions/changed-files@v41 | ||
with: | ||
files_yaml: | | ||
code: | ||
- '**.js' | ||
- '**.ts' | ||
- '**.tsx' | ||
- '**.jsx' | ||
- '**.mjs' | ||
- '**.cjs' | ||
style: | ||
- '**.scss' | ||
- name: Run stylelint in scss files | ||
if: steps.changed-files.outputs.style_any_changed == 'true' | ||
env: | ||
files: ${{ steps.changed-files.outputs.style_all_changed_files }} | ||
run: pnpm exec stylelint $files --allow-empty-input | ||
|
||
- name: Run eslint in code files | ||
if: steps.changed-files.outputs.code_any_changed == 'true' | ||
env: | ||
files: ${{ steps.changed-files.outputs.code_all_changed_files }} | ||
run: pnpm exec eslint $files --report-unused-disable-directives --max-warnings 0 --output-file eslint_report.json --format json | ||
continue-on-error: true | ||
|
||
- name: Annotate Code Linting Results | ||
if: steps.changed-files.outputs.code_any_changed == 'true' | ||
uses: ataylorme/eslint-annotate-action@v2 | ||
with: | ||
repo-token: '${{ secrets.GITHUB_TOKEN }}' | ||
report-json: 'eslint_report.json' | ||
|
||
- name: Upload ESLint report | ||
if: steps.changed-files.outputs.code_any_changed == 'true' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: eslint_report.json | ||
path: eslint_report.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
## PNPM related ############### | ||
## https://pnpm.io/npmrc # | ||
############################### | ||
|
||
# Not always possible to be strict, but if it works for you, keep it to true. | ||
# https://pnpm.io/next/npmrc#strict-peer-dependencies | ||
strict-peer-dependencies=true | ||
|
||
# https://pnpm.io/npmrc#auto-install-peers | ||
auto-install-peers=true | ||
|
||
# Helps locating duplicates, default in v8 | ||
# https://pnpm.io/next/npmrc#use-lockfile-v6 | ||
use-lockfile-v6=true | ||
|
||
# Will fix duplicates due to peer-dependencies (>=7.29.0), default in v8 | ||
# https://github.com/pnpm/pnpm/releases/tag/v7.29.0 | ||
dedupe-peer-dependents=true | ||
|
||
# Helps with peer-deps (>=7.23.0), default in v8 | ||
# https://pnpm.io/npmrc#resolve-peers-from-workspace-root | ||
resolve-peers-from-workspace-root=true | ||
|
||
# default to 'lowest' in v8.5.0 | ||
# set to highest for reasons specified here: https://github.com/pnpm/pnpm/issues/6463 | ||
# https://pnpm.io/npmrc#resolution-mode | ||
resolution-mode=highest | ||
|
||
# Default in 8.1.0 to fix issues with root/workspaces hoisting | ||
# https://pnpm.io/npmrc#dedupe-direct-deps | ||
dedupe-direct-deps=false | ||
|
||
# Pinlock to exact version (default is '^') | ||
# https://pnpm.io/npmrc#save-prefix | ||
# see also how save-workspace-protocol affect this https://pnpm.io/npmrc#save-workspace-protocol | ||
save-prefix='' | ||
|
||
# Most of the time, you want to use the rolling protocol for monorepos | ||
# https://pnpm.io/npmrc#save-workspace-protocol | ||
save-workspace-protocol=rolling | ||
|
||
# Specifies which exact Node.js version should be used for the project's runtime. | ||
# pnpm will automatically install the specified version of Node.js and use it | ||
# for running pnpm run commands or the pnpm node command. | ||
# https://pnpm.io/npmrc#save-workspace-protocol | ||
use-node-version=20.10.0 | ||
|
||
# Prevent contributors of your project from adding new incompatible dependencies | ||
# This way, even if someone is using Node.js v16, they will not be able to install | ||
# a new dependency that doesn't support Node.js v20.10.0 | ||
# https://pnpm.io/npmrc#use-node-version | ||
node-version=20.10.0 | ||
engine-strict=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.