From dcb6b51d5fb4ccc2624fae1f42b39d0a41ce7f3a Mon Sep 17 00:00:00 2001
From: davidpoltorak-io <109518299+davidpoltorak-io@users.noreply.github.com>
Date: Fri, 13 Jan 2023 14:50:35 +0000
Subject: [PATCH] ci(shared): enable megalinter checks on pullrequests (#300)
* ci(shared): enable megalinter checks on pullrequests
* ci(shared): updated contribution guidelines with CI checks
* ci(shared): fix mega-linter report path for artefact upload
* ci(shared): fix linting issues for modified files in pr
* ci(shared): added language to fenced code blocks
* ci(shared): added documentation about running mega-linter locally
* ci(shared): fix table formatting
---
.github/workflows/lint.yml | 10 ++---
.gitignore | 2 +-
.pre-commit-config.yaml | 20 +++++++---
CONTRIBUTING.md | 77 ++++++++++++++++++++++----------------
4 files changed, 65 insertions(+), 44 deletions(-)
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 5534834cb5..b5dd477960 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -1,3 +1,4 @@
+---
name: Linter
# Default shell is `sh`
@@ -7,17 +8,14 @@ defaults:
shell: bash
on:
- push:
- branches:
- - fixme
- # pull_request:
+ pull_request:
jobs:
lint:
name: Lint changes
runs-on: ubuntu-latest
env:
- APPLY_FIXES: all
+ APPLY_FIXES: none
APPLY_FIXES_EVENT: pull_request
APPLY_FIXES_MODE: commit
VALIDATE_ALL_CODEBASE: ${{ github.ref_name == 'main' }}
@@ -38,5 +36,5 @@ jobs:
with:
name: Mega-Linter reports
path: |
- report
+ megalinter-reports
mega-linter.log
diff --git a/.gitignore b/.gitignore
index 9718a056d4..8ec36ee463 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,6 @@
.idea
report
-megalinter-reports
+megalinter-reports/
.vscode
.bloop
.bsp
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index d2e7b45364..a050287cdb 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,14 +1,24 @@
+---
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- - id: trailing-whitespace
- - id: end-of-file-fixer
- - id: check-added-large-files
+ - id: trailing-whitespace
+ - id: end-of-file-fixer
+ - id: check-added-large-files
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v1.4.0
hooks:
- - id: conventional-pre-commit
- stages: [commit-msg]
+ - id: conventional-pre-commit
+ stages: [commit-msg]
+ - repo: https://github.com/oxsecurity/megalinter
+ rev: v6.8.0 # Git tag specifying the hook, not mega-linter-runner, version
+ hooks:
+ - id: megalinter-incremental # Faster, less thorough
+ stages:
+ - commit
+ - id: megalinter-full # Slower, more thorough
+ stages:
+ - push
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 4acf47875d..02b8c6f4e2 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -3,19 +3,19 @@
We would love for you to contribute to Atala PRISM and help make it even better than it is today!
As a contributor, here are the guidelines we would like you to follow:
- - [Pull Requests](#pr)
- - [Commit Message Guidelines](#commit)
- - [Release process](#release)
- - Software development lifecycle (TBD)
+- [Pull Requests](#pull-requests)
+- [Commit Message Guidelines](#commits)
+- [Release process](#releases)
+- Software development lifecycle (TBD)
-## Pull Requests
+## Pull Requests
-### Submitting a Pull Request
+### Submitting a Pull Request
**All code changes to the `main` branch must go through Pull Requests (PRs)**
-To create a Pull Request, follow the [official GitHub PR guidelines](#pr_guidelines).
+To create a Pull Request, follow the [Official GitHub PR guidelines](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request)
> Use `Create draft pull Request` option to create work-in-progress (WIP) PRs.
> Remove draft state when PR is ready for review.
@@ -29,7 +29,7 @@ Otherwise, break the PR into several ones.
Pull Requests are expected to be named like `[ATL-XXXX]: short description` (ticket id as prefix with a short but understandable description).
-> Please note, PR title should not be a part of the `main` branch commit history. All commits in `main` should correspond to the [Commit Message Guidelines](#commit).
+> Please note, PR title should not be a part of the `main` branch commit history. All commits in `main` should correspond to the [Commit Message Guidelines](#commits).
### Pull Request checklist
@@ -37,6 +37,23 @@ All Pull Requests will get a checklist that everyone is expected to follow, fail
Check the [PR checklist](.github/PULL_REQUEST_TEMPLATE.md) for more info.
+### Pull request CI checks
+
+All pull requests will be subject to the following checks and actions:
+
+| Name | Type | Description |
+|-----------------------|--------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| Linter | Check | Powered by megalinter - any changed source will be checked against configured linting rules (configured in .mega-linter.yml at root of repository). No automatic fixes will be generated. If the check fails, the author of the pull request must fix issues and update pull request. |
+| Pull request labeller | Action | Pull Request will be labelled based upon directory structure |
+
+Linting is also available as part of the pre-commit hooks, this will follow the same rules as the CI checks in that it will not automatically fix linting issues.
+
+> You must run `pre-commit install` to install these hooks once you have cloned the repository. Instructions can be found [here](https://pre-commit.com/#usage)
+
+In order to automatically fix linting issues, you must install and run the megalinter tool yourself. Instructions for running locally can be found [here](https://megalinter.io/latest/mega-linter-runner/)
+
+Use `npx mega-linter-runner --fix` after installation to fix any detected local issues
+
### Pull Request review
The team `input-output-hk/atala` will be automatically set as reviewer when the PR is created, so that 2 reviewers from the team get assigned.
@@ -63,7 +80,7 @@ Once the Pull Request is ready to be merged, you will have 2 options:
`Squash and Merge` feature from Github combines all the PR commits into a single one.
-You are expected to review the auto-generated message and update it as necessary to get a decent commit message that fully corresponds to the [Commit Message Guidelines](#commit).
+You are expected to review the auto-generated message and update it as necessary to get a decent commit message that fully corresponds to the [Commit Message Guidelines](#commits).
Use this option when all commits you made in the PR can be combined into one.
@@ -73,11 +90,11 @@ If this is not the case, use `Rebase and Merge` option.
`Rebase and Merge` feature from Github attached all commits from the PR branch on top of the base branch.
-You are expected to make sure that **all the commits** in the PR are corresponding to the [Commit Message Guidelines](#commit).
+You are expected to make sure that **all the commits** in the PR are corresponding to the [Commit Message Guidelines](#commits).
Use this option when the update you're working on contains several commits that should be merged to the `main` branch of the repository.
-## Commits
+## Commits
The following general rules are applied to all commits:
@@ -91,11 +108,11 @@ The following general rules are applied to all commits:
We have very precise rules over how our Git commit messages must be formatted.
This format leads to **easier to read commit history**.
-This format is based on the [Conventional Commits Specification](conventional-commits).
+This format is based on the [Conventional Commits Specification](https://www.conventionalcommits.org/en/v1.0.0/#summary).
Each commit message consists of a mandatory **header**, an optional **body**, and an optional **footer**.
-```
+```text
@@ -103,16 +120,16 @@ Each commit message consists of a mandatory **header**, an optional **body**, an