Skip to content

Commit

Permalink
linting / pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fredclausen committed Oct 10, 2023
1 parent f7ec262 commit 4657b07
Show file tree
Hide file tree
Showing 20 changed files with 411 additions and 323 deletions.
1 change: 1 addition & 0 deletions .dictionary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
crate
9 changes: 4 additions & 5 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'
- 'Check Linting'
- 'Tests'
types: ['requested']
- "Deploy to Docker Hub"
- "Check Linting"
- "Tests"
types: ["requested"]

jobs:
cancel-duplicate-workflow-runs:
Expand All @@ -18,4 +18,3 @@ jobs:
cancelMode: allDuplicates
token: ${{ secrets.GITHUB_TOKEN }}
sourceRunId: ${{ github.event.workflow_run.id }}

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
4 changes: 2 additions & 2 deletions .hadolint.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ignored:
ignored:
- DL3003
- DL3007
- DL3008
- SC3054
- SC3044
- SC3044
10 changes: 5 additions & 5 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"MD024": false,
"MD013": false,
"MD033": false,
"MD029": false
}
"MD024": false,
"MD013": false,
"MD033": false,
"MD029": false
}
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"]
8 changes: 4 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"yaml.schemas": {
"https://json.schemastore.org/github-workflow.json": "file:https:///Users/ramon_kolb/github/docker-adsb-ultrafeeder/.github/workflows/deploy.yml"
}
}
"yaml.schemas": {
"https://json.schemastore.org/github-workflow.json": "file:https:///Users/ramon_kolb/github/docker-adsb-ultrafeeder/.github/workflows/deploy.yml"
}
}
48 changes: 24 additions & 24 deletions README-grafana.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ services:

Prometheus will store a lot of data, and Grafana will do a lot of data queries. As a result, it would be better if you run these containers on a different system than your feeder Raspberry Pi. This will leave your Pi focused on data collection and processing, and unbothered by the CPU and Disk IO load that Prometheus/Grafana will cause.

You *can* do it on a single system. We're assuming below that you are not. If you do it on a single system, then you can combine the `docker-compose.yml` components in a single file
You _can_ do it on a single system. We're assuming below that you are not. If you do it on a single system, then you can combine the `docker-compose.yml` components in a single file

## Steps to install Prometheus, Grafana, and the Grafana Dashboard

Expand All @@ -52,11 +52,11 @@ You *can* do it on a single system. We're assuming below that you are not. If yo
- Edit your Ultrafeeder's `docker-compose.yml` file and ensure that the following is set for the `ultrafeeder` service:

```yaml
environment:
- PROMETHEUS_ENABLE=true
- TAR1090_ENABLE_AC_DB=true
ports:
- 9273-9274:9273-9274
environment:
- PROMETHEUS_ENABLE=true
- TAR1090_ENABLE_AC_DB=true
ports:
- 9273-9274:9273-9274
```

Now recreate the ultrafeeder container (`docker-compose up -d ultrafeeder`) and it will generate Prometheus data.
Expand All @@ -71,7 +71,7 @@ cd /opt/grafana
cat > docker-compose.yml
```

Now paste in the following text *):
Now paste in the following text \*):

<details>
<summary>&lt;&dash;&dash; Click the arrow to see the <code>docker-compose.yml</code> text</summary>
Expand Down Expand Up @@ -149,7 +149,7 @@ services:

</details>

*) The volume definition structure is written this way purposely to ensure that the containers can place files in the persistent directories. Do not try to "directly" map volumes (`/opt/grafana/grafana/appdata:/var/lib/grafana`).
\*) The volume definition structure is written this way purposely to ensure that the containers can place files in the persistent directories. Do not try to "directly" map volumes (`/opt/grafana/grafana/appdata:/var/lib/grafana`).

You should be able to see the following directories:

Expand Down Expand Up @@ -178,9 +178,9 @@ docker compose up -d
This will add the following to the bottom of the `prometheus.xml` file:

```yaml
- job_name: 'ultrafeeder'
static_configs:
- targets: ['ip_xxxxxxx:9273', 'ip_xxxxxxx:9274']
- job_name: "ultrafeeder"
static_configs:
- targets: ["ip_xxxxxxx:9273", "ip_xxxxxxx:9274"]
```

(If you screw this up, **do NOT** re-run the command. Instead, try `sudo nano /opt/grafana/prometheus/config/prometheus.yml` and fix it that way.)
Expand All @@ -198,9 +198,9 @@ docker compose up -d
This will add the following to the bottom of the `prometheus.xml` file:

```yaml
- job_name: 'dump978'
static_configs:
- targets: ['ip_xxxxxxx:9274']
- job_name: "dump978"
static_configs:
- targets: ["ip_xxxxxxx:9274"]
```

(If you screw this up, **do NOT** re-run the command. Instead, try `sudo nano /opt/grafana/prometheus/config/prometheus.yml` and fix it that way.)
Expand All @@ -222,10 +222,10 @@ After you have logged into the `grafana` console the following manual steps are
2. Click `Prometheus` from the list of options provided
3. Input or select the following options, if the option is not listed, do not input anything for that option:

Option | Input
------------- | -------------
Name | ultrafeeder
URL | `https://prometheus:9090/`
| Option | Input |
| ------ | ------------------------- |
| Name | ultrafeeder |
| URL | `https://prometheus:9090/` |

Clicking `Save & Test` should return a green message indicating success. The dashboard can now be imported with the following steps:

Expand Down Expand Up @@ -261,12 +261,12 @@ First execute all steps above, and then continue here.
### Step 1: Edit your Prometheus config file so the `job_name`s look like this

```yaml
- job_name: 'heerlen'
static_configs:
- targets: ['10.0.0.100:9273', '10.0.0.100:9274']
- job_name: 'trenton'
static_configs:
- targets: ['10.0.0.101:9273', '10.0.0.101:9274']
- job_name: "heerlen"
static_configs:
- targets: ["10.0.0.100:9273", "10.0.0.100:9274"]
- job_name: "trenton"
static_configs:
- targets: ["10.0.0.101:9273", "10.0.0.101:9274"]
```

Here, `10.0.0.100` is the IP address of the `heerlen` station, and `10.0.0.101` is the IP address of the `trenton` station. Yours will be different. Please keep the ports as you mapped them for Ultrafeeder in each instance. You should have a `- job_name` block for each ultrafeeder instance.
Expand Down
Loading

0 comments on commit 4657b07

Please sign in to comment.