From 4dede00b1f2fe72272883e4bb96e78cc992e738d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20P=C4=99dzich?= Date: Fri, 28 Feb 2025 15:34:31 +0100 Subject: [PATCH] ci: add CI/CD GitHub workflows and issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 30 +++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 19 ++++++ .github/dependabot.yaml | 36 ++++++++++ .github/workflows/cargo_deny.yaml | 35 ++++++++++ .github/workflows/cd.yaml | 58 ++++++++++++++++ .github/workflows/check_msrv.yaml | 39 +++++++++++ .github/workflows/ci.yaml | 81 +++++++++++++++++++++++ README.md | 2 +- 8 files changed, 299 insertions(+), 1 deletion(-) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/dependabot.yaml create mode 100644 .github/workflows/cargo_deny.yaml create mode 100644 .github/workflows/cd.yaml create mode 100644 .github/workflows/check_msrv.yaml create mode 100644 .github/workflows/ci.yaml diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..9abbac3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,30 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: bug +assignees: '' +--- + +**Description** +A description of what the bug is. + +**Example** +A [minimal reproducible code example](https://stackoverflow.com/help/minimal-reproducible-example) where the bug happens. + +**Expected behavior** +A description of what you expected to happen. + +**Actual behavior** +A description of what actually happens. + +**Environment** +- OS: [e.g. Windows/MacOS/Linux] +- Rust version: [e.g. 1.78.0] +- Crate version: [e.g. 1.0.0] +- F1 game [F1 24/23/22] +- Platform [PC/Xbox/PlayStation] +- Packet format [2024/2023/2022] + +**Additional context** +Any other context about the bug here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..acb0040 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,19 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: enhancement +assignees: '' +--- + +**Problem** +A description of what is the problem that can be fixed with the feature you propose. + +**Feature** +A description of the feature you propose. + +**Examples** +One or more code examples that shows the feature in action. + +**Additional context** +Any other context about the feature request here. diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..5bf9b3f --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,36 @@ +# Dependabot +version: 2 + +updates: + - package-ecosystem: cargo + directory: / + schedule: + interval: weekly + day: friday + allow: + - dependency-type: all + groups: + patch-updates: + patterns: + - "*" + update-types: + - "patch" + minor-updates: + patterns: + - "*" + update-types: + - "minor" + major-updates: + patterns: + - "*" + update-types: + - "major" + + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + groups: + github-actions-updates: + patterns: + - "*" \ No newline at end of file diff --git a/.github/workflows/cargo_deny.yaml b/.github/workflows/cargo_deny.yaml new file mode 100644 index 0000000..ea1f547 --- /dev/null +++ b/.github/workflows/cargo_deny.yaml @@ -0,0 +1,35 @@ +# Check for licenses and advisores +# ../../deny.toml +name: Cargo Deny + +on: + workflow_call: + workflow_dispatch: + +jobs: + cargo-deny: + runs-on: ubuntu-latest + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Cargo deny + uses: EmbarkStudios/cargo-deny-action@v2 + + cargo-audit: + runs-on: ubuntu-latest + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - uses: taiki-e/install-action@v2 + with: + tool: cargo-audit + + - run: cargo audit \ No newline at end of file diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml new file mode 100644 index 0000000..cf77bf2 --- /dev/null +++ b/.github/workflows/cd.yaml @@ -0,0 +1,58 @@ +name: Release-plz + +permissions: + pull-requests: write + contents: write + +on: + push: + branches: + - master + +jobs: + + # Release unpublished packages. + release-plz-release: + name: Release-plz release + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + - name: Run release-plz + uses: release-plz/action@v0.5 + with: + command: release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + + # Create a PR with the new versions and changelog, preparing the next release. + release-plz-pr: + name: Release-plz PR + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + concurrency: + group: release-plz-${{ github.ref }} + cancel-in-progress: false + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + - name: Run release-plz + uses: release-plz/action@v0.5 + with: + command: release-pr + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/.github/workflows/check_msrv.yaml b/.github/workflows/check_msrv.yaml new file mode 100644 index 0000000..048fec8 --- /dev/null +++ b/.github/workflows/check_msrv.yaml @@ -0,0 +1,39 @@ +name: Check MSRV + +on: + workflow_call: + workflow_dispatch: + +jobs: + check-msrv: + runs-on: ubuntu-latest + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - uses: cargo-bins/cargo-binstall@main + + - name: Install cargo-msrv + uses: taiki-e/install-action@v2 + with: + tool: cargo-msrv + + - name: Get current msrv + id: data-msrv + run: | + current_msrv=$(cargo msrv show --output-format minimal); + echo "current msrv: $current_msrv"; + echo "current=$current_msrv" >> "$GITHUB_OUTPUT"; + + - name: Run cargo msrv + run: cargo msrv verify --min ${{ steps.data-msrv.outputs.current }} + + - name: echo msrv info + if: failure() + run: |- + echo "current msrv: ${{ steps.data-msrv.outputs.current }}"; + new_msrv=$(cargo msrv show --output-format minimal); + echo "new msrv: $new_msrv"; \ No newline at end of file diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..0d70481 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,81 @@ +name: "CI" + +on: + merge_group: + workflow_dispatch: + workflow_call: + pull_request: + push: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + clippy: + name: Cargo Clippy + runs-on: ubuntu-latest + + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: clippy + + - name: Clippy check + run: cargo clippy --workspace --all-targets --all-features -- -Dwarnings + + rustfmt: + name: Rustfmt + runs-on: ubuntu-latest + + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: rustfmt + + - name: Rustfmt check + run: cargo fmt --all --check + + test-suite: + name: Test Suite + runs-on: ubuntu-latest + + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Run tests + run: cargo test --workspace --all-features + + docs: + name: Docs + runs-on: ubuntu-latest + + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Check documentation + env: + RUSTDOCFLAGS: -D warnings + run: cargo doc --workspace --all-features + + cargo-deny: + uses: ./.github/workflows/cargo_deny.yaml + + check-msrv: + uses: ./.github/workflows/check_msrv.yaml diff --git a/README.md b/README.md index 3aff08a..09cfbfd 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This is a Rust crate that allows you to convert binary data from F1 24, F1 23, a Add `f1-game-packet-parser` to your project by running this command: ``` -cargo add f1_game_packet_parser +cargo add f1-game-packet-parser ``` ## Example