From afaa2a814f3ed9b036e70e551e2dae2fea8c1615 Mon Sep 17 00:00:00 2001 From: Javed Habib Date: Tue, 5 Mar 2024 16:04:13 +0530 Subject: [PATCH] feat(ci): add PR evaluation --- .github/workflows/pr_evaluation.yml | 128 ++++++++++++++++++++++++++++ package.json | 1 + yarn.lock | 16 ++-- 3 files changed, 137 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/pr_evaluation.yml diff --git a/.github/workflows/pr_evaluation.yml b/.github/workflows/pr_evaluation.yml new file mode 100644 index 0000000..1fa9d13 --- /dev/null +++ b/.github/workflows/pr_evaluation.yml @@ -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/cache@v3.0.2 + 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/cache@v3.0.2 + # 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 \ No newline at end of file diff --git a/package.json b/package.json index d5d481a..3a31d38 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/yarn.lock b/yarn.lock index 21d8e0f..b319ba1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -204,10 +204,15 @@ dependencies: glob "7.1.7" -"@next/swc-darwin-x64@13.4.19": +"@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/swc-linux-x64-musl@13.4.19": + 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/fs.scandir@2.1.5": version "2.1.5" @@ -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"