Skip to content

Commit 515a939

Browse files
authoredFeb 8, 2020
Clean-up of the docker tools for local dev. (#1028)
* Clean-up of the docker tools for local dev. * Fix github action indentation.
1 parent 5319144 commit 515a939

File tree

7 files changed

+25
-40
lines changed

7 files changed

+25
-40
lines changed
 

‎.github/workflows/ci_test.yml

+2
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ jobs:
147147
- uses: actions/checkout@v1
148148
- name: Checking the sanity check
149149
run: bash tools/run_sanity_check.sh
150+
- name: Checking the pre-commit
151+
run: bash tools/pre-commit.sh
150152
docs_tests:
151153
name: Check that we can build the docs
152154
runs-on: ubuntu-latest

‎CONTRIBUTING.md

+21-4
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,35 @@ us**
5454
## Development Tips
5555
Try these useful commands below:
5656

57-
* Format code automatically: `bash tools/run_docker.sh -c 'make code-format'`
57+
* Format code automatically: `bash tools/pre-commit.sh`
5858
* Run sanity check: `bash tools/run_sanity_check.sh`
5959
* Run CPU unit tests: `bash tools/run_docker.sh -c 'make unit-test'`
6060
* Run GPU unit tests: `bash tools/run_docker.sh -d gpu -c 'make gpu-unit-test'`
6161
* All of the above: `bash tools/run_docker.sh -d gpu -c 'make'`
6262

6363
## Coding style
6464

65-
Addons provides `make code-format` command to format your changes
66-
automatically, don't forget to use it before pushing your code.
65+
We provide a pre-commit hook to format your code automatically before each
66+
commit, so that you don't have to read our style guide. Install it with
6767

68-
Please see our [Style Guide](STYLE_GUIDE.md) for more details.
68+
```
69+
cd .git/hooks && ln -s -f ../../tools/pre-commit.sh pre-commit
70+
```
71+
72+
and you're good to go.
73+
74+
Note that this pre-commit needs Docker to run.
75+
If you have docker 19.03+, it uses
76+
[Docker buildkit](https://docs.docker.com/develop/develop-images/build_enhancements/)
77+
to make the build step much faster.
78+
79+
80+
It should also work on
81+
Windows (with [Docker desktop for Windows](https://docs.docker.com/docker-for-windows/install/),
82+
select "Run linux containers").
83+
But this has not been tested. If you work on Windows, we'd be happy to have your feedback!
84+
85+
See our [Style Guide](STYLE_GUIDE.md) for more details.
6986

7087
## Code Testing
7188
### CI Testing

‎STYLE_GUIDE.md

-7
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ format all with:
2727
clang-format-9 -i --style=google **/*.cc **/*.h
2828
```
2929

30-
We'll soon provide a simple and easy to use docker image to run this.
31-
3230
#### Python
3331

3432
Addons uses [flake8](http://flake8.pycqa.org/en/latest/) to check pep8 compliance and
@@ -49,11 +47,6 @@ python -m black ./
4947
python -m flake8
5048
```
5149

52-
If you want those tools to run automatically before each commit, run:
53-
```bash
54-
cd .git/hooks && ln -s -f ../../tools/pre-commit.sh pre-commit
55-
```
56-
5750
#### TensorFlow Conventions
5851

5952
Follow the guidance in the [TensorFlow Style Guide - Conventions](https://www.tensorflow.org/community/contribute/code_style#tensorflow_conventions_and_special_uses).

‎makefile

+1-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,7 @@
1414
# ==============================================================================
1515
.PHONY: all
1616

17-
all: code-format sanity-check unit-test
18-
19-
install-ci-dependency:
20-
bash tools/ci_build/install/install_ci_dependency.sh
21-
22-
code-format:
23-
bash tools/pre-commit.sh
17+
all: unit-test
2418

2519
unit-test:
2620
bash tools/ci_testing/addons_cpu.sh

‎tools/ci_build/install/install_ci_dependency.sh

-21
This file was deleted.
File renamed without changes.

‎tools/pre-commit.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
set -e
44

55
export DOCKER_BUILDKIT=1
6-
docker build -t tf_addons_formatting -f tools/docker/Dockerfile_formatting .
6+
docker build -t tf_addons_formatting -f tools/docker/formatting.Dockerfile .
77
docker run --rm -t -v "$(pwd -P):/addons" tf_addons_formatting

0 commit comments

Comments
 (0)
Please sign in to comment.