Skip to content

Commit

Permalink
Fix linters and disable pre-commit autoupdate (kube-burner#344)
Browse files Browse the repository at this point in the history
* Fix linters and disable autoupdate

Signed-off-by: Raul Sevilla <[email protected]>

* Fix error msg

Signed-off-by: Raul Sevilla <[email protected]>

* Remove version 1.24 from matrix

Signed-off-by: Raul Sevilla <[email protected]>

* Gen UUID before setting common_flags

Signed-off-by: Raul Sevilla <[email protected]>

* Load helpers outside from setup and setup_file

Signed-off-by: Raul Sevilla <[email protected]>

* Disable SC2086

Signed-off-by: Raul Sevilla <[email protected]>

* setup-prometheus

* Check kube-burner rc

Signed-off-by: Raul Sevilla <[email protected]>

* Improve k8s tests

Signed-off-by: Raul Sevilla <[email protected]>

---------

Signed-off-by: Raul Sevilla <[email protected]>
  • Loading branch information
rsevilla87 authored Jun 6, 2023
1 parent fe64eeb commit ba1a752
Show file tree
Hide file tree
Showing 12 changed files with 205 additions and 225 deletions.
11 changes: 0 additions & 11 deletions .github/workflows/commit.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/linters.yml

This file was deleted.

17 changes: 17 additions & 0 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,25 @@ on:
- main

jobs:
linters:
runs-on: ubuntu-latest
steps:

- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 1
persist-credentials: false

- name: Install pre-commit
run: pip install pre-commit

- name: Run pre-commit hooks
run: pre-commit run --all-files

build:
uses: ./.github/workflows/builders.yml
needs: linters
tests:
needs: build
uses: ./.github/workflows/test-k8s.yml
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test-k8s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
strategy:
matrix:
k8s-version:
- v1.24.0
- v1.25.0
- v1.26.0
- v1.27.0
Expand Down
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ $(BIN_PATH): $(SOURCES)
GOARCH=$(ARCH) CGO_ENABLED=$(CGO) go build -v -ldflags "-X $(KUBE_BURNER_VERSION).GitCommit=$(GIT_COMMIT) -X $(KUBE_BURNER_VERSION).BuildDate=$(BUILD_DATE) -X $(KUBE_BURNER_VERSION).Version=$(VERSION)" -o $(BIN_PATH) ./cmd/kube-burner

lint:
@echo -e "\n\033[2mUpdating pre-commit hooks..\033[0m"
pre-commit autoupdate
@echo "Executing pre-commit for all files"
pre-commit run --all-files
@echo "pre-commit executed."
Expand Down
79 changes: 0 additions & 79 deletions docs/development/ci/commit.md

This file was deleted.

79 changes: 77 additions & 2 deletions docs/development/ci/pullrequest.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,79 @@
The Pull Request Workflow, defined in the `pullrequest.yml` file, is triggered on push events to any branch. It has three jobs: **build**, **tests**, and **report_results**.
The Pull Request Workflow, defined in the `pullrequest.yml` file, is triggered on `pull_request_target` events to the branches `master` and `main`. It has three jobs: **linters**, **build**, **tests**, and **report_results**.

### Linters

This job performs the following steps:

1. Checks out the code
1. Installs pre-commit.
1. Runs pre-commit hooks to execute code linting based on `.pre-commit-config.yaml` file

#### Running local pre-commit

!!! info
Main purpose for pre-commit is to allow developers to pass the Lint Checks before commiting the code. Same checks will be executed on all the commits once they are pushed to GitHub

---

To install pre-commit checks locally, follow these steps:

1. Install [pre-commit](https://pre-commit.com/) by running the following command:

```console
pip install pre-commit
```

1. `ruby` is required for running the Markdown Linter, installation will depends on your Operating System, for example, on Fedora:

```console
dnf install -y ruby
```

1. Initialize pre-commit on the repo:

```console
pre-commit install
```

---

To run pre-commit manually for all files, you can use `make lint`

```console
make lint
```

Or you can run against an especific file:

```console
$ pre-commit run --files README.md
golangci-lint........................................(no files to check)Skipped
Markdownlint.............................................................Passed
```

```console
$ pre-commit run --files ./cmd/kube-burner/kube-burner.go
golangci-lint............................................................Passed
Markdownlint.........................................(no files to check)Skipped
```

```console
$ pre-commit run --all-files
golangci-lint............................................................Passed
Markdownlint.............................................................Passed
```

Pre-commit hooks can be updated using `pre-commit autoupdate`:

```console
$ pre-commit autoupdate
[WARNING] The 'rev' field of repo 'https://github.com/golangci/golangci-lint' appears to be a mutable reference (moving tag / branch). Mutable references are never updated after first install and are not supported. See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details. Hint: `pre-commit autoupdate` often fixes this.
[WARNING] The 'rev' field of repo 'https://github.com/markdownlint/markdownlint' appears to be a mutable reference (moving tag / branch). Mutable references are never updated after first install and are not supported. See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details. Hint: `pre-commit autoupdate` often fixes this.
[WARNING] The 'rev' field of repo 'https://github.com/jumanjihouse/pre-commit-hooks' appears to be a mutable reference (moving tag / branch). Mutable references are never updated after first install and are not supported. See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details. Hint: `pre-commit autoupdate` often fixes this.
[https://github.com/golangci/golangci-lint] updating master -> v1.52.2
[https://github.com/markdownlint/markdownlint] updating master -> v0.12.0
[https://github.com/jumanjihouse/pre-commit-hooks] updating master -> 3.0.0
```

### Build

Expand All @@ -17,7 +92,7 @@ The "build" job uses the file `builders.yml` file to build binaries and images,

### Report Results

The "report_results" performs the following steps:
The "report_results" job performs the following steps:

1. Checks out the code.
1. Downloads the Kubernetes and OpenShift test results artifacts.
Expand Down
16 changes: 5 additions & 11 deletions docs/development/ci/workflow-graph.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
### Commit Workflow

``` mermaid
graph LR
A[push] --> B[Linters];
```

### Pull Request Workflow

``` mermaid
```mermaid
graph LR
A[pull_request_target] --> B[builders];
B --> C[tests];
A[pull_request_target] --> B[linters];
B --> C[build];
C --> D[tests];
C --> D[report_results];
```

### Release Workflow

``` mermaid
```mermaid
graph LR
A[release] --> B[release_build];
A --> C[image-upload];
Expand Down
Loading

0 comments on commit ba1a752

Please sign in to comment.