Skip to content

Commit

Permalink
feat: add pre-commit framework
Browse files Browse the repository at this point in the history
  • Loading branch information
jbampton committed Mar 14, 2021
1 parent 659b762 commit 99d6e86
Show file tree
Hide file tree
Showing 57 changed files with 1,373 additions and 754 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ output comes here
```

## Additional information you deem important:
* issue happens only occasionally or under certain circumstances
* issue happens only occasionally or under certain circumstances
* changes you did or observed in the environment
1 change: 0 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@
- [ ] I added tests to cover my changes.
- [ ] My changes require further changes to the documentation.
- [ ] I updated the documentation where necessary.

45 changes: 45 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

MD001: false
MD002: false
MD003: false
MD004: false
MD005: false
MD006: false
MD007: false
MD009: false
MD010: false
MD012: false
MD013: false
MD014: false
MD019: false
MD022: false
MD023: false
MD024: false
MD026: false
MD029: false
MD030: false
MD031: false
MD032: false
MD033: false
MD034: false
MD037: false
MD040: false
MD041: false
MD042: false
MD045: false
MD046: false
198 changes: 198 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

default_stages: [commit, push]
default_language_version:
# force all unspecified Python hooks to run python3
python: python3
minimum_pre_commit_version: "1.20.0"
repos:
- repo: meta
hooks:
- id: identity
- id: check-hooks-apply
# - repo: https://github.com/thlorenz/doctoc.git
# rev: v2.0.0
# hooks:
# - id: doctoc
# name: Add TOC for Markdown files
# files: ^CONTRIBUTING\.md$
# args:
# - "--maxlevel"
# - "3"
# - repo: https://github.com/asottile/dead
# rev: v1.4.0
# hooks:
# - id: dead
# name: Dead simple python dead code detection
# exclude: ^tests/dat/actions/malformed\.py$
- repo: https://github.com/asottile/reorder_python_imports
rev: v2.4.0
hooks:
- id: reorder-python-imports
exclude: ^tests/dat/actions/malformed\.py$
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
name: Run black on Python files
exclude: ^tools/admin/wskadmin$|^tests/dat/actions/malformed\.py$
# - repo: https://github.com/jumanjihouse/pre-commit-hooks
# rev: 2.1.5
# hooks:
# - id: shellcheck
- repo: git://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.9
hooks:
# - id: insert-license
# name: Add license for all other files
# exclude: ^\.github/.*$
# args:
# - --comment-style
# - "|#|"
# - --license-filepath
# - license-templates/LICENSE.txt
# - --fuzzy-match-generates-todo
# files: >
# \.cfg$|\.conf$|\.ini$|\.properties$|Dockerfile.*$
# - id: insert-license
# name: Add license for all JS/CSS files
# files: \.(js|css)$
# exclude: ^\.github/.*$
# args:
# - --comment-style
# - "/*!| *| */"
# - --license-filepath
# - license-templates/LICENSE.txt
# - --fuzzy-match-generates-todo
# - id: insert-license
# name: Add license for all Markdown files
# files: ^README\.md$
# exclude: ^\.github/.*$
# args:
# - --comment-style
# - "<!--|| -->"
# - --license-filepath
# - license-templates/LICENSE.txt
# - --fuzzy-match-generates-todo
# - id: insert-license
# name: Add license for all Shell files
# exclude: ^\.github/.*$
# files: \.(sh|bash)$
# args:
# - --comment-style
# - "|#|"
# - --license-filepath
# - license-templates/LICENSE.txt
# - --fuzzy-match-generates-todo
# - id: insert-license
# name: Add license for all Python files
# exclude: ^\.github/.*$
# types: [python]
# args:
# - --comment-style
# - "|#|"
# - --license-filepath
# - license-templates/LICENSE.txt
# - --fuzzy-match-generates-todo
# - id: insert-license
# name: Add license for all XML files
# exclude: ^\.github/.*$
# files: \.xml$
# args:
# - --comment-style
# - "<!--||-->"
# - --license-filepath
# - license-templates/LICENSE.txt
# - --fuzzy-match-generates-todo
- id: insert-license
name: Add license for all YAML files
exclude: ^\.github/.*$
types: [yaml]
files: \.(yml|yaml)$
args:
- --comment-style
- "|#|"
- --license-filepath
- license-templates/LICENSE.txt
- --fuzzy-match-generates-todo
# - id: forbid-tabs
# - id: remove-tabs
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: check-added-large-files
- id: check-ast
exclude: ^tests/dat/actions/malformed\.py$
- id: check-builtin-literals
exclude: ^tests/dat/actions/malformed\.py$
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-json
exclude: ^tests/dat/actions/invalid.*\.json$
- id: check-merge-conflict
- id: check-vcs-permalinks
- id: check-symlinks
- id: check-xml
- id: check-yaml
exclude: ^tests/dat/apigw/local\.api\.bad\.yaml$
- id: debug-statements
exclude: ^tests/dat/actions/malformed\.py$
- id: destroyed-symlinks
# - id: detect-private-key
- id: end-of-file-fixer
files: \.(bal|bat|cfg|conf|cs|gradle|ini|java|md|properties|py|scala|sh|swift|txt|yml|yaml)$|^Dockerfile$
- id: fix-byte-order-marker
exclude: ^tests/dat/actions/unicode\.tests/src/dotnet2\.2/openwhisk-unicodetests-dotnet\.sln$
- id: fix-encoding-pragma
args:
- --remove
- id: mixed-line-ending
# - id: name-tests-test
# - id: pretty-format-json
- id: trailing-whitespace
exclude: ^\.github/ISSUE_TEMPLATE\.md$
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.8.0
hooks:
- id: python-check-mock-methods
- id: python-no-eval
- id: python-no-log-warn
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.27.1
hooks:
- id: markdownlint
name: Run markdownlint
entry: markdownlint
files: \.(md|mdown|markdown)$
types: [markdown]
- repo: https://github.com/adrienverge/yamllint
rev: v1.26.0
hooks:
- id: yamllint
name: Check YAML files with yamllint
entry: yamllint --strict .
files: \.(yml|yaml)$
types: [yaml]
# - repo: https://github.com/PyCQA/bandit
# rev: 1.7.0
# hooks:
# - id: bandit
# - repo: https://gitlab.com/pycqa/flake8
# rev: 3.8.4
# hooks:
# - id: flake8
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ jobs:
- ./tools/travis/checkAndUploadLogs.sh unit db
name: "Unit Tests"
- script:
- ./tools/travis/runSystemTests.sh
- ./tools/travis/checkAndUploadLogs.sh system
- ./tools/travis/runSystemTests.sh
- ./tools/travis/checkAndUploadLogs.sh system
name: "System Tests"
- script:
- ./tools/travis/runMultiRuntimeTests.sh
- ./tools/travis/checkAndUploadLogs.sh multi-runtime
- ./tools/travis/runMultiRuntimeTests.sh
- ./tools/travis/checkAndUploadLogs.sh multi-runtime
name: "Multi-Runtime Tests"
- script:
- ./tools/travis/runStandaloneTests.sh
Expand Down
29 changes: 29 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

extends: default

ignore: |
/tests/dat/apigw/local.api.yaml
/tests/dat/apigw/local.api.bad.yaml
rules:
colons: disable
comments: disable
comments-indentation: disable
document-start: disable
line-length: disable
truthy: disable
37 changes: 34 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

# Contributing to Apache OpenWhisk

Anyone can contribute to the OpenWhisk project and we welcome your contributions.
Anyone can contribute to the OpenWhisk project, and we welcome your contributions.

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

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
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.
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.

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

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

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

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

Expand All @@ -69,3 +69,34 @@ code base. Some basic rules include:
- all files must have the Apache license in the header.
- all PRs must have passing builds for all operating systems.
- 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.

#### Pre-commit

A framework for managing and maintaining multi-language pre-commit hooks.
Pre-commit can be [installed](https://pre-commit.com/#installation) with `pip`, `curl`, `brew` or `conda`.

You need to first install pre-commit and then install the pre-commit hooks with `pre-commit install`.
Now pre-commit will run automatically on git commit!

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).
Use `pre-commit run --all-files` to check all files.

You can run the hook with `id`: `check-hooks-apply` against all files with:

```
pre-commit run check-hooks-apply --all-files
```

You can update your hooks to the latest version automatically by running `pre-commit autoupdate`.

##### Hooks

The hooks run:

- [Black](https://github.com/psf/black) - The uncompromising [Python](https://www.python.org/) code formatter.
- [markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli) - [markdownlint](https://github.com/DavidAnson/markdownlint) Command Line Interface.
- [yamllint](https://github.com/adrienverge/yamllint) - A linter for [YAML](https://yaml.org/) files.

##### References

- [markdownlint Rules](https://github.com/DavidAnson/markdownlint#rules--aliases)
6 changes: 3 additions & 3 deletions CREDITS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ the initial donation:
* JavaScript (JS) client library for the OpenWhisk platform.
* openwhisk-client-swift:
* Swift-based client SDK for OpenWhisk compatible with Swift 2.x and runs on iOS 9, WatchOS 2, and Darwin.
* openwhisk-sdk-docker:
* openwhisk-sdk-docker:
* SDK that shows how to create “Black box” Docker containers that can run Action (code).
* openwhisk-client-go:
* API Framework written in GoLang (in-progress)
Expand Down Expand Up @@ -56,7 +56,7 @@ the initial donation:
* Collection of OpenWhisk tools for OS X implemented in Swift 3.
* openwhisk-debugger
* The OpenWhisk debugger project
* openwhisk-podspecs:
* openwhisk-podspecs:
* CocoaPods Podspecs repository for ‘openwhisk-client-swift’ subproject.
* openwhisk-devtools:
* Development tools for building and deploying Apache OpenWhisk
Expand All @@ -68,7 +68,7 @@ the initial donation:
* Sample application with Message Hub and Object Store.
* openwhisk-sample-slackbot:
* A proof-of-concept Slackbot to invoke OpenWhisk actions.

The API Gateway code was a collaboration project jointly developed by both IBM Corporation
and Adobe Systems Incorporated (http://www.adobe.com/) and a donation to the Apache OpenWhisk
project by both companies.
Expand Down
Loading

0 comments on commit 99d6e86

Please sign in to comment.