Skip to content

Commit

Permalink
linting / precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
fredclausen committed Oct 12, 2023
1 parent 0ebef19 commit 34841af
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 47 deletions.
1 change: 1 addition & 0 deletions .dictionary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
crate
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 to GHCR'
- 'Check Linting'
- 'Tests'
types: ['requested']
- "Deploy to GHCR"
- "Check Linting"
- "Tests"
types: ["requested"]

jobs:
cancel-duplicate-workflow-runs:
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
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.4.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.5" # 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.9.1
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"]
16 changes: 8 additions & 8 deletions .vscode/scp.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"host": "pete",
"port": 22,
"user": "docker",
"ignore":[".git",".vscode"],
"remotePath": "~",
"identity_file": "~/.ssh/id_rsa",
"uploadOnSave": true
}
"host": "pete",
"port": 22,
"user": "docker",
"ignore": [".git", ".vscode"],
"remotePath": "~",
"identity_file": "~/.ssh/id_rsa",
"uploadOnSave": true
}
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ENV URL_MLAT_CLIENT_REPO="https://github.com/wiedehopf/mlat-client.git" \
PRIVATE_MLAT="false" \
MLAT_INPUT_TYPE="dump1090"

# hadolint ignore=DL3008,SC2086,SC2039,SC2068,DL3003,DL3015,SC3054
RUN set -x && \
# define packages needed for installation and general management of the container:
TEMP_PACKAGES=() && \
Expand Down
86 changes: 54 additions & 32 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
version: '3.8'
version: "3.8"

#
# If you are using the readsb container to pull your feed from, you may have add the following environment
# variables to the readsb section:
# - READSB_NET_BEAST_OUTPUT_PORT=30005
# - READSB_NET_RAW_OUTPUT_PORT=30002
#
# Also, it assumes that you have added the following parameters to your `.env` file., or made available in this docker-compose.yml file:
# Also, it assumes that you have added the following parameters to your `.env` file., or made available in this docker-compose.yml file:
#
# RV_FEEDER_KEY=xxxx:123456789ABCDEF
# FEEDER_LAT=12.345678
Expand Down
2 changes: 1 addition & 1 deletion rootfs/etc/s6-overlay/scripts/mlat-client
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ if chk_enabled "${VERBOSE}"; then
s6wrap --quiet --prepend="${APPNAME}" --timestamps --args echo "Starting MLAT with: ${MLAT_CMD} ${MLAT_PARAM[@]}"
exec s6wrap --quiet --prepend="${APPNAME}" --timestamps --args "${MLAT_CMD}" "${MLAT_PARAM[@]}"
else
exec s6wrap --quiet --ignore=stdout --prepend="${APPNAME}" --timestamps --args "${MLAT_CMD}" "${MLAT_PARAM[@]}"
exec s6wrap --quiet --ignore=stdout --prepend="${APPNAME}" --timestamps --args "${MLAT_CMD}" "${MLAT_PARAM[@]}"
fi
4 changes: 4 additions & 0 deletions rootfs/home/healthcheck/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/command/with-contenv bash
#shellcheck shell=bash

# Import healthchecks-framework
# shellcheck disable=SC1091
source /opt/healthchecks-framework/healthchecks.sh

# HEALTHLIMIT is the number of error lines that can be in run/imalive/errors before things go UNHEALTHY
Expand All @@ -9,11 +11,13 @@ HEALTHLIMIT=20
APPNAME="$(hostname)/healthcheck"

touch /run/imalive/errors
#shellcheck disable=SC2002
if [[ "$(cat /run/imalive/errors | wc -l)" -ge "$HEALTHLIMIT" ]]
then
echo "[$APPNAME][$(date)] Abnormal death count for RadarVirtuel is $(cat /run/imalive/errors | wc -l): UNHEALTHY (>= $HEALTHLIMIT)"
exit 1
else
#shellcheck disable=SC2002
[[ "$VERBOSE" == "ON" ]] && echo "[$APPNAME][$(date)] Abnormal death count for RadarVirtuel is $(cat /run/imalive/errors | wc -l): HEALTHY (< $HEALTHLIMIT)"
fi
exit 0

0 comments on commit 34841af

Please sign in to comment.