Skip to content

Commit

Permalink
Add pre-commit (#454)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacome authored Jun 21, 2023
1 parent 5bdbd6d commit 915df37
Show file tree
Hide file tree
Showing 31 changed files with 91 additions and 52 deletions.
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
Expand Down Expand Up @@ -48,7 +48,7 @@ DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeCategories:
IncludeCategories:
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:
env:
ACTIONS_RUNNER_DEBUG: true
ACTIONS_STEP_DEBUG: true

jobs:
dependabot:
runs-on: ubuntu-latest
Expand All @@ -23,7 +23,7 @@ jobs:
uses: dependabot/fetch-metadata@v1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Approve a PR
if: ${{contains(steps.metadata.outputs.directory, '/test')}}
run: gh pr review --approve "$PR_URL"
Expand Down
41 changes: 41 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude: .*pb2.*
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
args: [--allow-multiple-documents]
- id: check-ast
- id: check-added-large-files
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-executables-have-shebangs
- id: check-symlinks
- id: check-case-conflict
- id: check-vcs-permalinks
- id: check-json
- id: pretty-format-json
args: [--autofix, --no-sort-keys, --no-ensure-ascii]
- id: mixed-line-ending
args: [--fix=lf]
- id: name-tests-test
args: [--pytest-test-first]
- id: no-commit-to-branch
- id: requirements-txt-fixer
- id: fix-byte-order-marker
- repo: https://github.com/asottile/pyupgrade
rev: v3.6.0
hooks:
- id: pyupgrade
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
1 change: 0 additions & 1 deletion ci/build_nginx_opentracing_module.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ cd nginx-release-${NGINX_VERSION}
--with-debug \
--add-dynamic-module="${SRC_DIR}/opentracing"
make VERBOSE=1

2 changes: 1 addition & 1 deletion ci/install_gcc4.8.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

set -e
apt-get update
apt-get update
apt-get install --no-install-recommends --no-install-suggests -y \
software-properties-common
add-apt-repository -y ppa:ubuntu-toolchain-r/test
Expand Down
2 changes: 1 addition & 1 deletion ci/release.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

set -e
apt-get update
apt-get update
apt-get install --no-install-recommends --no-install-suggests -y \
wget \
unzip
Expand Down
1 change: 0 additions & 1 deletion ci/run_nginx_ot_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ if [ -n "$1" ]; then
else
docker run -v "$PWD":/src -w /src --privileged -it "$BUILD_IMAGE" /bin/bash -l
fi

2 changes: 1 addition & 1 deletion ci/setup_build_environment.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

set -e
apt-get update
apt-get update
apt-get install --no-install-recommends --no-install-suggests -y \
build-essential \
cmake \
Expand Down
16 changes: 8 additions & 8 deletions doc/Tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Virtual Zoo
In this tutorial, we'll enable an application for OpenTracing and use the
trace data to guide us in making several optimizations. The application we're
going to work with is a virtual zoo. Users admit new animals into the zoo by
filling out a form and submitting a profile picture.
filling out a form and submitting a profile picture.

![alt text](data/Admit.png "Admit New Animal")

Expand All @@ -16,7 +16,7 @@ page with thumbnail pictures of all the animals organized into a table.
The application uses NGINX to load-balance between multiple Node.js backends
and serve static content. When processing a new admittance, a Node.js server
writes the profile data to a shared sqlite database and resizes the profile
picture to a common thumbnail size. Here's what the NGINX configuration looks
picture to a common thumbnail size. Here's what the NGINX configuration looks
like:

```
Expand Down Expand Up @@ -65,18 +65,18 @@ http {
proxy_pass http://backend;
opentracing_propagate_context;
# Redirect to the spash page if the animal was successfully admitted.
proxy_intercept_errors on;
error_page 301 302 303 =200 /;
}
location / {
root www;
root www;
}
location ~ \.jpg$ {
# Set the root directory to where the Node.js backend uploads profile
# Set the root directory to where the Node.js backend uploads profile
# images.
include image_params;
}
Expand Down Expand Up @@ -104,7 +104,7 @@ uses the name of the first location as the name for the top-level span. We can
change this behavior by using the directives `opentracing_operation_name` and
`opentracing_location_operation_name` to set the names of the request and
location block spans respectively. For
example, by adding
example, by adding
```
http {
...
Expand All @@ -125,7 +125,7 @@ OpenTracing.
Enabling OpenTracing for the Backend
---------------------------------

When using express with Node.js, OpenTracing can be turn on
When using express with Node.js, OpenTracing can be turn on
by adding tracing middleware to the express app:
```JavaScript
const app = express();
Expand Down Expand Up @@ -157,7 +157,7 @@ of its contents to the Node.js servers. Updating NGINX's configuration file to d
client_max_body_size 1000M;
proxy_pass_request_headers on;
proxy_set_header admit-profile-pic $request_body_file;
proxy_set_header admit-profile-pic $request_body_file;
proxy_set_body off;
proxy_redirect off;
...
Expand Down
2 changes: 1 addition & 1 deletion example/php/jaeger/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function getallheaders() {
$config = new Config(
[
'sampler' => [
'type' => 'const',
'type' => 'const',
'param' => true,
],
'local_agent' => [
Expand Down
4 changes: 2 additions & 2 deletions example/php/jaeger/composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"minimum-stability": "dev",
"require": {
"require": {
"jonahgeorge/jaeger-client-php": "1.4.3",
"opentracing/opentracing":"1.0.2"
"opentracing/opentracing": "1.0.2"
}
}
2 changes: 1 addition & 1 deletion example/trivial/datadog/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:18.04
FROM ubuntu:18.04
# 17.10 doesn't come with latest golang.

WORKDIR /app
Expand Down
2 changes: 1 addition & 1 deletion example/trivial/datadog/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
A minimal OpenTracing example demonstrating usage of the nginx-opentracing
docker image with Datadog. It features Nginx as a reverse-proxy in front a Go
server.
server.

Before running create an account at https://www.datadoghq.com and enter your
API key into docker-compose.yaml
Expand Down
2 changes: 1 addition & 1 deletion example/trivial/datadog/datadog-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"operation_name_override": "nginx.handle",
"agent_host": "dd-agent",
"agent_port": 8126
}
}
2 changes: 1 addition & 1 deletion example/trivial/datadog/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ services:
- "9001"
ports:
- "9001:9001"
command:
command:
- /app/server

dd-agent:
Expand Down
2 changes: 1 addition & 1 deletion example/trivial/jaeger/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ services:
- "9001"
ports:
- "9001:9001"
command:
command:
- /app/server
- -collector_host
- jaeger
Expand Down
2 changes: 1 addition & 1 deletion example/trivial/ubuntu-x86_64/Dockerfile-nginx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:18.04

RUN set -x \
# Install package dependencies
# Install package dependencies
&& apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -y \
wget \
Expand Down
2 changes: 1 addition & 1 deletion example/trivial/ubuntu-x86_64/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ services:
- "9001"
ports:
- "9001:9001"
command:
command:
- /app/server
- -collector_host
- jaeger
Expand Down
2 changes: 1 addition & 1 deletion example/trivial/zipkin/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ services:
- "9001"
ports:
- "9001:9001"
command:
command:
- /app/server
- -collector_host
- zipkin
Expand Down
2 changes: 1 addition & 1 deletion example/zoo/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ services:
entrypoint: ./start-backend.sh

volumes:
image-volume:
image-volume:
tmp-volume:

networks:
Expand Down
4 changes: 2 additions & 2 deletions example/zoo/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ http {
client_body_buffer_size 128K;
client_max_body_size 1000M;

proxy_set_header admit-profile-pic $request_body_file;
proxy_set_header admit-profile-pic $request_body_file;
proxy_set_body off;
proxy_redirect off;

Expand All @@ -62,7 +62,7 @@ http {
opentracing_operation_name $request_uri;
opentracing_trace_locations off;

root /app/www;
root /app/www;
}

location ~ \.jpg$ {
Expand Down
3 changes: 1 addition & 2 deletions example/zoo/node/views/animal.pug
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ html
head
title= title
body
table
table
tr
td(align='center', valign='center')
dl
Expand All @@ -11,4 +11,3 @@ html
dd= description
br
| <img src="#{profile_pic}">

3 changes: 1 addition & 2 deletions example/zoo/node/views/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ html
each row in animals
tr
each animal in row
td(align='center', valign='center')
td(align='center', valign='center')
a(href=animal.profile)
img(src=animal.thumbnail_pic)
br
| #{animal.name}
a(href="/admit.html")
| New Admittance

4 changes: 2 additions & 2 deletions opentracing/src/ngx_http_opentracing_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ using namespace ngx_opentracing;
// https://github.com/opentracing/lua-bridge-tracer/issues/6
//
// As a solution, we use a plain pointer and never free and instead rely on the OS to clean up the
// resources when the process exits. This is a pattern proposed on
// resources when the process exits. This is a pattern proposed on
// https://google.github.io/styleguide/cppguide.html#Static_and_Global_Variables
static const opentracing::DynamicTracingLibraryHandle*
opentracing_library_handle;
Expand Down Expand Up @@ -328,7 +328,7 @@ static char *merge_opentracing_loc_conf(ngx_conf_t *, void *parent,
}

*tag = kv.second;
}
}
else {
opentracing_tag_t* tag = (opentracing_tag_t*)conf->tags->elts;
tag[index] = kv.second;
Expand Down
16 changes: 10 additions & 6 deletions test/environment/grpc/app.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
from concurrent import futures
import sys
import signal
import sys
import time
import grpc
from concurrent import futures

import app_pb2 as app_messages
import app_pb2_grpc as app_service
import grpc

_ONE_DAY_IN_SECONDS = 60 * 60 * 24


class AppService(app_service.AppServicer):
def CheckTraceHeader(self, request, context):
metadata = dict(context.invocation_metadata())
if 'x-ot-span-context' not in metadata:
if "x-ot-span-context" not in metadata:
context.set_code(grpc.StatusCode.INTERNAL)
context.set_details("Metadatum x-ot-span-context not found")
return app_messages.Empty()


def serve():
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
app_service.add_AppServicer_to_server(AppService(), server)
server.add_insecure_port('0.0.0.0:50051')
server.add_insecure_port("0.0.0.0:50051")
server.start()
signal.signal(signal.SIGTERM, signal.getsignal(signal.SIGINT))
try:
Expand All @@ -28,5 +31,6 @@ def serve():
except KeyboardInterrupt:
server.stop(0)

if __name__ == '__main__':

if __name__ == "__main__":
serve()
4 changes: 2 additions & 2 deletions test/environment/grpc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
grpcio-tools==1.55.0
grpcio==1.55.0
grpcio-reflection==1.55.0
grpcio-health-checking==1.55.0
grpcio-reflection==1.55.0
grpcio-testing==1.55.0
grpcio-tools==1.55.0
1 change: 0 additions & 1 deletion test/environment/logs/debug.log
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

1 change: 0 additions & 1 deletion test/environment/logs/error.log
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

2 changes: 1 addition & 1 deletion test/environment/tracer-config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"output_file":"/trace.json"
"output_file": "/trace.json"
}
Loading

0 comments on commit 915df37

Please sign in to comment.