From 67f4bb7539ca599df463fa48724c5a3f267c692c Mon Sep 17 00:00:00 2001 From: Jacek Kurkowski Date: Tue, 12 Jul 2022 14:25:48 +0200 Subject: [PATCH] [ATL-1386] Add simple rules --- .github/CODEOWNERS | 20 +++++++++ .github/PULL_REQUEST_TEMPLATE.md | 14 +++++++ .github/labeler.yml | 17 ++++++++ .github/workflows/labeler.yml | 11 +++++ .github/workflows/lint.yml | 71 ++++++++++++++++++++++++++++++++ .github/workflows/pr-check.yml | 64 ++++++++++++++++++++++++++++ .gitignore | 3 +- .mega-linter.yml | 20 +++++++++ CONTRIBUTING.md | 0 docs/.gitkeep | 0 10 files changed, 219 insertions(+), 1 deletion(-) create mode 100644 .github/CODEOWNERS create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/labeler.yml create mode 100644 .github/workflows/labeler.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/pr-check.yml create mode 100644 .mega-linter.yml create mode 100644 CONTRIBUTING.md create mode 100644 docs/.gitkeep diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000000..22c262eac5 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,20 @@ +# Apollo maintainers (Jesus Diaz Vico, Shota Jolbordi): +/apollo/ @jesusdiazvico @shotexa + +# Castor maintainers (Ilya Peresadin, Fabio Pinheiro): +/castor/ @pva701 @FabioPinheiro + +# Mercury maintainers (Fabio Pinheiro, Shailesh Patil): +/mercury/ @FabioPinheiro @mineme0110 + +# Pluto maintainers (Ilya Peresadin, Yurii Shynbuiev): +/pluto/ @pva701 @yshyn-iohk + +# Pollux maintainers (Shota Jolbordi, Yurii Shynbuiev): +/pollux/ @shotexa @yshyn-iohk + +# Github maintainer (Anton Baliasnikov): +/.github/ @antonbaliasnikov + +# Everything else will be reviewed by someone from the Atala group +* @input-output-hk/atala diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000000..4b9fb88c90 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,14 @@ +# Overview + +Fixes ATL-xxxx + +# Added features + +- [ ] +# Checklist + + +- [ ] Self-reviewed the diff +- [ ] New code has inline documentation +- [ ] New code has proper comments/tests +- [ ] Any changes not covered by tests have been tested manually \ No newline at end of file diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000000..05f725eb0b --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,17 @@ +repo: + - "*" +apollo: + - apollo/**/* +castor: + - castor/**/* +mercury: + - mercury/**/* +pluto: + - pluto/**/* +pollux: + - pollux/**/* +ci: + - .github/**/* +docs: + - docs/**/* + - README.md diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 0000000000..e998c0fe6f --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,11 @@ +name: "Pull Request Labeler" +on: + - pull_request_target + +jobs: + triage: + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v4 + with: + repo-token: "${{ secrets.ATALA_GITHUB_TOKEN }}" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000000..0bcfbb8945 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,71 @@ +name: Linter + +# Default shell is `sh` +# which is old, use bourne-again version instead +defaults: + run: + shell: bash + +on: + push: + branches: + - main + pull_request: + +jobs: + lint: + name: Lint changes + runs-on: ubuntu-latest + env: + APPLY_FIXES: all + APPLY_FIXES_EVENT: pull_request + APPLY_FIXES_MODE: commit + VALIDATE_ALL_CODEBASE: ${{ github.ref_name == 'main' }} + DISABLE: COPYPASTE,SPELL + GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} + steps: + - name: Checkout Code + uses: actions/checkout@v2 + with: + token: ${{ secrets.ATALA_GITHUB_TOKEN }} + fetch-depth: 0 + - name: Mega-Linter + id: ml + uses: megalinter/megalinter@v5 + - name: Prepare commit + if: | + (success() || failure()) && + steps.ml.outputs.has_updated_sources == 1 && + github.event_name == 'pull_request' + run: sudo chown -Rc ${UID} .git/ + - name: Import GPG key + id: import_gpg + if: | + (success() || failure()) && + steps.ml.outputs.has_updated_sources == 1 && + github.event_name == 'pull_request' + uses: crazy-max/ghaction-import-gpg@v3 + with: + gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} + git-user-signingkey: true + git-commit-gpgsign: true + - name: Commit and push applied linter fixes + if: | + (success() || failure()) && + steps.ml.outputs.has_updated_sources == 1 && + github.event_name == 'pull_request' + uses: stefanzweifel/git-auto-commit-action@v4 + with: + branch: ${{ github.event.pull_request.head.ref }} + commit_message: "[Mega-Linter] Apply linters fixes" + commit_options: "--gpg-sign" + commit_user_name: ${{ steps.import_gpg.outputs.name }} + commit_user_email: ${{ steps.import_gpg.outputs.email }} + - name: Archive production artifacts + if: success() || failure() + uses: actions/upload-artifact@v2 + with: + name: Mega-Linter reports + path: | + report + mega-linter.log diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml new file mode 100644 index 0000000000..cc9b350de1 --- /dev/null +++ b/.github/workflows/pr-check.yml @@ -0,0 +1,64 @@ +name: Check PR + +env: + # Maximum number of lines allowed to be changed in one PR + MAX_CHANGED_LINES: 500 + PR_TITLE_MAX_LENGTH: 70 + # Title must be `[ATL-1234] ...` + PR_TITLE_REGEXP: '\[\w+-\d+\] .+' + +defaults: + run: + shell: bash + +on: + pull_request: + types: [opened, edited, synchronize, reopened] + +jobs: + check-pr-title: + name: "Check PR title" + runs-on: ubuntu-latest + steps: + - uses: deepakputhraya/action-pr-title@master + name: Validate PR Title + with: + regex: ${{ env.PR_TITLE_REGEXP }} + max_length: ${{ env.PR_TITLE_MAX_LENGTH }} + github_token: ${{ secrets.ATALA_GITHUB_TOKEN }} + - uses: mshick/add-pr-comment@v1 + name: Comment on PR + if: failure() + env: + GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} + with: + message: | + Please fix the title of this PR.
+ If you don't have ATL number, you must create it.
+ Examples: + * `[ATL-1234] New feature description` + * `[ATL-1234] [HUGE] Huge new feature description (mind the space between ] and [)` + check-pr-size: + name: "Check PR size" + runs-on: ubuntu-latest + env: + TITLE: ${{ github.event.pull_request.title }} + steps: + - name: Checkout the repo + uses: actions/checkout@v2 + - name: Get diff + uses: technote-space/get-diff-action@v5 + with: + SET_ENV_NAME_LINES: LINES_CHANGED + - name: Check diff size + run: | + echo "This PR changes: ${LINES_CHANGED} lines" + if [[ ${TITLE} =~ [HUGE] ]]; then + echo "PR marked as [HUGE], skipping size check." + exit 0 + fi + if (( LINES_CHANGED > MAX_CHANGED_LINES )); then + echo "ERROR: This PR changes more than ${MAX_CHANGED_LINES} lines." + echo "Please, separate this PR to small parts. Thanks!" + exit 1 + fi diff --git a/.gitignore b/.gitignore index 723ef36f4e..ae4a5732dc 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.idea \ No newline at end of file +.idea +report \ No newline at end of file diff --git a/.mega-linter.yml b/.mega-linter.yml new file mode 100644 index 0000000000..56bc5a7d85 --- /dev/null +++ b/.mega-linter.yml @@ -0,0 +1,20 @@ +# Configuration file for Mega-Linter +# See all available variables at https://megalinter.github.io/configuration/ + +APPLY_FIXES: all +DEFAULT_BRANCH: main +DISABLE: [COPYPASTE, SPELL, CREDENTIALS] +SHOW_ELAPSED_TIME: false +FILEIO_REPORTER: false +FLAVOR_SUGGESTIONS: false +PRINT_ALPACA: false +VALIDATE_ALL_CODEBASE: false +SHOW_SKIPPED_LINTERS: false +LOG_LEVEL: INFO +# This pre-command fixes complex CLRF bug +# when MegaLinter takes changes, it checkouts code twice +# that could lead to new files in workspace created +# with CLRF instead of CL due docker/python/git chain +PRE_COMMANDS: + - command: git config --global core.autocrlf input + cwd: "workspace" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/.gitkeep b/docs/.gitkeep new file mode 100644 index 0000000000..e69de29bb2