Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use mage commands in CI instead of pre-commit #355

Merged
merged 5 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/go-ftw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ jobs:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
with:
lfs: true
fetch-depth: 0 #for better blame info
cache: true
- name: Start httpbin
run: docker run -p 8080:80 -d kennethreitz/httpbin
- name: Setup CRS
Expand Down
19 changes: 6 additions & 13 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
name: lint (pre-commit)
name: lint

on:
pull_request:
push:
jobs:
pre-commit:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: v1.18.x
- name: Install dependencies
run: |
cd /tmp && go install github.com/go-critic/go-critic/cmd/gocritic@latest
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.46.2
go install golang.org/x/lint/golint@latest
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/[email protected]
with:
extra_args: --all-files
cache: true
- run: go run mage.go lint
14 changes: 5 additions & 9 deletions .github/workflows/regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,15 @@ jobs:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
with:
lfs: true
fetch-depth: 0 #for better blame info
- name: Download vendored dependencies
run: go mod vendor
cache: true
- name: Tests and coverage
run: go test -v -coverpkg=./... -coverprofile=coverage-waf.out ./...
run: go run mage.go coverage
- name: SonarCloud Scan
if: ${{ matrix.go-version == '1.17.x' && github.event.pull_request.head.repo.full_name == github.repository }}
uses: sonarsource/sonarcloud-github-action@master
Expand Down
26 changes: 0 additions & 26 deletions .github/workflows/tinygo.yml

This file was deleted.

3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ linters:
- govet
- ineffassign
- staticcheck
- structcheck
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not supported on Go 1.18+

- typecheck
- unused
- varcheck
# Enabled by coraza
- goimports
- gofmt
- gocritic
- gocritic
7 changes: 0 additions & 7 deletions .pre-commit-config.yaml

This file was deleted.

10 changes: 6 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Did you write a patch that fixes a bug?

* Open a new GitHub pull request which includes your changes.
* Please include a description which clearly describes the change. Include the relevant issue number if applicable.
* We use the [pre-commit](https://pre-commit.com/) framework to perform quality tests before sending them for review. It is recommended you [install](https://pre-commit.com/#install) it and use it before sending any patches.
* You may consider installing a pre-commit hook to automatically run required checks with `go run mage.go precommit`

## Enhancements

Expand All @@ -63,12 +63,14 @@ Do you have questions about the source code? Ask any question about how to use C

Coraza uses Go's built-in test tool. Examples (run from the repository root):

- `go test -v`
- `go test -v` or `go run mage.go test`
- `go test -v -race ` use to enable the built-in data race detector
- `go test -run TestDefaultWriters -v ./loggers` run all tests loggers package with name substring `TestDefaultWriters`

- `pre-commit run --all-files` run tests using pre-commit
- `pre-commit install` install the pre-commit git hook
- `go run mage.go lint` run code style checks
- `go run mage.go check` run tests and code style checks

- `go run mage.go precommit` install the pre-commit git hook

_________________

Expand Down