Skip to content

Commit

Permalink
precommit/linting
Browse files Browse the repository at this point in the history
  • Loading branch information
fredclausen committed Oct 12, 2023
1 parent 663e8b8 commit e7058f3
Show file tree
Hide file tree
Showing 13 changed files with 135 additions and 57 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 Docker Hub'
- 'Linting'
- 'Tests'
types: ['requested']
- "Deploy to Docker Hub"
- "Linting"
- "Tests"
types: ["requested"]

jobs:
cancel-duplicate-workflow-runs:
Expand Down
38 changes: 17 additions & 21 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +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 --ignore SC1091 --ignore DL3013 $(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 --ignore SC1091 --ignore DL3013 $(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,~MD029 $(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,~MD029 $(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 @@ -18,17 +18,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 @@ -38,19 +35,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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,3 @@ pip-selfcheck.json
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)

.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: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ COPY rootfs/ /

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# hadolint ignore=DL3008,SC2086,SC2039,SC2068
RUN set -x && \
dpkg --add-architecture armhf && \
TEMP_PACKAGES=() && \
Expand Down
2 changes: 1 addition & 1 deletion README.DockerHub.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ For more information on what `pfclient` is, see here: <https://planefinder.net/s

## Documentation

Please [read this container's detailed and thorough documentation in the GitHub repository.](https://github.com/sdr-enthusiasts/docker-readsb-protobuf/blob/main/README.md)
Please [read this container's detailed and thorough documentation in the GitHub repository.](https://github.com/sdr-enthusiasts/docker-readsb-protobuf/blob/main/README.md)
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ For more information on what `pfclient` is, see here: <https://planefinder.net/s

## Supported tags and respective Dockerfiles

* `latest` (`master` branch, `Dockerfile`)
* Version and architecture specific tags available
* `development` (`dev` branch, `Dockerfile`, not recommended for production)
- `latest` (`master` branch, `Dockerfile`)
- Version and architecture specific tags available
- `development` (`dev` branch, `Dockerfile`, not recommended for production)

## Obtaining a PlaneFinder Share Code

Expand Down Expand Up @@ -84,7 +84,7 @@ docker run \
## Up-and-Running with Docker Compose

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

services:
pfclient:
Expand Down Expand Up @@ -115,25 +115,25 @@ Once your container is up and running, you should claim your receiver.
There are a series of available environment variables:
| Environment Variable | Purpose | Default |
| -------------------- | ------------------------------- | ------- |
| `BEASTHOST` | Required. IP/Hostname of a Mode-S/BEAST provider (dump1090/readsb) | |
| `BEASTPORT` | Optional. TCP port number of Mode-S/BEAST provider (dump1090/readsy) | 30005 |
| `SHARECODE` | Required. PlaneFinder Share Code | |
| `LAT` | Required. Latitude of the antenna | |
| `LONG` | Required. Longitude of the antenna | |
| `TZ` | Optional. Your local timezone | GMT |
| Environment Variable | Purpose | Default |
| -------------------- | -------------------------------------------------------------------- | ------- |
| `BEASTHOST` | Required. IP/Hostname of a Mode-S/BEAST provider (dump1090/readsb) | |
| `BEASTPORT` | Optional. TCP port number of Mode-S/BEAST provider (dump1090/readsy) | 30005 |
| `SHARECODE` | Required. PlaneFinder Share Code | |
| `LAT` | Required. Latitude of the antenna | |
| `LONG` | Required. Longitude of the antenna | |
| `TZ` | Optional. Your local timezone | GMT |

## Ports

The following ports are used by this container:

* `30053` - `pfclient` web GUI. Suggest mapping this port for the web GUI.
* `30054` - `pfclient` "echo port". Suggest leaving this port unmapped.
- `30053` - `pfclient` web GUI. Suggest mapping this port for the web GUI.
- `30054` - `pfclient` "echo port". Suggest leaving this port unmapped.

## 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
3 changes: 1 addition & 2 deletions rootfs/etc/s6-overlay/scripts/pfclient
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#shellcheck shell=bash

# Test pfclient can run natively (without qemu)
if /usr/local/bin/pfclient --version > /dev/null 2>&1; then
if /usr/local/bin/pfclient --version > /dev/null 2>&1; then
# pfclient can be run natively
s6-setuidgid nobody /usr/local/bin/pfclient \
--connection_type=1 \
Expand Down Expand Up @@ -32,4 +32,3 @@ else
--log_path=/var/log/pfclient \
2>&1 | mawk -W Interactive '{print "[pfclient_daemon] " $0}'
fi

3 changes: 1 addition & 2 deletions rootfs/firstrun
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#shellcheck shell=bash

# Test pfclient can run natively (without qemu)
if /usr/local/bin/pfclient --version > /dev/null 2>&1; then
if /usr/local/bin/pfclient --version > /dev/null 2>&1; then
# pfclient can be run natively
s6-setuidgid nobody /usr/local/bin/pfclient

Expand All @@ -11,4 +11,3 @@ else
s6-setuidgid nobody qemu-arm-static /usr/local/bin/pfclient

fi

1 change: 1 addition & 0 deletions rootfs/scripts/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/command/with-contenv bash
#shellcheck shell=bash

# Import healthchecks-framework
# shellcheck disable=SC1091
Expand Down

0 comments on commit e7058f3

Please sign in to comment.