Skip to content

Commit 91a6827

Browse files
committed
rust-test: init
1 parent cdc9a80 commit 91a6827

3 files changed

Lines changed: 59 additions & 37 deletions

File tree

.pre-commit-hooks.yaml

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,3 @@
1-
- id: go-test
2-
name: 'Go tests'
3-
entry: run-go-test.sh
4-
types: [go]
5-
language: 'script'
6-
pass_filenames: false
7-
minimum_pre_commit_version: 0.15.0
8-
description: "Runs `go test ./...` at the repo root"
9-
10-
- id: goimports
11-
name: 'Check Go imports'
12-
entry: run-go-imports.sh
13-
types: [go]
14-
language: 'script'
15-
pass_filenames: true
16-
minimum_pre_commit_version: 0.15.0
17-
description: "Runs `goimports` on changed files"
18-
require_serial: true
19-
exclude: 'vendor/'
20-
21-
- id: go-dep-check
22-
name: 'dep-check'
23-
entry: run-dep-check.sh
24-
types: [go]
25-
language: 'script'
26-
pass_filenames: false
27-
minimum_pre_commit_version: 0.15.0
28-
description: "Runs `dep check`, ensuring all imports are vendored"
29-
301
- id: todo-tagged-jira
312
name: 'TODOs have JIRA tags'
323
entry: todo-jira-check.py
@@ -47,19 +18,48 @@
4718
description: 'Prints any TODOs tagged with the ticket reference in the current branch name'
4819

4920
- id: branch-name-check
50-
name: 'Checks branch name obeys the standardised format'
21+
name: 'Branch name obeys the standardised format'
5122
entry: run-branch-name-check.sh
5223
always_run: true
5324
pass_filenames: false
5425
language: 'script'
5526
minimum_pre_commit_version: 0.15.0
5627
description: 'Checks branch names obeys the following regex'
5728

29+
- id: go-test
30+
name: 'Go tests'
31+
entry: run-go-test.sh
32+
types: [go]
33+
language: 'script'
34+
pass_filenames: false
35+
minimum_pre_commit_version: 0.15.0
36+
description: "Runs `go test ./...` at the repo root"
37+
38+
- id: go-goimports
39+
name: 'Check Go imports'
40+
entry: run-go-imports.sh
41+
types: [go]
42+
language: 'script'
43+
pass_filenames: true
44+
minimum_pre_commit_version: 0.15.0
45+
description: "Runs `goimports` on changed files"
46+
require_serial: true
47+
exclude: 'vendor/'
48+
49+
- id: go-dep-check
50+
name: 'Dependencies are vendored (dep)'
51+
entry: run-dep-check.sh
52+
types: [go]
53+
language: 'script'
54+
pass_filenames: false
55+
minimum_pre_commit_version: 0.15.0
56+
description: "Runs `dep check`, ensuring all imports are vendored"
57+
5858
# A copy of
5959
# https://github.com/golangci/golangci-lint/commit/09677d574ea6cd05141022aa90b88b6598bfa1a1
6060
# without --fix forced on users.
61-
- id: golangci-lint
62-
name: golangci-lint
61+
- id: go-golangci-lint
62+
name: 'Run golangci-lint'
6363
description: Static analysis for Go code
6464
entry: golangci-lint run
6565
types: [go]
@@ -75,6 +75,15 @@
7575
minimum_pre_commit_version: 0.15.0
7676
description: 'Run clippy lints against rust code'
7777

78+
- id: rust-test
79+
name: 'Cargo tests'
80+
entry: run-rust-tests.sh
81+
language: 'script'
82+
files: \.rs$
83+
pass_filenames: false
84+
minimum_pre_commit_version: 0.15.0
85+
description: 'Run cargo test in the repo root'
86+
7887
- id: r-stylr
7988
name: 'Format with stylr'
8089
entry: run-r-stylr.R

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
# pre-commit
22

3-
This is a set of [`pre-commit`] hooks for (primarily Go) development.
3+
This is a set of [`pre-commit`] hooks for development across multiple languages.
44

55
Hooks:
66
* `todo-tagged-jira`: ensure all TODO comments reference a JIRA ticket
77
* `todo-branch-tags`: show all TODOs tagged with the ticket reference in the branch name
88
* `branch-name-check`: checks branch names adhere to the regex `^(feature|bugfix|release|hotfix)\/.+`
99
* `go-test`: runs `go test ./...` at the repo root
1010
* `go-dep-check`: ensure all your 3rd party Go packages are vendored (see [dep])
11-
* `goimports`: ensure all the Go imports are included and ordered
12-
* `golangci-lint`: a copy of the [official lint
11+
* `go-goimports`: ensure all the Go imports are included and ordered
12+
* `go-golangci-lint`: a copy of the [official lint
1313
config](https://github.com/golangci/golangci-lint/commit/09677d574ea6cd05141022aa90b88b6598bfa1a1)
1414
without forcing the `--fix` argument
1515
* `rust-clippy`: runs `cargo clippy` lints in the repo root
16+
* `rust-test`: runs `cargo test` at the repo root, includes all targets/features/examples/benches
1617
* `r-stylr`: runs [`stylr`] to format R code
1718
* `r-lintr`: static analysis of R code with [`lintr`]
1819

@@ -40,7 +41,7 @@ repos:
4041
exclude: \.pb.go$ # Ignore generated protobuf files
4142
args: ["-timeout=30s"] # Set a deadline (fast tests == happy developers)
4243

43-
- id: goimports
44+
- id: go-goimports
4445
stages: [commit, push, manual]
4546
types: [go]
4647
exclude: \.pb.go$ # Ignore generated protobuf files
@@ -50,13 +51,20 @@ repos:
5051
stages: [push, manual]
5152
types: [go]
5253

53-
- id: golangci-lint
54+
- id: go-golangci-lint
5455
args: [--new-from-rev=origin/master]
5556
stages: [commit, push]
5657
types: [go]
5758
exclude: \.pb.go$
5859

5960
- id: rust-clippy
61+
#args: [ # Optionally override default configured lints
62+
# "-D rust_2018_idioms",
63+
# "-D missing_docs",
64+
#]
65+
stages: [commit, push]
66+
67+
- id: rust-test
6068
stages: [commit, push]
6169

6270
- id: r-stylr

run-rust-tests.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
cargo test --all-features --all --bins --tests --examples --benches --all-targets "$@"

0 commit comments

Comments
 (0)