Skip to content

Commit

Permalink
linting and precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
fredclausen committed Oct 18, 2023
1 parent ff099f3 commit c537ef9
Show file tree
Hide file tree
Showing 23 changed files with 323 additions and 241 deletions.
1 change: 1 addition & 0 deletions .dictionary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
crate
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
.gitattributes
READMETEMPLATE.md
README.md
buildx.sh
buildx.sh
8 changes: 4 additions & 4 deletions .github/workflows/cancel_dupes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Cancelling Duplicates
on:
workflow_run:
workflows:
- 'Deploy'
- 'Check Linting'
- 'Tests'
types: ['requested']
- "Deploy"
- "Check Linting"
- "Tests"
types: ["requested"]

jobs:
cancel-duplicate-workflow-runs:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/hadolint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ on:
branches:
- main
paths:
- 'Dockerfile'
- "Dockerfile"

jobs:

hadolint:
name: Run hadolint against docker files
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/markdownlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ on:
- main
# only run these if markdown files are updated
paths:
- '**.md'
- '**.MD'
- "**.md"
- "**.MD"

jobs:
markdownlint:
Expand Down
15 changes: 7 additions & 8 deletions .github/workflows/on_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ on:
- main
# Don't trigger if it's just a documentation update
paths-ignore:
- '**.md'
- '**.MD'
- '**.yml'
- 'LICENSE'
- '.gitattributes'
- '.gitignore'
- '.dockerignore'
- "**.md"
- "**.MD"
- "**.yml"
- "LICENSE"
- ".gitattributes"
- ".gitignore"
- ".dockerignore"

jobs:

test-build:
name: Test
uses: sdr-enthusiasts/common-github-workflows/.github/workflows/build_and_push_image.yml@main
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/pre-commit-updates.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Update pre-commit hooks

on:
workflow_dispatch:
schedule:
- cron: 0 0 * * *

jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
- uses: vrslev/[email protected]
- uses: peter-evans/create-pull-request@v5
with:
branch: pre-commit-autoupdate
title: "chore(deps): Update pre-commit hooks"
commit-message: "chore(deps): Update pre-commit hooks"
body: Update pre-commit hooks
labels: dependencies
delete-branch: True
2 changes: 1 addition & 1 deletion .github/workflows/yamllint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- main
# only run when yaml files are updated
paths:
- '**.yml'
- "**.yml"

jobs:
yamllint:
Expand Down
2 changes: 1 addition & 1 deletion .hadolint.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ignored:
- DL3008
- SC2086
- SC2086
6 changes: 3 additions & 3 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"MD029": false,
"MD013": false,
"MD009": false
"MD029": false,
"MD013": false,
"MD009": false
}
65 changes: 65 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
repos:
# lint yaml, line and whitespace
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: requirements-txt-fixer
- id: mixed-line-ending
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable

# lint the dockerfiles
- repo: https://github.com/hadolint/hadolint
rev: v2.12.1-beta
hooks:
- id: hadolint

# prettier
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.3" # Use the sha / tag you want to point at
hooks:
- id: prettier
types_or: [file, bash, sh, javascript, jsx, ts, tsx]
additional_dependencies:
- [email protected]
exclude: ^(Dockerfile*)

- repo: https://github.com/codespell-project/codespell.git
rev: "v2.2.6" # Use the sha / tag you want to point at
hooks:
- id: codespell
types: [text]
args: [--ignore-words=.dictionary.txt]
exclude: ^(Dockerfile*)

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.9.0.6
hooks:
- id: shellcheck

- repo: https://github.com/sirosen/check-jsonschema
rev: 0.27.0
hooks:
- id: check-github-actions
- id: check-github-workflows

- repo: https://github.com/doublify/pre-commit-rust
rev: v1.0
hooks:
- id: fmt
- id: cargo-check

# lint python formatting
- repo: https://github.com/psf/black
rev: 23.10.0
hooks:
- id: black

- repo: https://github.com/pycqa/flake8
rev: "6.1.0" # pick a git hash / tag to point to
hooks:
- id: flake8
args: ["--extend-ignore=W503,W504,E501"]
406 changes: 203 additions & 203 deletions README.md

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion rootfs/etc/nginx.tar1090/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,3 @@ http {
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}

Empty file modified rootfs/etc/s6-overlay/s6-rc.d/graphs1090-writeback/run
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion rootfs/etc/s6-overlay/scripts/06-range-outline
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if [ -n "${HEYWHATSTHAT_PANORAMA_ID}" ]; then

HEYWHATSTHAT_ALTS="${HEYWHATSTHAT_ALTS:-12192m}"

