Skip to content

Commit

Permalink
Merge pull request #483 from cbosdo/pre-commit
Browse files Browse the repository at this point in the history
Add pre-commit and pre-push hooks
  • Loading branch information
cbosdo authored Nov 6, 2024
2 parents bf16c7a + b210bd9 commit 7e8cd00
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 1 deletion.
54 changes: 54 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# SPDX-FileCopyrightText: 2024 SUSE LLC
#
# SPDX-License-Identifier: Apache-2.0
#
# 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: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/golangci/golangci-lint
rev: v1.59.1
hooks:
- id: golangci-lint

- repo: https://github.com/fsfe/reuse-tool
rev: v4.0.3
hooks:
- id: reuse

- repo: https://github.com/cbosdo/gettext-go-lint
rev: gettext-go-lint-0.1.1-0
hooks:
- id: lint
args:
- --keyword=L,NL,PL

- repo: local
hooks:
- id: check-localizable
name: Check localizable strings
entry: ./check_localizable
files: '.*\.go'
language: script
- id: build
name: Build
pass_filenames: false
entry: ./pre-commit-build.sh
language: script
stages:
- pre-push
- id: build-all-tags
name: Build with all tags
pass_filenames: false
entry: ./pre-commit-build.sh
language: script
args:
- -tags=nok8s,ptf
stages:
- pre-push
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
SPDX-FileCopyrightText: 2023 SUSE LLC
SPDX-FileCopyrightText: 2023-2024 SUSE LLC
SPDX-License-Identifier: Apache-2.0
-->
Expand Down Expand Up @@ -54,6 +54,22 @@ https://github.com/uyuni-project/uyuni/tree/master/containers/doc/server-kuberne

# Development documentation

## Install pre-commit hooks

[pre-commit](https://pre-commit.com) helps validating the code before submitting it. Please install the hooks on your machine to enable them:

```
zypper in python3.XX-pre-commit
./install-hooks.sh
```

There are two kind of hooks used in this project:

* `pre-commit` ones are fast checks that are running on each commit.
* `pre-push` ones are the lengthier ones like builds and unit tests and are only executed when pushing to a remote branch.

The hooks can also all be run manually at any time with `pre-commit run -a`.

## Sign your Git commits

Signing commits with a GPG/SSH key is mandatory for contributing. That way your commits will be marked as verified on GitHub so other people can be confident that the changes come from a trusted source.
Expand Down
5 changes: 5 additions & 0 deletions install-hooks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
# SPDX-FileCopyrightText: 2024 SUSE LLC
#
# SPDX-License-Identifier: Apache-2.0
pre-commit install --hook-type pre-commit --hook-type pre-push
6 changes: 6 additions & 0 deletions pre-commit-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
# SPDX-FileCopyrightText: 2024 SUSE LLC
#
# SPDX-License-Identifier: Apache-2.0
go build $* ./...
go test $* ./...

0 comments on commit 7e8cd00

Please sign in to comment.