From 92a87aea0b261e549bc3d506e21ae7e75fafaff9 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 9 Oct 2023 12:43:12 -0600 Subject: [PATCH] linting --- .dictionary.txt | 1 + .github/workflows/cancel_dupes.yml | 9 ++-- .github/workflows/markdownlint.yml | 4 +- .github/workflows/on_pr.yml | 15 +++--- .github/workflows/pre-commit-updates.yaml | 23 ++++++++ .github/workflows/yamllint.yml | 2 +- .pre-commit-config.yaml | 65 +++++++++++++++++++++++ Dockerfile | 1 + README.md | 46 ++++++++-------- rootfs/etc/s6-overlay/scripts/airspy_adsb | 8 +-- 10 files changed, 131 insertions(+), 43 deletions(-) create mode 100644 .dictionary.txt create mode 100644 .github/workflows/pre-commit-updates.yaml create mode 100644 .pre-commit-config.yaml diff --git a/.dictionary.txt b/.dictionary.txt new file mode 100644 index 0000000..9ac17d5 --- /dev/null +++ b/.dictionary.txt @@ -0,0 +1 @@ +crate diff --git a/.github/workflows/cancel_dupes.yml b/.github/workflows/cancel_dupes.yml index d5e6462..23cd838 100644 --- a/.github/workflows/cancel_dupes.yml +++ b/.github/workflows/cancel_dupes.yml @@ -1,15 +1,14 @@ --- - # Cancels duplicate github actions when superseded name: Cancelling Duplicates on: workflow_run: workflows: - - 'Pull Request' - - 'Deploy' - - 'Linting (Non-Image)' - types: ['requested'] + - "Pull Request" + - "Deploy" + - "Linting (Non-Image)" + types: ["requested"] jobs: cancel-duplicate-workflow-runs: diff --git a/.github/workflows/markdownlint.yml b/.github/workflows/markdownlint.yml index b270bfe..9fe857d 100644 --- a/.github/workflows/markdownlint.yml +++ b/.github/workflows/markdownlint.yml @@ -7,8 +7,8 @@ on: - main # only run these if markdown files are updated paths: - - '**.md' - - '**.MD' + - "**.md" + - "**.MD" jobs: markdownlint: diff --git a/.github/workflows/on_pr.yml b/.github/workflows/on_pr.yml index f5d7ac8..2a65881 100644 --- a/.github/workflows/on_pr.yml +++ b/.github/workflows/on_pr.yml @@ -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: - shellcheck: name: Run shellcheck against shell scripts runs-on: ubuntu-latest diff --git a/.github/workflows/pre-commit-updates.yaml b/.github/workflows/pre-commit-updates.yaml new file mode 100644 index 0000000..f075972 --- /dev/null +++ b/.github/workflows/pre-commit-updates.yaml @@ -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/checkout@v4.1.0 + with: + fetch-depth: 0 + - uses: vrslev/pre-commit-autoupdate@v1.0.0 + - 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 diff --git a/.github/workflows/yamllint.yml b/.github/workflows/yamllint.yml index 2fff033..d3b07f9 100644 --- a/.github/workflows/yamllint.yml +++ b/.github/workflows/yamllint.yml @@ -7,7 +7,7 @@ on: - main # only run when yaml files are updated paths: - - '**.yml' + - "**.yml" jobs: yamllint: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..34ef282 --- /dev/null +++ b/.pre-commit-config.yaml @@ -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: + - prettier@2.5.1 + 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"] diff --git a/Dockerfile b/Dockerfile index f9ca680..4c0f3a8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,7 @@ FROM ghcr.io/sdr-enthusiasts/docker-baseimage:base COPY rootfs/ / +# hadolint ignore=DL3008,DL3003,SC1091 RUN set -x && \ # # Install libusb diff --git a/README.md b/README.md index dbc60a6..fe7081b 100644 --- a/README.md +++ b/README.md @@ -8,33 +8,33 @@ It will provide BEAST protocol on TCP port `30005`. ## Environment Variables -| Environment Variable | `airspy_adsb`
option | Description | Default | -|----|----|----|----| -| `AIRSPY_ADSB_SERIAL` | `-s` | Device serial number | *unset* | -| `AIRSPY_ADSB_TIMEOUT` | `-t` | Aircraft timeout in seconds | `60` | -| `AIRSPY_ADSB_RF_GAIN` | `-g` | RF gain: `0` to `21` or `auto` | `auto` | -| `AIRSPY_ADSB_FEC_BITS` | `-f` | Forward Error Correction (FEC) bits | `1` | -| `AIRSPY_ADSB_PREAMBLE_FILTER` | `-e` | Preamble filter: `1` to `60` | `4` | -| `AIRSPY_ADSB_CPUTIME_TARGET` | `-C` | CPU processing time target (percentage): `5` to `95` | Disabled
*(adjusts preamble filter while running)*| -| `AIRSPY_ADSB_PREAMBLE_FILTER_MAX` | `-E` | Maximum preamble filter when using CPU target: `1` to `60` | `60` | -| `AIRSPY_ADSB_PREAMBLE_FILTER_NONCRC` | `-P` | Non-CRC Preamble filter: `1` to `$AIRSPY_ADSB_PREAMBLE_FILTER` | Disabled | -| `AIRSPY_ADSB_WHITELIST_THRESHOLD` | `-w` | Whitelist threshold: `1` to `20` | `5` | -| `AIRSPY_ADSB_MLAT_FREQ` | `-m` | MLAT frequency in MHz: `12`, `20` or `24` (Airspy R2 only) | *unset* | -| `AIRSPY_ADSB_VERBATIM_MODE` | `-n` | Set to `true` to enable Verbatim mode | *unset* | -| `AIRSPY_ADSB_DX_MODE` | `-x` | Set to `true` to enable DX mode | *unset* | -| `AIRSPY_ADSB_REDUCE_IF_BW` | `-r` | Set to `true` reduce the IF bandwidth to 4 MHz | *unset* | -| `AIRSPY_ADSB_RSSI_MODE` | `-R` | RSSI mode: `snr` (ref = 42 dB), `rms` (default: rms) | `rms` | -| `AIRSPY_ADSB_IGNORE_DF_TYPES` | `-D` | Ignore these DF types (comma separated list) | `24,25,26,27,28,29,30,31` | -| `AIRSPY_ADSB_BIAS_TEE` | `-b` | Set to `true` to enable Bias-Tee | *unset* | -| `AIRSPY_ADSB_BIT_PACKING` | `-p` | Set to `true` to enable Bit Packing | *unset* | -| `AIRSPY_ADSB_VERBOSE` | `-v` | Enable Verbose mode | *unset* | -| `AIRSPY_ADSB_STATS` | `-S` | Set to `true` to enable statistics in `/run/airspy_adsb` (this needs to be shared with a `tar1090` instance) | *unset* | -| `AIRSPY_ADSB_ARCH` | N/A | Forces a specific architecture binary. Supports `arm64`, `armv7`, `arm`, `nehalem`, `x86_64` or `i386`. If unset, will auto-detect. | *unset* | +| Environment Variable | `airspy_adsb`
option | Description | Default | +| ------------------------------------ | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ | +| `AIRSPY_ADSB_SERIAL` | `-s` | Device serial number | _unset_ | +| `AIRSPY_ADSB_TIMEOUT` | `-t` | Aircraft timeout in seconds | `60` | +| `AIRSPY_ADSB_RF_GAIN` | `-g` | RF gain: `0` to `21` or `auto` | `auto` | +| `AIRSPY_ADSB_FEC_BITS` | `-f` | Forward Error Correction (FEC) bits | `1` | +| `AIRSPY_ADSB_PREAMBLE_FILTER` | `-e` | Preamble filter: `1` to `60` | `4` | +| `AIRSPY_ADSB_CPUTIME_TARGET` | `-C` | CPU processing time target (percentage): `5` to `95` | Disabled
_(adjusts preamble filter while running)_ | +| `AIRSPY_ADSB_PREAMBLE_FILTER_MAX` | `-E` | Maximum preamble filter when using CPU target: `1` to `60` | `60` | +| `AIRSPY_ADSB_PREAMBLE_FILTER_NONCRC` | `-P` | Non-CRC Preamble filter: `1` to `$AIRSPY_ADSB_PREAMBLE_FILTER` | Disabled | +| `AIRSPY_ADSB_WHITELIST_THRESHOLD` | `-w` | Whitelist threshold: `1` to `20` | `5` | +| `AIRSPY_ADSB_MLAT_FREQ` | `-m` | MLAT frequency in MHz: `12`, `20` or `24` (Airspy R2 only) | _unset_ | +| `AIRSPY_ADSB_VERBATIM_MODE` | `-n` | Set to `true` to enable Verbatim mode | _unset_ | +| `AIRSPY_ADSB_DX_MODE` | `-x` | Set to `true` to enable DX mode | _unset_ | +| `AIRSPY_ADSB_REDUCE_IF_BW` | `-r` | Set to `true` reduce the IF bandwidth to 4 MHz | _unset_ | +| `AIRSPY_ADSB_RSSI_MODE` | `-R` | RSSI mode: `snr` (ref = 42 dB), `rms` (default: rms) | `rms` | +| `AIRSPY_ADSB_IGNORE_DF_TYPES` | `-D` | Ignore these DF types (comma separated list) | `24,25,26,27,28,29,30,31` | +| `AIRSPY_ADSB_BIAS_TEE` | `-b` | Set to `true` to enable Bias-Tee | _unset_ | +| `AIRSPY_ADSB_BIT_PACKING` | `-p` | Set to `true` to enable Bit Packing | _unset_ | +| `AIRSPY_ADSB_VERBOSE` | `-v` | Enable Verbose mode | _unset_ | +| `AIRSPY_ADSB_STATS` | `-S` | Set to `true` to enable statistics in `/run/airspy_adsb` (this needs to be shared with a `tar1090` instance) | _unset_ | +| `AIRSPY_ADSB_ARCH` | N/A | Forces a specific architecture binary. Supports `arm64`, `armv7`, `arm`, `nehalem`, `x86_64` or `i386`. If unset, will auto-detect. | _unset_ | ## Using with `readsb` ```yaml -version: '3.8' +version: "3.8" volumes: readsbpb_rrd: diff --git a/rootfs/etc/s6-overlay/scripts/airspy_adsb b/rootfs/etc/s6-overlay/scripts/airspy_adsb index e5e4efc..72e31f5 100755 --- a/rootfs/etc/s6-overlay/scripts/airspy_adsb +++ b/rootfs/etc/s6-overlay/scripts/airspy_adsb @@ -134,10 +134,10 @@ if [[ -z "$AIRSPY_ADSB_ARCH" ]]; then elif /usr/local/bin/airspy_adsb.i386 -h > /dev/null 2>&1; then AIRSPY_ADSB_ARCH="i386" - + else >&2 echo "[airspy_adsb] ERROR: Unsupported architecture: $(uname -m)!" - sleep infinity + sleep infinity fi fi @@ -147,13 +147,13 @@ AIRSPY_ADSB_BIN="/usr/local/bin/airspy_adsb.${AIRSPY_ADSB_ARCH}" # Ensure binary exists if [[ ! -x "$AIRSPY_ADSB_BIN" ]]; then >&2 echo "[airspy_adsb] ERROR: Executable binary not found for architecture: $AIRSPY_ADSB_ARCH!" - sleep infinity + sleep infinity fi # Ensure binary runnable if ! "$AIRSPY_ADSB_BIN" -h > /dev/null 2>&1; then >&2 echo "[airspy_adsb] ERROR: Executable $AIRSPY_ADSB_ARCH binary not supported on $(uname -m) architecture!" - sleep infinity + sleep infinity fi # Execute binary with arguments prepared above