Skip to content

Commit

Permalink
linting and pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fredclausen committed Oct 12, 2023
1 parent 1b6b1d9 commit b5188ab
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 35 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 @@ -3,4 +3,4 @@
.github
.gitattributes
READMETEMPLATE.md
README.md
README.md
9 changes: 4 additions & 5 deletions .github/workflows/cancel_dupes.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/markdownlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
- main
# only run these if markdown files are updated
paths:
- '**.md'
- '**.MD'
- "**.md"
- "**.MD"

jobs:
markdownlint:
Expand Down
16 changes: 7 additions & 9 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:

shellcheck:
name: Run shellcheck against shell scripts
runs-on: ubuntu-latest
Expand Down Expand Up @@ -56,7 +55,6 @@ jobs:
- linux/arm/v7
- linux/i386
steps:

# Check out our code
- name: Checkout
uses: actions/checkout@v4
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 @@ -7,7 +7,7 @@ on:
- main
# only run when yaml files are updated
paths:
- '**.yml'
- "**.yml"

jobs:
yamllint:
Expand Down
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 @@ -2,6 +2,7 @@ FROM ghcr.io/sdr-enthusiasts/docker-baseimage:base

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

# hadolint ignore=DL3008,SC2086,SC2039,SC2068
RUN set -x && \
TEMP_PACKAGES=() && \
KEPT_PACKAGES=() && \
Expand Down
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ More information on [beast-splitter][1] is available at the [official repository

## Environment Variables

| Variable | Controls which `beast-splitter` option | Description | Default |
| -------- | -------------------------------------- | ----------- | ------- |
| `BEAST_SPLITTER_SERIAL` | `--serial` | Read from given serial device, set to `OFF` to disable serial | `/dev/beast` |
| `BEAST_SPLITTER_NET` | `--net` | Read from given network host:port | Unset |
| `BEAST_SPLITTER_BAUD` | `--fixed-baud` | Set a fixed baud rate, or 0 for autobauding | `0` |
| `BEAST_SPLITTER_LISTEN` | `--listen` | Specify a `[host:]port[:settings]` to listen on | `0.0.0.0:30005:R` |
| `BEAST_SPLITTER_CONNECT` | `--connect` | Specify a `host:port[:settings]` to connect to | Unset |
| `BEAST_SPLITTER_FORCE` | `--force` | Specify settings to force on or off when configuring the Beast | Unset |
| Variable | Controls which `beast-splitter` option | Description | Default |
| ------------------------ | -------------------------------------- | -------------------------------------------------------------- | ----------------- |
| `BEAST_SPLITTER_SERIAL` | `--serial` | Read from given serial device, set to `OFF` to disable serial | `/dev/beast` |
| `BEAST_SPLITTER_NET` | `--net` | Read from given network host:port | Unset |
| `BEAST_SPLITTER_BAUD` | `--fixed-baud` | Set a fixed baud rate, or 0 for autobauding | `0` |
| `BEAST_SPLITTER_LISTEN` | `--listen` | Specify a `[host:]port[:settings]` to listen on | `0.0.0.0:30005:R` |
| `BEAST_SPLITTER_CONNECT` | `--connect` | Specify a `host:port[:settings]` to connect to | Unset |
| `BEAST_SPLITTER_FORCE` | `--force` | Specify settings to force on or off when configuring the Beast | Unset |

## Example `docker run`

Expand All @@ -31,15 +31,15 @@ docker run \
## Example `docker-compose.yml` service

```yaml
beast-splitter:
image: ghcr.io/sdr-enthusiasts/docker-beast-splitter:latest
tty: true
container_name: beast-splitter
restart: always
devices:
- /dev/beast:/dev/beast
ports:
- 30005:30005
beast-splitter:
image: ghcr.io/sdr-enthusiasts/docker-beast-splitter:latest
tty: true
container_name: beast-splitter
restart: always
devices:
- /dev/beast:/dev/beast
ports:
- 30005:30005
```
## Testing the container
Expand Down

0 comments on commit b5188ab

Please sign in to comment.