Add sanity check for non-ASCII character and trailing spaces (#927)

* add CI sanity check for non-ASCII encoding and trailing spaces

* check TAB too

* fix ordering

* rename sanity to sanitycheck
This commit is contained in:
Reiley Yang 2020-07-27 07:52:26 -07:00 committed by GitHub
parent 14255acb6d
commit 755f727df0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 67 additions and 13 deletions

View File

@ -1,11 +1,11 @@
name: spellcheck
name: sanitycheck
on:
pull_request:
branches: [ master ]
jobs:
build:
misspell:
runs-on: ubuntu-latest
steps:
@ -19,3 +19,13 @@ jobs:
- name: run misspell
run: ./bin/misspell -error .
encoding:
runs-on: ubuntu-latest
steps:
- name: check out code
uses: actions/checkout@v2
- name: detect non-ASCII encoding and trailing space
run: python3 ./build/sanitycheck.py

45
build/sanitycheck.py Normal file
View File

@ -0,0 +1,45 @@
#!/usr/bin/env python3
import glob
import os
import sys
def sanitycheck(pattern, allow_utf8 = False):
error_count = 0
for filename in glob.glob(pattern, recursive=True):
if not os.path.isfile(filename):
continue
with open(filename, 'rb') as file:
content = file.read()
error = []
lineno = 1
for line in content.splitlines():
if allow_utf8 and lineno == 1 and line.startswith(b'\xef\xbb\xbf'):
line = line[3:]
if any(b > 127 for b in line):
error.append(' Non-ASCII character found at Ln:{} {}'.format(lineno, line))
if line[-1:] == b' ' or line[-1:] == b'\t':
error.append(' Trailing space found at Ln:{} {}'.format(lineno, line))
lineno += 1
if error:
error_count += 1
print('{} [FAIL]'.format(filename), file=sys.stderr)
for msg in error:
print(msg, file=sys.stderr)
else:
# print('{} [PASS]'.format(filename))
pass
return error_count
retval = 0
retval += sanitycheck('**/*.cmd')
retval += sanitycheck('**/*.cs', allow_utf8 = True)
retval += sanitycheck('**/*.csproj', allow_utf8 = True)
retval += sanitycheck('**/*.md')
retval += sanitycheck('**/*.proj', allow_utf8 = True)
retval += sanitycheck('**/*.py')
retval += sanitycheck('**/*.xml', allow_utf8 = True)
sys.exit(retval)

View File

@ -9,7 +9,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Examples.AspNet")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyCopyright("Copyright @ 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

View File

@ -1,4 +1,4 @@
# Open Telemetry - Jaeger Exporter - Apache Thrift
# Open Telemetry - Jaeger Exporter - Apache Thrift
This folder contains a stripped-down fork of the [ApacheThrift
0.13.0.1](https://www.nuget.org/packages/ApacheThrift/0.13.0.1) library from

View File

@ -1,4 +1,4 @@
# OpenTelemetry Protocol Implementation
# OpenTelemetry Protocol Implementation
`.proto` files under `Implementation\` are copied from the
[`opentelemetry-proto`](https://github.com/open-telemetry/opentelemetry-proto/commit/1a931b4b57c34e7fd8f7dddcaa9b7587840e9c08)

View File

@ -35,4 +35,3 @@ for an example of how to use the exporter.
* [OpenTelemetry Project](https://opentelemetry.io/)
* [OpenTelemetry
Protocol](https://github.com/open-telemetry/opentelemetry-proto)

View File

@ -1,4 +1,4 @@
# OpenTelemetry Benchmarks
# OpenTelemetry Benchmarks
Use the following example to run Benchmarks from command line:
(change parameters as necessary)