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

[RFC] Add a "go-unit-tests" hook #3

Open
cshamrick opened this issue Apr 13, 2021 · 2 comments
Open

[RFC] Add a "go-unit-tests" hook #3

cshamrick opened this issue Apr 13, 2021 · 2 comments
Labels
question Further information is requested

Comments

@cshamrick
Copy link
Member

Adding this RFC on behalf of @jduclos-bellese - we'd like to get feedback about whether we could add a go-unit-tests hook to this project. We could implement the hook similar to the go-unit-tests hook found in dnephin/pre-commit-golang, which executes a bash script like this:

#!/usr/bin/env bash
FILES=$(go list ./...  | grep -v /vendor/)

go test -tags=unit -timeout 30s -short -v ${FILES}

returncode=$?
if [ $returncode -ne 0 ]; then
  echo "unit tests failed"
  exit 1
fi
@cshamrick cshamrick added the question Further information is requested label Apr 13, 2021
@cshamrick cshamrick assigned phillipjf and unassigned phillipjf Apr 13, 2021
@phillipjf
Copy link
Contributor

This example script is pretty opinionated. We should decide if it's the opinion we want to enforce or if there's a better way to allow configuration on how to run tests. There's only a few issues on the original project but one already asks for a different way to do tests: dnephin/pre-commit-golang#49

This suggests all tests to be tagged unit via Build Constraints. What if a project does not tag their tests? Or already uses another tag for managing tests?

If there really is a good "standard" for tests, we could drive towards that but I think, generally, any implementation may end up being too opinionated, and therefore, unused.

@cshamrick
Copy link
Member Author

@phillipjf would it be of value to implement a generic, configurable/overridable solution for this? e.g.:

The default just runs tests without tags, etc.:

repos:
 - repo: git://github.com/bellese/pre-commit-golang
   rev: master
   hooks:
     - id: go-unit-tests

Or with -tags and -timeout:

repos:
 - repo: git://github.com/bellese/pre-commit-golang
   rev: master
   hooks:
     - id: go-unit-tests
       args: [-tags=unit, -timeout=30s]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants