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 12, 2023
1 parent 5b6965b commit 4b21b99
Show file tree
Hide file tree
Showing 11 changed files with 136 additions and 59 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'
- 'Linting'
- 'Tests'
types: ['requested']
- "Deploy"
- "Linting"
- "Tests"
types: ["requested"]

jobs:
cancel-duplicate-workflow-runs:
Expand Down
39 changes: 17 additions & 22 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,38 @@ name: Linting

on:
pull_request:
branches:
branches:
- master
- main

jobs:

shellcheck:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Pull koalaman/shellcheck:stable Image
run: docker pull koalaman/shellcheck:stable
- name: Run Shellcheck against shell scripts
run: docker run --rm -i -v "$PWD:/mnt" koalaman/shellcheck:stable $(find . -type f -exec grep -m1 -l -E '^#!.*sh.*' {} \; | grep -v '/.git/')
# docker run --rm -i -v "$PWD:/mnt" koalaman/shellcheck:stable $(find . -type f -exec grep -m1 -l -E '^#!.*execline.*' {} \; | grep -v '/.git/')
- uses: actions/checkout@v4
- name: Pull koalaman/shellcheck:stable Image
run: docker pull koalaman/shellcheck:stable
- name: Run Shellcheck against shell scripts
run: docker run --rm -i -v "$PWD:/mnt" koalaman/shellcheck:stable $(find . -type f -exec grep -m1 -l -E '^#!.*sh.*' {} \; | grep -v '/.git/')
# docker run --rm -i -v "$PWD:/mnt" koalaman/shellcheck:stable $(find . -type f -exec grep -m1 -l -E '^#!.*execline.*' {} \; | grep -v '/.git/')

hadolint:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Pull hadolint/hadolint:latest Image
run: docker pull hadolint/hadolint:latest
- name: Run hadolint against Dockerfiles
run: docker run --rm -i -v "$PWD":/workdir --workdir /workdir --entrypoint hadolint hadolint/hadolint --ignore DL3008 --ignore SC2068 $(find . -type f -iname "Dockerfile*")
- uses: actions/checkout@v4
- name: Pull hadolint/hadolint:latest Image
run: docker pull hadolint/hadolint:latest
- name: Run hadolint against Dockerfiles
run: docker run --rm -i -v "$PWD":/workdir --workdir /workdir --entrypoint hadolint hadolint/hadolint --ignore DL3008 --ignore SC2068 $(find . -type f -iname "Dockerfile*")

markdownlint:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Pull markdownlint/markdownlint:latest Image
run: docker pull markdownlint/markdownlint:latest
- name: Run markdownlint against *.md files
run: docker run --rm -i -v "$(pwd)":/workdir --workdir /workdir markdownlint/markdownlint:latest --rules ~MD013,~MD033 $(find . -type f -iname '*.md' | grep -v '/.git/')

- uses: actions/checkout@v4
- name: Pull markdownlint/markdownlint:latest Image
run: docker pull markdownlint/markdownlint:latest
- name: Run markdownlint against *.md files
run: docker run --rm -i -v "$(pwd)":/workdir --workdir /workdir markdownlint/markdownlint:latest --rules ~MD013,~MD033 $(find . -type f -iname '*.md' | grep -v '/.git/')
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
16 changes: 5 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,14 @@ jobs:
- linux/arm/v7
- linux/i386
steps:

# Check out our code
-
name: Checkout
- name: Checkout
uses: actions/checkout@v4

# Hit an issue where arm builds would fail with cURL errors regarding intermediary certificates when downloading from github (ie: deploy-s6-overlay).
# After many hours of troubleshooting, the workaround is to pre-load the image's rootfs with the CA certificates from the runner.
# This problem may go away in future.
-
name: Copy CA Certificates from GitHub Runner to Image rootfs
- name: Copy CA Certificates from GitHub Runner to Image rootfs
run: |
ls -la /etc/ssl/certs/
mkdir -p ./rootfs/etc/ssl/certs
Expand All @@ -39,19 +36,16 @@ jobs:
cp --no-dereference /usr/share/ca-certificates/mozilla/*.crt ./rootfs/usr/share/ca-certificates/mozilla
# Set up QEMU for multi-arch builds
-
name: Set up QEMU
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

# Set up buildx for multi platform builds
-
name: Set up Docker Buildx
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3

# Test container build for all supported platforms (defined above)
-
name: Test Build ${{ matrix.docker-platform }}
- name: Test Build ${{ matrix.docker-platform }}
uses: docker/build-push-action@v5
with:
context: .
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ Temporary Items
!.vscode/extensions.json
*.code-workspace

# End of https://www.toptal.com/developers/gitignore/api/macos,vscode
# End of https://www.toptal.com/developers/gitignore/api/macos,vscode
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"]
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ RUN set -x && \
chmod 755 /usr/bin/adsbhub.sh
# Add healthcheck
HEALTHCHECK --start-period=3600s --interval=600s CMD /scripts/healthcheck.sh

4 changes: 2 additions & 2 deletions README.DockerHub.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
[![Docker Image Size (tag)](https://img.shields.io/docker/image-size/mikenye/adsbhub/latest)](https://hub.docker.com/r/mikenye/adsbhub)
[![Discord](https://img.shields.io/discord/734090820684349521)](https://discord.gg/sTf9uYF)

Docker container to send ADS-B data to [ADSBHub](https://www.adsbhub.org). Designed to work in tandem with [sdr-enthusiasts/docker-readsb-protobuf](https://github.com/sdr-enthusiasts/docker-readsb-protobuf). Builds and runs on `x86`, `x86_64`, `arm64`, `arm32v7` annd `arm32v6`.
Docker container to send ADS-B data to [ADSBHub](https://www.adsbhub.org). Designed to work in tandem with [sdr-enthusiasts/docker-readsb-protobuf](https://github.com/sdr-enthusiasts/docker-readsb-protobuf). Builds and runs on `x86`, `x86_64`, `arm64`, `arm32v7` and `arm32v6`.

This container pulls SBS/Basestation protocol data from a host or container, and sends the data to ADSBHub.

## Documentation

Please [read this container's detailed and thorough documentation in the GitHub repository.](https://github.com/sdr-enthusiasts/docker-adsbhub/blob/master/README.md)
Please [read this container's detailed and thorough documentation in the GitHub repository.](https://github.com/sdr-enthusiasts/docker-adsbhub/blob/master/README.md)
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
[![Docker Image Size (tag)](https://img.shields.io/docker/image-size/mikenye/adsbhub/latest)](https://hub.docker.com/r/mikenye/adsbhub)
[![Discord](https://img.shields.io/discord/734090820684349521)](https://discord.gg/sTf9uYF)

Docker container to send ADS-B data to [ADSBHub](https://www.adsbhub.org). Designed to work in tandem with [sdr-enthusiasts/docker-readsb-protobuf](https://github.com/sdr-enthusiasts/docker-readsb-protobuf). Builds and runs on `x86`, `x86_64`, `arm64`, `arm32v7` annd `arm32v6`.
Docker container to send ADS-B data to [ADSBHub](https://www.adsbhub.org). Designed to work in tandem with [sdr-enthusiasts/docker-readsb-protobuf](https://github.com/sdr-enthusiasts/docker-readsb-protobuf). Builds and runs on `x86`, `x86_64`, `arm64`, `arm32v7` and `arm32v6`.

This container pulls SBS/Basestation protocol data from a host or container, and sends the data to ADSBHub.

## Supported tags and respective Dockerfiles

* `latest` (`main` branch, `Dockerfile`)
* Version and architecture specific tags available
- `latest` (`main` branch, `Dockerfile`)
- Version and architecture specific tags available

## First-time users

Expand All @@ -22,9 +22,9 @@ First-time users should obtain a ADSBHub Station dynamic IP key. Follow the dire

In your station preferences, you should set the following:

* Feeder type: `Linux`
* Data Protocol: `SBS`
* Station mode: `Client`
- Feeder type: `Linux`
- Data Protocol: `SBS`
- Station mode: `Client`

## Up-and-Running with `docker run`

Expand Down Expand Up @@ -59,7 +59,7 @@ ghcr.io/sdr-enthusiasts/docker-adsbhub:latest
## Up-and-Running with Docker Compose

```yaml
version: '2.0'
version: "2.0"

services:
adsbhub:
Expand All @@ -77,14 +77,14 @@ services:
The ADSBHub client key is full of special characters, that can be misinterpreted on multiple levels. To avoid that:
* Wrap the environment variable assignment (the whole assignment, not just the key) in single quotation marks so that YAML parses it correctly.
* Duplicate every `$` character. The single `$` sign is the start of a [variable substitution](https://docs.docker.com/compose/compose-file/#variable-substitution) in docker-compose. Use `$$` instead.
- Wrap the environment variable assignment (the whole assignment, not just the key) in single quotation marks so that YAML parses it correctly.
- Duplicate every `$` character. The single `$` sign is the start of a [variable substitution](https://docs.docker.com/compose/compose-file/#variable-substitution) in docker-compose. Use `$$` instead.

If your client key was `abc$123$$$ABC`, your `docker-compose.yml` should look like this:

```yaml
environment:
- 'CLIENTKEY=abc$$123$$$$$$ABC'
- "CLIENTKEY=abc$$123$$$$$$ABC"
```

## Ports
Expand All @@ -93,16 +93,16 @@ No ports are exposed in this container

## Environment variables

| Variable | Description | Required | Default |
|----------|-------------|---------|--------|
| `TZ` | Timezone for the container. | Optional | `UTC` |
| `SBSHOST` | Host for RAW ADSB packets.| Required | Unset |
| `SBSPORT` | Port on SBSHOST that provides beast formatted ADSB packets | Optional | `30003` |
| `CLIENTKEY` | ADSBHub Station Dynamic IP key. | Required | Unset |
| Variable | Description | Required | Default |
| ----------- | ---------------------------------------------------------- | -------- | ------- |
| `TZ` | Timezone for the container. | Optional | `UTC` |
| `SBSHOST` | Host for RAW ADSB packets. | Required | Unset |
| `SBSPORT` | Port on SBSHOST that provides beast formatted ADSB packets | Optional | `30003` |
| `CLIENTKEY` | ADSBHub Station Dynamic IP key. | Required | Unset |

## Logging

* All processes are logged to the container's stdout, and can be viewed with `docker logs [-f] container`.
- All processes are logged to the container's stdout, and can be viewed with `docker logs [-f] container`.

## Getting Help

Expand Down
2 changes: 1 addition & 1 deletion rootfs/CONTAINER_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.06
1.06

0 comments on commit 4b21b99

Please sign in to comment.