Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
Merge pull request #48 from catenax-ng/feat/precommit-hook
Browse files Browse the repository at this point in the history
docs: how to setup tractusx quality check pre-commit hook description
  • Loading branch information
tomaszbarwicki authored Oct 3, 2023
2 parents a1cf186 + dee8b3d commit 5a44b4e
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,38 @@ are available as library to use in multiple usecases. These could be:
If you want to build the command locally, you just need Golang version 1.20 and run `go build` on the root level of
this repository.

## Git pre-commit hook

It is possible to add quality checks as git pre-commit hook in the repository which will run checks triggered by git commit command. To achieve that please follow below steps:

1. Download latest version of the tractusx-quality-checks tool for your platform under Asset section at https://github.com/eclipse-tractusx/tractusx-quality-checks/releases/latest
2. Add executable permission if necessary and copy the binary (changing file name to tractusx-quality-checks) into one of the $PATH location depending on your OS.

#### macOS example:

```
$ chmod +x tractusx-quality-checks-0.8.0-darwin-arm64
$ sudo cp tractusx-quality-checks-0.8.0-darwin-arm64 /usr/local/bin/tractusx-quality-checks
```

3. Inside your repo copy below to .git/hooks/pre-commit:

```
#!/usr/bin/env bash
# ^ Note the above "shebang" line. This says "This is an executable shell script"
# Name this script "pre-commit" and place it in the ".git/hooks/" directory
# Exit immediately with that command's exit status if the command fails
set -eo pipefail
# Run Tractus-X quality checks
tractusx-quality-checks checkLocal
echo -e "\n\n--- TRG checks passed! ---\n\n"
```

5. Make .git/hooks/pre-commit executable.
6. Pre-commit setup is complete and initiates checks each time git commit is ran.

## Custom GitHub action

The `tractusx-quality-checks` can be run as a GitHub action. This action is build as a
Expand Down

0 comments on commit 5a44b4e

Please sign in to comment.