Skip to content

Commit 4dfb131

Browse files
committed
feat: add pre-commit framework
1 parent e05aa44 commit 4dfb131

File tree

58 files changed

+1456
-785
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1456
-785
lines changed

.asf.yaml

+11-11
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ github:
1919
description: "Apache OpenWhisk is an open source serverless cloud platform"
2020
homepage: https://openwhisk.apache.org/
2121
labels:
22-
- openwhisk
23-
- apache
24-
- serverless
25-
- faas
26-
- functions-as-a-service
27-
- cloud
28-
- serverless-architectures
29-
- serverless-functions
30-
- docker
31-
- kubernetes
32-
- functions
22+
- openwhisk
23+
- apache
24+
- serverless
25+
- faas
26+
- functions-as-a-service
27+
- cloud
28+
- serverless-architectures
29+
- serverless-functions
30+
- docker
31+
- kubernetes
32+
- functions

.github/ISSUE_TEMPLATE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ output comes here
4848
```
4949

5050
## Additional information you deem important:
51-
* issue happens only occasionally or under certain circumstances
51+
* issue happens only occasionally or under certain circumstances
5252
* changes you did or observed in the environment

.github/PULL_REQUEST_TEMPLATE.md

-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,3 @@
4040
- [ ] I added tests to cover my changes.
4141
- [ ] My changes require further changes to the documentation.
4242
- [ ] I updated the documentation where necessary.
43-

.markdownlint.yaml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
MD001: false
18+
MD002: false
19+
MD003: false
20+
MD004: false
21+
MD005: false
22+
MD006: false
23+
MD007: false
24+
MD009: false
25+
MD010: false
26+
MD012: false
27+
MD013: false
28+
MD014: false
29+
MD019: false
30+
MD022: false
31+
MD023: false
32+
MD024: false
33+
MD026: false
34+
MD029: false
35+
MD030: false
36+
MD031: false
37+
MD032: false
38+
MD033: false
39+
MD034: false
40+
MD037: false
41+
MD040: false
42+
MD041: false
43+
MD042: false
44+
MD045: false
45+
MD046: false

.pre-commit-config.yaml

+198
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
default_stages: [commit, push]
18+
default_language_version:
19+
# force all unspecified Python hooks to run python3
20+
python: python3
21+
minimum_pre_commit_version: "1.20.0"
22+
repos:
23+
- repo: meta
24+
hooks:
25+
- id: identity
26+
- id: check-hooks-apply
27+
# - repo: https://github.com/thlorenz/doctoc.git
28+
# rev: v2.0.0
29+
# hooks:
30+
# - id: doctoc
31+
# name: Add TOC for Markdown files
32+
# files: ^CONTRIBUTING\.md$
33+
# args:
34+
# - "--maxlevel"
35+
# - "3"
36+
# - repo: https://github.com/asottile/dead
37+
# rev: v1.4.0
38+
# hooks:
39+
# - id: dead
40+
# name: Dead simple python dead code detection
41+
# exclude: ^tests/dat/actions/malformed\.py$
42+
- repo: https://github.com/asottile/reorder_python_imports
43+
rev: v2.4.0
44+
hooks:
45+
- id: reorder-python-imports
46+
exclude: ^tests/dat/actions/malformed\.py$
47+
- repo: https://github.com/psf/black
48+
rev: 20.8b1
49+
hooks:
50+
- id: black
51+
name: Run black on Python files
52+
exclude: ^tools/admin/wskadmin$|^tests/dat/actions/malformed\.py$
53+
# - repo: https://github.com/jumanjihouse/pre-commit-hooks
54+
# rev: 2.1.5
55+
# hooks:
56+
# - id: shellcheck
57+
- repo: git://github.com/Lucas-C/pre-commit-hooks
58+
rev: v1.1.9
59+
hooks:
60+
# - id: insert-license
61+
# name: Add license for all other files
62+
# exclude: ^\.github/.*$
63+
# args:
64+
# - --comment-style
65+
# - "|#|"
66+
# - --license-filepath
67+
# - license-templates/LICENSE.txt
68+
# - --fuzzy-match-generates-todo
69+
# files: >
70+
# \.cfg$|\.conf$|\.ini$|\.properties$|Dockerfile.*$
71+
# - id: insert-license
72+
# name: Add license for all JS/CSS files
73+
# files: \.(js|css)$
74+
# exclude: ^\.github/.*$
75+
# args:
76+
# - --comment-style
77+
# - "/*!| *| */"
78+
# - --license-filepath
79+
# - license-templates/LICENSE.txt
80+
# - --fuzzy-match-generates-todo
81+
# - id: insert-license
82+
# name: Add license for all Markdown files
83+
# files: ^README\.md$
84+
# exclude: ^\.github/.*$
85+
# args:
86+
# - --comment-style
87+
# - "<!--|| -->"
88+
# - --license-filepath
89+
# - license-templates/LICENSE.txt
90+
# - --fuzzy-match-generates-todo
91+
# - id: insert-license
92+
# name: Add license for all Shell files
93+
# exclude: ^\.github/.*$
94+
# files: \.(sh|bash)$
95+
# args:
96+
# - --comment-style
97+
# - "|#|"
98+
# - --license-filepath
99+
# - license-templates/LICENSE.txt
100+
# - --fuzzy-match-generates-todo
101+
# - id: insert-license
102+
# name: Add license for all Python files
103+
# exclude: ^\.github/.*$
104+
# types: [python]
105+
# args:
106+
# - --comment-style
107+
# - "|#|"
108+
# - --license-filepath
109+
# - license-templates/LICENSE.txt
110+
# - --fuzzy-match-generates-todo
111+
# - id: insert-license
112+
# name: Add license for all XML files
113+
# exclude: ^\.github/.*$
114+
# files: \.xml$
115+
# args:
116+
# - --comment-style
117+
# - "<!--||-->"
118+
# - --license-filepath
119+
# - license-templates/LICENSE.txt
120+
# - --fuzzy-match-generates-todo
121+
- id: insert-license
122+
name: Add license for all YAML files
123+
exclude: ^\.github/.*$
124+
types: [yaml]
125+
files: \.(yml|yaml)$
126+
args:
127+
- --comment-style
128+
- "|#|"
129+
- --license-filepath
130+
- license-templates/LICENSE.txt
131+
- --fuzzy-match-generates-todo
132+
# - id: forbid-tabs
133+
# - id: remove-tabs
134+
- repo: https://github.com/pre-commit/pre-commit-hooks
135+
rev: v3.4.0
136+
hooks:
137+
- id: check-added-large-files
138+
- id: check-ast
139+
exclude: ^tests/dat/actions/malformed\.py$
140+
- id: check-builtin-literals
141+
exclude: ^tests/dat/actions/malformed\.py$
142+
- id: check-case-conflict
143+
- id: check-docstring-first
144+
- id: check-executables-have-shebangs
145+
- id: check-json
146+
exclude: ^tests/dat/actions/invalid.*\.json$
147+
- id: check-merge-conflict
148+
- id: check-vcs-permalinks
149+
- id: check-symlinks
150+
- id: check-xml
151+
- id: check-yaml
152+
exclude: ^tests/dat/apigw/local\.api\.bad\.yaml$
153+
- id: debug-statements
154+
exclude: ^tests/dat/actions/malformed\.py$
155+
- id: destroyed-symlinks
156+
# - id: detect-private-key
157+
- id: end-of-file-fixer
158+
files: \.(bal|bat|cfg|conf|cs|gradle|ini|java|md|properties|py|scala|sh|swift|txt|yml|yaml)$|^Dockerfile$
159+
- id: fix-byte-order-marker
160+
exclude: ^tests/dat/actions/unicode\.tests/src/dotnet2\.2/openwhisk-unicodetests-dotnet\.sln$
161+
- id: fix-encoding-pragma
162+
args:
163+
- --remove
164+
- id: mixed-line-ending
165+
# - id: name-tests-test
166+
# - id: pretty-format-json
167+
- id: trailing-whitespace
168+
exclude: ^\.github/ISSUE_TEMPLATE\.md$
169+
- repo: https://github.com/pre-commit/pygrep-hooks
170+
rev: v1.8.0
171+
hooks:
172+
- id: python-check-mock-methods
173+
- id: python-no-eval
174+
- id: python-no-log-warn
175+
- repo: https://github.com/igorshubovych/markdownlint-cli
176+
rev: v0.27.1
177+
hooks:
178+
- id: markdownlint
179+
name: Run markdownlint
180+
entry: markdownlint
181+
files: \.(md|mdown|markdown)$
182+
types: [markdown]
183+
- repo: https://github.com/adrienverge/yamllint
184+
rev: v1.26.0
185+
hooks:
186+
- id: yamllint
187+
name: Check YAML files with yamllint
188+
entry: yamllint --strict .
189+
files: \.(yml|yaml)$
190+
types: [yaml]
191+
# - repo: https://github.com/PyCQA/bandit
192+
# rev: 1.7.0
193+
# hooks:
194+
# - id: bandit
195+
# - repo: https://gitlab.com/pycqa/flake8
196+
# rev: 3.8.4
197+
# hooks:
198+
# - id: flake8

.travis.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ jobs:
7373
- ./tools/travis/checkAndUploadLogs.sh unit db
7474
name: "Unit Tests"
7575
- script:
76-
- ./tools/travis/runSystemTests.sh
77-
- ./tools/travis/checkAndUploadLogs.sh system
76+
- ./tools/travis/runSystemTests.sh
77+
- ./tools/travis/checkAndUploadLogs.sh system
7878
name: "System Tests"
7979
- script:
80-
- ./tools/travis/runMultiRuntimeTests.sh
81-
- ./tools/travis/checkAndUploadLogs.sh multi-runtime
80+
- ./tools/travis/runMultiRuntimeTests.sh
81+
- ./tools/travis/checkAndUploadLogs.sh multi-runtime
8282
name: "Multi-Runtime Tests"
8383
- script:
8484
- ./tools/travis/runStandaloneTests.sh

.yamllint.yaml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
extends: default
18+
19+
ignore: |
20+
/tests/dat/apigw/local.api.yaml
21+
/tests/dat/apigw/local.api.bad.yaml
22+
23+
rules:
24+
colons: disable
25+
comments: disable
26+
comments-indentation: disable
27+
document-start: disable
28+
line-length: disable
29+
truthy: disable

CONTRIBUTING.md

+34-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
# Contributing to Apache OpenWhisk
2222

23-
Anyone can contribute to the OpenWhisk project and we welcome your contributions.
23+
Anyone can contribute to the OpenWhisk project, and we welcome your contributions.
2424

2525
There are multiple ways to contribute: report bugs, improve the docs, and
2626
contribute code, but you must follow these prerequisites and guidelines:
@@ -37,7 +37,7 @@ Instructions on how to do this can be found here:
3737
[http://www.apache.org/licenses/#clas](http://www.apache.org/licenses/#clas)
3838

3939
Sign the appropriate CLA and submit it to the Apache Software Foundation (ASF) secretary. You will receive a confirmation email from the ASF and be added to
40-
the following list: http://people.apache.org/unlistedclas.html. Once your name is on this list, you are done and your PR can be merged.
40+
the following list: http://people.apache.org/unlistedclas.html. Once your name is on this list, you are done, and your PR can be merged.
4141

4242
Project committers will use this list to verify pull requests (PRs) come from contributors that have signed a CLA.
4343

@@ -49,7 +49,7 @@ Please raise any bug reports or enhancement requests on the respective project r
4949
list to see if your issue has already been raised.
5050

5151
A good bug report is one that make it easy for us to understand what you were trying to do and what went wrong.
52-
Provide as much context as possible so we can try to recreate the issue.
52+
Provide as much context as possible, so we can try to recreate the issue.
5353

5454
A good enhancement request comes with an explanation of what you are trying to do and how that enhancement would help you.
5555

@@ -69,3 +69,34 @@ code base. Some basic rules include:
6969
- all files must have the Apache license in the header.
7070
- all PRs must have passing builds for all operating systems.
7171
- the code is correctly formatted as defined in the [Scalariform plugin properties](tools/eclipse/scala.properties). If you use IntelliJ for development this [page](https://plugins.jetbrains.com/plugin/7480-scalariform) describes the setup and configuration of the plugin.
72+
73+
#### Pre-commit
74+
75+
A framework for managing and maintaining multi-language pre-commit hooks.
76+
Pre-commit can be [installed](https://pre-commit.com/#installation) with `pip`, `curl`, `brew` or `conda`.
77+
78+
You need to first install pre-commit and then install the pre-commit hooks with `pre-commit install`.
79+
Now pre-commit will run automatically on git commit!
80+
81+
It's usually a good idea to run the hooks against all the files when adding new hooks (usually pre-commit will only run on the changed files during git hooks).
82+
Use `pre-commit run --all-files` to check all files.
83+
84+
You can run the hook with `id`: `check-hooks-apply` against all files with:
85+
86+
```
87+
pre-commit run check-hooks-apply --all-files
88+
```
89+
90+
You can update your hooks to the latest version automatically by running `pre-commit autoupdate`.
91+
92+
##### Hooks
93+
94+
The hooks run:
95+
96+
- [Black](https://github.com/psf/black) - The uncompromising [Python](https://www.python.org/) code formatter.
97+
- [markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli) - [markdownlint](https://github.com/DavidAnson/markdownlint) Command Line Interface.
98+
- [yamllint](https://github.com/adrienverge/yamllint) - A linter for [YAML](https://yaml.org/) files.
99+
100+
##### References
101+
102+
- [markdownlint Rules](https://github.com/DavidAnson/markdownlint#rules--aliases)

0 commit comments

Comments
 (0)