Skip to content

Commit

Permalink
repo: Add linting (#46)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Northey <ryan@synca.io>
  • Loading branch information
phlax committed Aug 6, 2024
1 parent 6aa9c37 commit 27a2880
Show file tree
Hide file tree
Showing 55 changed files with 1,087 additions and 84 deletions.
8 changes: 8 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

[flake8]

# TODO(phlax): ignore less
ignore = W503,W504,E121,E126,E241,E125,E127,E129,E251,E265,E303,E306,E402,E501,E502,E711,E713,E722,E741,F523,F541,F841,N803,N806,N817,W605

# TODO(phlax): exclude less
exclude = build_docs,.git,generated,test,examples,venv,tools/dev
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto eol=lf

*.svg binary
20 changes: 10 additions & 10 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ jobs:
docs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
repository: envoyproxy/envoy
path: envoy
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
path: examples
- run: |
bazel build --override_repository=envoy_examples=../examples --config=ci //docs
working-directory: envoy
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
repository: envoyproxy/envoy
path: envoy
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
path: examples
- run: |
bazel build --override_repository=envoy_examples=../examples --config=ci //docs
working-directory: envoy
28 changes: 28 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Lint

permissions:
contents: read

on:
pull_request:
push:
branches:
- main

concurrency:
group: >-
${{ github.event.inputs.head_ref || github.run_id }}
jobs:
lint:
runs-on: ubuntu-24.04
if: github.repository_owner == 'envoyproxy'
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: "3.12"
- run: |
pip install -r ./.github/workflows/requirements.txt
envoy.code.check . -c glint python_flake8 shellcheck yamllint -x single-page-app/_github-clusters.yml
1 change: 1 addition & 0 deletions .github/workflows/requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
envoy.code.check
938 changes: 938 additions & 0 deletions .github/workflows/requirements.txt

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
extends: default

rules:
document-start: false
indentation:
spaces: consistent
indent-sequences: false
line-length:
# This can be adjusted if there is a very good reason.
max: 140
level: error
allow-non-breakable-words: true
truthy:
allowed-values:
- "yes"
- "no"
- "true"
- "false"
# https://github.com/adrienverge/yamllint/issues/430
- "on"
- "off"

yaml-files:
- .clang-format
- "*.yml"
- "*.yaml"

ignore:
- "**/*template.yaml"
- examples/single-page-app/_github-clusters.yml
- test/config/integration/server_xds.cds.with_unknown_field.yaml
10 changes: 5 additions & 5 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ to `verify.sh` will test that the sandbox can be started and stopped.

export NAME=example-sandbox

# shellcheck source=examples/verify-common.sh
# shellcheck source=verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"

# add example tests here...
Expand Down Expand Up @@ -146,7 +146,7 @@ following:
export NAME=example-sandbox
export DELAY=10

# shellcheck source=examples/verify-common.sh
# shellcheck source=verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"

# add example tests here...
Expand All @@ -169,7 +169,7 @@ might use a `verify.sh` with:
export NAME=example-sandbox
export PATHS=frontend,backend

# shellcheck source=examples/verify-common.sh
# shellcheck source=verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"

# add example tests here...
Expand All @@ -190,7 +190,7 @@ For example:
export NAME=example-sandbox
export MANUAL=true

# shellcheck source=examples/verify-common.sh
# shellcheck source=verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"

run_log "Creating bar.txt before starting containers"
Expand Down Expand Up @@ -218,7 +218,7 @@ should add the following:
export NAME=example-sandbox
export UPARGS="--scale http_service=2"

# shellcheck source=examples/verify-common.sh
# shellcheck source=verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"

# add example tests here...
Expand Down
2 changes: 1 addition & 1 deletion brotli/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export PORT_PROXY="${BROTLI_PORT_PROXY:-10200}"
export PORT_STATS0="${BROTLI_PORT_PROXY:-10201}"
export PORT_STATS1="${BROTLI_PORT_PROXY:-10202}"

# shellcheck source=examples/verify-common.sh
# shellcheck source=verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"

wait_for 10 bash -c "\
Expand Down
1 change: 0 additions & 1 deletion cache/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
import re
import datetime
from typing import Optional

import yaml

Expand Down
2 changes: 1 addition & 1 deletion cache/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export PORT_PROXY="${CACHE_PORT_PROXY:-10300}"
export CACHE_RESPONSES_YAML=./ci-responses.yaml


# shellcheck source=examples/verify-common.sh
# shellcheck source=verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"

check_validated() {
Expand Down
2 changes: 1 addition & 1 deletion cors/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export PORT_PROXY="${CORS_PORT_PROXY:-10310}"
export PORT_BACKEND="${CORS_PORT_BACKEND:-10311}"
export PORT_STATS="${CORS_PORT_STATS:-10312}"

# shellcheck source=examples/verify-common.sh
# shellcheck source=verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"


Expand Down
2 changes: 1 addition & 1 deletion csrf/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export PORT_SAME="${CSRF_PORT_SAME:-10320}"
export PORT_STATS="${CSRF_PORT_STATS:-10321}"
export PORT_CROSS="${CSRF_PORT_CROSS:-10322}"

# shellcheck source=examples/verify-common.sh
# shellcheck source=verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"


Expand Down
2 changes: 1 addition & 1 deletion double-proxy/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export MANUAL=true

export PORT_PROXY="${DOUBLE_PROXY_PORT_PROXY:-10400}"

# shellcheck source=examples/verify-common.sh
# shellcheck source=verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"

mkdir -p certs
Expand Down
6 changes: 3 additions & 3 deletions dynamic-config-cp/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ export UPARGS=" proxy"
export PORT_PROXY="${DYNAMIC_CP_PORT_PROXY:-10410}"
export PORT_ADMIN="${DYNAMIC_CP_PORT_ADMIN:-10411}"

# shellcheck source=examples/verify-common.sh
# shellcheck source=verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"

run_log "Check port ${PORT_PROXY} is not open (still shows as succeeded)"
nc -zv localhost ${PORT_PROXY} |& grep -v open
nc -zv localhost "${PORT_PROXY}" |& grep -v open

run_log "Check the static cluster"
curl -s "http://localhost:${PORT_ADMIN}/config_dump" \
Expand Down Expand Up @@ -43,7 +43,7 @@ run_log "Bring down the control plane"
"${DOCKER_COMPOSE[@]}" stop go-control-plane

wait_for 10 sh -c "\
curl -s "http://localhost:${PORT_ADMIN}/config_dump" \
curl -s \"http://localhost:${PORT_ADMIN}/config_dump\" \
| jq -r '.configs[1].dynamic_active_clusters' \
| grep '\"version_info\": \"1\"'"

Expand Down
2 changes: 1 addition & 1 deletion dynamic-config-fs/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export PORT_ADMIN="${DYNAMIC_FS_PORT_ADMIN:-10421}"
chmod go+r configs/*
chmod go+rx configs

# shellcheck source=examples/verify-common.sh
# shellcheck source=verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"

run_log "Check for response comes from service1 upstream"
Expand Down
2 changes: 1 addition & 1 deletion ext_authz/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
export NAME=ext_authz
export PORT_PROXY="${EXT_AUTH_PORT_PROXY:-10500}"

# shellcheck source=examples/verify-common.sh
# shellcheck source=verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"


Expand Down
2 changes: 1 addition & 1 deletion fault-injection/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
export NAME=fault-injection
export PORT_PROXY="${FAULT_INJECTION_PORT_PROXY:-10610}"

# shellcheck source=examples/verify-common.sh
# shellcheck source=verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"


Expand Down
2 changes: 1 addition & 1 deletion front-proxy/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export PORT_PROXY="${FRONT_PROXY_PORT_PROXY:-10610}"
export PORT_HTTPS="${FRONT_PROXY_PORT_HTTPS:-10611}"
export PORT_STATS="${FRONT_PROXY_PORT_STATS:-10612}"

# shellcheck source=examples/verify-common.sh
# shellcheck source=verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"


Expand Down
2 changes: 1 addition & 1 deletion golang-http/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export MANUAL=true
export PORT_PROXY="${GOLANG_PORT_PROXY:-10710}"


# shellcheck source=examples/verify-common.sh
# shellcheck source=verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"

run_log "Compile the go plugin library"
Expand Down
2 changes: 1 addition & 1 deletion golang-network/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export UID
export MANUAL=true
export PORT_PROXY="${GOLANG_NETWORK_PORT_PROXY:-10720}"

# shellcheck source=examples/verify-common.sh
# shellcheck source=verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"

run_log "Compile the go plugin library"
Expand Down
3 changes: 2 additions & 1 deletion grpc-bridge/client/client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python

import requests, sys
import requests
import sys
import os

# Stubs generated by protoc
Expand Down
2 changes: 1 addition & 1 deletion grpc-bridge/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export NAME=grpc-bridge
# this allows us to bring up the stack manually after generating stubs
export MANUAL=true

# shellcheck source=examples/verify-common.sh
# shellcheck source=verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"


Expand Down
2 changes: 1 addition & 1 deletion gzip/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export PORT_PROXY="${GZIP_PORT_PROXY:-10700}"
export PORT_STATS0="${GZIP_PORT_STATS0:-10701}"
export PORT_STATS1="${GZIP_PORT_STATS1:-10702}"

# shellcheck source=examples/verify-common.sh
# shellcheck source=verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"

run_log "Test service: localhost:${PORT_PROXY}/file.json with compression"
Expand Down
2 changes: 1 addition & 1 deletion jaeger-tracing/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export NAME=jaeger-tracing
export PORT_PROXY="${JAEGER_PORT_PROXY:-11010}"
export PORT_UI="${JAEGER_PORT_UI:-11011}"

# shellcheck source=examples/verify-common.sh
# shellcheck source=verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"

wait_for 10 bash -c "responds_with Hello http://localhost:${PORT_PROXY}/trace/1"
Expand Down
2 changes: 1 addition & 1 deletion kafka/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export PORT_ADMIN="${KAFKA_PORT_ADMIN:-11101}"
# not start.
UPARGS="proxy kafka-server zookeeper"

# shellcheck source=examples/verify-common.sh
# shellcheck source=verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"

kafka_client () {
Expand Down
2 changes: 1 addition & 1 deletion load-reporting-service/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export PORT_PROXY0="${LRS_PORT_PROXY0:-11200}"
export PORT_PROXY1="${LRS_PORT_PROXY1:-11201}"
export PORT_ADMIN="${LRS_PORT_ADMIN:-11202}"

# shellcheck source=examples/verify-common.sh
# shellcheck source=verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"

run_log "Send requests"
Expand Down
2 changes: 1 addition & 1 deletion local_ratelimit/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export PORT_PROXY="${LOCAL_RATELIMIT_PORT_PROXY:-11210}"
export PORT_STATS0="${LOCAL_RATELIMIT_PORT_STATS0:-11211}"
export PORT_STATS1="${LOCAL_RATELIMIT_PORT_STATS1:-11212}"

# shellcheck source=examples/verify-common.sh
# shellcheck source=verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"


Expand Down
14 changes: 7 additions & 7 deletions locality-load-balancing/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@
from aiohttp import web

routes = web.RouteTableDef()
healthy = True
ishealthy = True


@routes.get("/")
async def get(request):
global healthy
if healthy:
global ishealthy
if ishealthy:
return web.Response(text=f"Hello from {os.environ['HOST']}!\n")
else:
raise web.HTTPServiceUnavailable(reason="Unhealthy")


@routes.get("/healthy")
async def healthy(request):
global healthy
healthy = True
global ishealthy
ishealthy = True
return web.Response(text=f"[{os.environ['HOST']}] Set to healthy\n", status=201)


@routes.get("/unhealthy")
async def unhealthy(request):
global healthy
healthy = False
global ishealthy
ishealthy = False
return web.Response(text=f"[{os.environ['HOST']}] Set to unhealthy\n", status=201)


Expand Down
2 changes: 1 addition & 1 deletion locality-load-balancing/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
export NAME=locality-load-balancing


# shellcheck source=examples/verify-common.sh
# shellcheck source=verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"


Expand Down
2 changes: 1 addition & 1 deletion lua-cluster-specifier/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export NAME=lua-cluster-specifier
export PORT_PROXY="${LUA_CLUSTER_PORT_PROXY:-12620}"
export PORT_WEB="${LUA_CLUSTER_PORT_WEB:-12621}"

# shellcheck source=examples/verify-common.sh
# shellcheck source=verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"

run_log "Test Lua cluster specifier with normal cluster"
Expand Down
Loading

0 comments on commit 27a2880

Please sign in to comment.