if grep -e "[^0-9kmft,]" <<< "${HEYWHATSTHAT_ALTS}" >/dev/null 2>&1; then
if grep -e "[^0-9kmft,]" <<< "${HEYWHATSTHAT_ALTS}" >/dev/null 2>&1; then
echo "[$(date)][06-range-outline] FATAL: Illegal character in HEYWHATSTHAT_ALTS=${HEYWHATSTHAT_ALTS}"
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion rootfs/etc/s6-overlay/scripts/07-ngnix-logging
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ if ! chk_enabled "${HTTP_ERROR_LOG}"; then
else
# shellcheck disable=SC1003
sed -i 's\error_log .*\error_log /dev/stdout notice;\' /etc/nginx/nginx.conf
fi
fi
1 change: 0 additions & 1 deletion rootfs/etc/s6-overlay/scripts/08-graphs1090-down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ source /scripts/common
if chk_enabled "${GRAPHS1090_DISABLE}"; then
exit 0
fi

4 changes: 1 addition & 3 deletions rootfs/etc/s6-overlay/scripts/collectd
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ elif [[ -f "${PERMFILE}" ]] && ! [[ -d /var/lib/collectd/rrd/localhost ]]; then
fi


# wait for neccessary input file to exist before starting
# wait for necessary input file to exist before starting

loop_count=0
# shellcheck disable=SC2016
Expand All @@ -48,5 +48,3 @@ if chk_enabled "${GRAPHS1090_REDUCE_IO}"; then
# writeback
s6wrap --quiet --prepend=graphs1090-writeback --timestamps --args bash /usr/share/graphs1090/writeback.sh
fi


8 changes: 4 additions & 4 deletions rootfs/etc/s6-overlay/scripts/readsb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ fi
#
if [[ -n "$READSB_NET_API_PORT" ]]; then
READSB_CMD+=("--net-api-port=$READSB_NET_API_PORT")
else
else
READSB_CMD+=("--net-api-port=30152")
fi

Expand Down Expand Up @@ -250,7 +250,7 @@ fi
if [[ -n "$READSB_GAIN" ]]; then
if [[ "${READSB_GAIN,,}" == "autogain" ]] && [[ -f /var/globe_history/autogain/gain ]]; then
read -r gain < /var/globe_history/autogain/gain
READSB_CMD+=("--gain=$gain")
READSB_CMD+=("--gain=$gain")
elif [[ -n "$READSB_GAIN" ]]; then
[[ "${READSB_GAIN,,}" == "autogain" ]] && gain="49.6" || gain="${READSB_GAIN}"
READSB_CMD+=("--gain=$gain")
Expand Down Expand Up @@ -316,9 +316,9 @@ if [[ -n "$READSB_BEAST_BAUDRATE" ]]; then
fi

#####################
# Handle --write-prom=<filepath>
# Handle --write-prom=<filepath>

if [[ -n "$PROMETHEUS_ENABLE" ]]; then
if [[ -n "$PROMETHEUS_ENABLE" ]]; then
READSB_CMD+=("--write-prom=/run/readsb-prometheus.prom")
fi

Expand Down
2 changes: 1 addition & 1 deletion rootfs/etc/s6-overlay/scripts/timelapse1090
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if chk_enabled "$ENABLE_TIMELAPSE1090" && ! chk_enabled "${TAR1090_DISABLE}"; th
s6wrap --quiet --prepend=timelapse1090 --timestamps --args /opt/timelapse1090/timelapse1090.sh &
wait $!
popd || exit 1

sleep 30 & wait $!
else
exec sleep infinity
Expand Down
2 changes: 1 addition & 1 deletion rootfs/healthcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if [ -f "/run/readsb/aircraft.json" ]; then
# get current timestamp
TIMESTAMP_NOW=$(date +"%s.%N")

# makse sure readsb has updated json in past 60 seconds
# make sure readsb has updated json in past 60 seconds
TIMEDELTA=$(echo "$TIMESTAMP_NOW - $TIMESTAMP_LAST_READSB_UPDATE" | bc)
if [ "$(echo "$TIMEDELTA" \< 60 | bc)" -ne 1 ]; then
echo "readsb last updated: ${TIMESTAMP_LAST_READSB_UPDATE}, now: ${TIMESTAMP_NOW}, delta: ${TIMEDELTA}. UNHEALTHY"
Expand Down
3 changes: 1 addition & 2 deletions rootfs/tar1090-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ if [[ -n $2 ]]; then
elif [[ -n $1 ]] && [ "$1" != "test" ] ; then
instances="$1 tar1090"
elif [ -f /etc/default/tar1090_instances ]; then
instances=$(</etc/default/tar1090_instances)
instances=$(</etc/default/tar1090_instances)
else
instances="$srcdir tar1090"
fi
Expand Down Expand Up @@ -463,4 +463,3 @@ elif [[ $nginx == yes ]]; then
else
echo "All done! You'll need to configure your webserver yourself, see ${ipath}/nginx-tar1090.conf for a reference nginx configuration"
fi

2 changes: 1 addition & 1 deletion rootfs/usr/local/bin/autogain1090
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if [[ "$1" == "reset" ]]; then
pkill -f "/usr/local/bin/readsb"
exit 0
fi

if ! [[ -f $stats ]]; then echo "stats.json not found, is the decoder running?"; exit 1; fi

oldstrong=$(cat $autogain_dir/strong 2>/dev/null)
Expand Down

0 comments on commit c537ef9

Please sign in to comment.