Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
Add a git hook to run tests, and instructions. (#104)
Browse files Browse the repository at this point in the history
* Add a git hook to run tests, and instructions.

* Buildifier to fix hook.

* Remove redundant shellcheck.
  • Loading branch information
dlorenc authored Oct 25, 2017
1 parent 2edd0e4 commit af74b8a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 14 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ install:
- go get -u github.com/bazelbuild/buildifier/buildifier

script:
- find . -name "*.sh" | grep -v "third_party/" | xargs shellcheck
- make test
10 changes: 10 additions & 0 deletions CONTRIB.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Environment Setup

To build and test these images you will need to install `bazel`.

To install a pre-commit hook that will automatically run tests, run the following command:

```shell
ln -s $(pwd)/hack/hooks/* .git/hooks/
```

# How to build these base images

We use `bazel` to build most of the images in this repository, so that we can build them reproducibly.
Expand Down
17 changes: 13 additions & 4 deletions check-fmt.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
#!/bin/bash
set -ex

echo "Checking gofmt..."
files=$(gofmt -l -s ./tests)
if [[ $files ]]; then
echo "Gofmt errors in files: $files"
exit 1
fi
echo "Checking go vet..."
files=$(go vet ./tests)

echo "Checking buildifer..."
# shellcheck disable=SC2046
files=$(buildifier -mode=check $(find . -not -path "./vendor/*" -name 'BUILD' -o -name '*.bzl' -type f))
if [[ $files ]]; then
echo "Go vet errors in files: $files"
exit 1
echo "$files"
echo "Run 'buildifier -mode fix \$(find . -name BUILD -o -name '*.bzl' -type f)' to fix formatting"
exit 1
fi


echo "Checking shellcheck..."
find . -name "*.sh" | grep -v "third_party/" | xargs shellcheck
2 changes: 2 additions & 0 deletions hack/hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
make test
18 changes: 9 additions & 9 deletions reproducible/ubuntu/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ UBUNTU_ENV = {

NODEJS_ENV = {
"PORT": "8080",
"NODE_ENV": "production"
"NODE_ENV": "production",
}

docker_build(
Expand Down Expand Up @@ -39,9 +39,9 @@ docker_build(
base = "//reproducible/ubuntu:ubuntu",
env = NODEJS_ENV,
ports = ["8080"],
tars =[
"//reproducible/ubuntu:nodejs"
]
tars = [
"//reproducible/ubuntu:nodejs",
],
)

# nodejs_ubuntu_build is a docker image that is a nodejs install compiled from
Expand All @@ -50,9 +50,9 @@ docker_build(
name = "nodejs_ubuntu_build",
base = ":ubuntu_build",
env = NODEJS_ENV,
tars =[
"//reproducible/ubuntu:nodejs"
]
tars = [
"//reproducible/ubuntu:nodejs",
],
)

# nodejs_builder is a docker image that is capable of building nodejs running
Expand All @@ -65,6 +65,6 @@ docker_build(
],
files = [
":mknodeimage.sh",
"@nodejs_tar_download//file"
],
"@nodejs_tar_download//file",
],
)

0 comments on commit af74b8a

Please sign in to comment.