Skip to content

Commit

Permalink
ci: add pre-commit to lint for general file style (envoyproxy#184)
Browse files Browse the repository at this point in the history
Signed-off-by: Jose Nino [email protected]

Description: this PR introduces pre-commit in order to lint for general file style. All of our linters are language specific. This linter adds common style, e.g newline at the end of files.
Risk Level: low
Testing: ran locally and added CI job.
Docs Changes: added docs in STYLE.md

Fixes #111

Signed-off-by: JP Simard <[email protected]>
  • Loading branch information
junr03 authored and jpsim committed Nov 28, 2022
1 parent 4a9b00e commit 61e49b6
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 9 deletions.
12 changes: 12 additions & 0 deletions mobile/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.1.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-yaml
- id: detect-private-key
- id: mixed-line-ending
2 changes: 1 addition & 1 deletion mobile/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,4 @@
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.
limitations under the License.
17 changes: 15 additions & 2 deletions mobile/STYLE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## General file style

- General style guidelines -- like newlines at the end of file -- are linted
for using [pre-commit](https://pre-commit.com/)
- The rules enforced are available in the
repo's [.pre-commit-config.yaml file](.pre-commit-config.yaml).
- You can install pre-commit locally with these [instructions](https://pre-commit.com/#install).
- The linter may be run locally using `pre-commit run --all-files`.
Additionally it can be installed as a commit hook with `pre-commit install`.

## C++ coding style

- C++ code uses the [Envoy style guide](https://github.com/envoyproxy/envoy/blob/master/STYLE.md)
Expand All @@ -13,8 +23,11 @@

## Kotlin coding style

- Kotlin code style is validated using [detekt](https://github.com/arturbosch/detekt)
- The rules enforced are available in the repo's [.kotlinlint.yml file](./.kotlinlint.yml). We build upon the default config provided by [`detekt`](https://github.com/arturbosch/detekt/blob/master/detekt-cli/src/main/resources/default-detekt-config.yml)
- Kotlin code style is validated using
[detekt](https://github.com/arturbosch/detekt)
- The rules enforced are available in the repo's [.kotlinlint.yml file](./.kotlinlint.yml).
We build upon the default config provided by
[`detekt`](https://github.com/arturbosch/detekt/blob/master/detekt-cli/src/main/resources/default-detekt-config.yml)

## Swift coding style

Expand Down
10 changes: 10 additions & 0 deletions mobile/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ stages:
submodules: true
- script: ./tools/check_format.sh
displayName: 'Run formatters'
- job: precommit_lint
timeoutInMinutes: 60
pool:
vmImage: 'macos-10.14'
steps:
- checkout: self
- script: brew install pre-commit
displayName: 'Install pre-commit'
- script: pre-commit run --all-files
displayName: 'Running pre-commit'
- job: swift_lint
timeoutInMinutes: 60
pool:
Expand Down
2 changes: 1 addition & 1 deletion mobile/docs/root/_static/css/envoy.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
/* align multi line csv table columns */
table.docutils div.line-block {
margin-left: 0;
}
}
2 changes: 1 addition & 1 deletion mobile/docs/root/start/building/building.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ example of how this artifact may be used.

For a demo of a working app using this artifact, see the :ref:`hello_world` example.

.. _releases: https://github.com/lyft/envoy-mobile/releases
.. _releases: https://github.com/lyft/envoy-mobile/releases
1 change: 0 additions & 1 deletion mobile/examples/kotlin/hello_world/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,3 @@ class MainActivity : Activity() {
return inputStream.bufferedReader().use { reader -> reader.readText() }
}
}

3 changes: 0 additions & 3 deletions mobile/examples/kotlin/shared/Response.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,3 @@ sealed class Response {
data class Success(val title: String, val header: String) : Response()

data class Failure(val message: String) : Response()



0 comments on commit 61e49b6

Please sign in to comment.