Skip to content

Commit

Permalink
feat(ci): add PR evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
JaeAeich committed Mar 5, 2024
1 parent 6b03757 commit afaa2a8
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 8 deletions.
128 changes: 128 additions & 0 deletions .github/workflows/pr_evaluation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: PR Evaluation

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, edited]
branches: ['main']

jobs:

semantic_pr:
name: Semantic PR title
runs-on: ubuntu-latest
if: ${{ github.event.action != 'edited' || github.event.changes.title != null }}
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# Configure which types are allowed (newline-delimited).
# Default: https://github.com/commitizen/conventional-commit-types
types: |
fix
feat
docs
style
refactor
perf
test
build
ci
chore
revert
# Configure additional validation for the subject based on a regex.
# This example ensures the subject doesn't start with an uppercase character & has more than 50 chars.
subjectPattern: ^(?![A-Z])(?=.{1,50}$).+$
# If `subjectPattern` is configured, you can use this property to override
# the default error message that is shown when the pattern doesn't match.
# The variables `subject` and `title` can be used within the message.
subjectPatternError: |
The subject "{subject}" found in the pull request title "{title}"
didn't match the configured pattern. Please ensure that the subject
doesn't start with an uppercase character & not have more than 50 characters.
detect-unresolved-conflicts:
name: Detect unresolved merge conflicts
runs-on: ubuntu-latest
needs: semantic_pr
steps:
- uses: actions/checkout@v3
- name: List files with merge conflict markers
run: git --no-pager grep "<<<<<<<" ":(exclude).github/" || true
- name: Fail or succeed job if any files with merge conflict markers have been checked in
# Find lines containing "<<<<<<<", then count the number of lines.
# 0 matching lines results in exit code 0, i.e. success.
run: exit $(git grep "<<<<<<<" ":(exclude).github/" | wc --lines)

linters:
name: Linting checks
runs-on: ubuntu-latest
needs: semantic_pr

steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Use Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20.x

- name: Get node version
id: node
run: |
echo "::set-output name=version::$(node -v)"
- name: Get node_modules cache
uses: actions/[email protected]
id: node_modules
with:
path: |
**/node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package.lock') }}-${{ steps.node.outputs.version }}

- name: Install dependencies
run: npm install

- name: Run linters
run: npm run lint

# tests:
# name: Test checks
# runs-on: ubuntu-latest
# needs: semantic_pr
# strategy:
# matrix:
# node-version: [18.x, 20.x]

# steps:
# - name: Check out code
# uses: actions/checkout@v3
# with:
# fetch-depth: 2

# - name: Use Node.js ${{ matrix.node-version }}
# uses: actions/setup-node@v3
# with:
# node-version: ${{ matrix.node-version }}

# - name: Get node version
# id: node
# run: |
# echo "::set-output name=version::$(node -v)"

# - name: Get node_modules cache
# uses: actions/[email protected]
# id: node_modules
# with:
# path: |
# **/node_modules
# key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package.lock') }}-${{ steps.node.outputs.version }}

# - name: Install dependencies
# run: npm install

# - name: Run tests
# run: npm run test
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"lint": "next lint",
"lint-fix": "eslint ./ --fix",
"format": "prettier --write \"**/*.{js,jsx,json,md}\"",
"format:check": "prettier --check \"**/*.{js,jsx,json,md}\"",
"prepare": "husky install",
"pre-commit": "lint-staged"
},
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,15 @@
dependencies:
glob "7.1.7"

"@next/swc-darwin[email protected]":
"@next/swc-linux-x64-gnu@13.4.19":
version "13.4.19"
resolved "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.4.19.tgz"
integrity sha512-jyzO6wwYhx6F+7gD8ddZfuqO4TtpJdw3wyOduR4fxTUCm3aLw7YmHGYNjS0xRSYGAkLpBkH1E0RcelyId6lNsw==
resolved "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.4.19.tgz"
integrity sha512-htwOEagMa/CXNykFFeAHHvMJeqZfNQEoQvHfsA4wgg5QqGNqD5soeCer4oGlCol6NGUxknrQO6VEustcv+Md+g==

"@next/[email protected]":
version "13.4.19"
resolved "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.4.19.tgz"
integrity sha512-4Gj4vvtbK1JH8ApWTT214b3GwUh9EKKQjY41hH/t+u55Knxi/0wesMzwQRhppK6Ddalhu0TEttbiJ+wRcoEj5Q==

"@nodelib/[email protected]":
version "2.1.5"
Expand Down Expand Up @@ -1486,11 +1491,6 @@ fs.realpath@^1.0.0:
resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==

fsevents@~2.3.2:
version "2.3.3"
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz"
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==

function-bind@^1.1.1:
version "1.1.1"
resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz"
Expand Down

0 comments on commit afaa2a8

Please sign in to comment.