From 1244978619ff644601b9460722ee57d2dc3063ba Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Sat, 18 Nov 2023 11:43:20 -0700 Subject: [PATCH] set up repo github actions (precommit and dependabot) as well as pre-commit --- .dictionary.txt | 1 + .github/dependabot.yaml | 27 ++++++++++ .github/workflows/pr-validator.yml | 3 +- .github/workflows/pre-commit-updates.yaml | 23 ++++++++ .pre-commit-config.yaml | 66 +++++++++++++++++++++++ README.md | 5 +- src/strategies.rs | 2 +- 7 files changed, 120 insertions(+), 7 deletions(-) create mode 100644 .dictionary.txt create mode 100644 .github/dependabot.yaml 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/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..667f926 --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,27 @@ +--- +version: 2 + +updates: + # Maintain dependencies for Docker + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: weekly + assignees: + - "fredclausen" + + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: weekly + assignees: + - "fredclausen" + + # Maintain pip packages for acars_router + - package-ecosystem: "cargo" + directory: "/" + schedule: + interval: weekly + assignees: + - "fredclausen" diff --git a/.github/workflows/pr-validator.yml b/.github/workflows/pr-validator.yml index 1a47cf7..9a75f17 100644 --- a/.github/workflows/pr-validator.yml +++ b/.github/workflows/pr-validator.yml @@ -7,7 +7,6 @@ on: jobs: build: - runs-on: ubuntu-latest steps: @@ -15,7 +14,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: toolchain: stable - + - name: Format check run: cargo fmt -- --check - name: Build and Lint diff --git a/.github/workflows/pre-commit-updates.yaml b/.github/workflows/pre-commit-updates.yaml new file mode 100644 index 0000000..effb642 --- /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 * * 0 + +jobs: + update: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.1 + 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/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..3971571 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,66 @@ +repos: + # lint yaml, line and whitespace + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.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.6" # 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.1 + 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.11.0 + hooks: + - id: black + exclude: ^(acars_router/) + + - 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"] + exclude: ^(acars_router/) diff --git a/README.md b/README.md index 5e5c261..c6ed4f1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -stubborn-io -=========== +# stubborn-io This crate provides io traits/structs that automatically recover from potential disconnections/interruptions. @@ -12,7 +11,6 @@ stubborn-io = "0.3" API Documentation, examples and motivations can be found here - https://docs.rs/stubborn-io . - ### Usage Example In this example, we will see a drop in replacement for tokio's TcpStream, with the @@ -32,4 +30,3 @@ let mut tcp_stream = StubbornTcpStream::connect(addr).await?; // call all of the regular methods on it, as seen below tcp_stream.write_all(b"hello world!").await?; ``` - diff --git a/src/strategies.rs b/src/strategies.rs index ea8a707..f23be0a 100644 --- a/src/strategies.rs +++ b/src/strategies.rs @@ -11,7 +11,7 @@ use std::time::Duration; /// /// // With the below strategy, the stubborn-io item will try to reconnect infinitely, /// // waiting an exponentially increasing (by 2) value with 5% random jitter. Once the -/// // wait would otherwise exceed the maxiumum of 30 seconds, it will instead wait 30 +/// // wait would otherwise exceed the maximum of 30 seconds, it will instead wait 30 /// // seconds. /// /// let options = ReconnectOptions::new().with_retries_generator(|| {