From a1cc3edcd9b81a64ef0a436253c95666930a135d Mon Sep 17 00:00:00 2001 From: Srylax Date: Tue, 7 May 2024 09:48:40 +0200 Subject: [PATCH] feat(ci): :sparkles: Add MSRV and CI --- .github/ISSUE_TEMPLATE/0_feature_requests.yml | 24 +++ .github/ISSUE_TEMPLATE/1_bug_report.yml | 23 +++ .../\360\237\220\234-bug-report.md" | 44 ------ .../\360\237\232\200-feature-request.md" | 28 ---- .github/workflows/audit.yaml | 36 +++++ .github/workflows/ci.yaml | 137 ++++++++++++++++++ .github/workflows/committed.yaml | 28 ++++ .github/workflows/spelling.yaml | 25 ++++ Cargo.toml | 2 + 9 files changed, 275 insertions(+), 72 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/0_feature_requests.yml create mode 100644 .github/ISSUE_TEMPLATE/1_bug_report.yml delete mode 100644 ".github/ISSUE_TEMPLATE/\360\237\220\234-bug-report.md" delete mode 100644 ".github/ISSUE_TEMPLATE/\360\237\232\200-feature-request.md" create mode 100644 .github/workflows/audit.yaml create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/committed.yaml create mode 100644 .github/workflows/spelling.yaml diff --git a/.github/ISSUE_TEMPLATE/0_feature_requests.yml b/.github/ISSUE_TEMPLATE/0_feature_requests.yml new file mode 100644 index 0000000..6245427 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/0_feature_requests.yml @@ -0,0 +1,24 @@ +name: 🚀 Feature Request +description: "Suggest a feature / idea" +labels: [ "enhancement" ] +body: + - type: checkboxes + attributes: + label: Check for existing issues + description: Check the backlog of issues to reduce the chances of creating duplicates; if an issue already exists, place a `+1` (👍) on it. + options: + - label: Completed + required: true + - type: textarea + attributes: + label: Describe the feature + description: A clear and concise description of what you want to happen. + validations: + required: true + - type: textarea + attributes: + label: | + If applicable, add mockups / screenshots to help present your vision of the feature + description: Drag images into the text input below + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/1_bug_report.yml b/.github/ISSUE_TEMPLATE/1_bug_report.yml new file mode 100644 index 0000000..80dfce5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/1_bug_report.yml @@ -0,0 +1,23 @@ +name: 🐜 Bug report +description: "Create a bug report to help us improve" +labels: [ "defect" ] +body: + - type: checkboxes + attributes: + label: Check for existing issues + description: Check the backlog of issues to reduce the chances of creating duplicates; if an issue already exists, place a `+1` (👍) on it. + options: + - label: Completed + required: true + - type: textarea + attributes: + label: Describe the bug / provide steps to reproduce it + description: A clear and concise description of what the bug is. + validations: + required: true + - type: textarea + attributes: + label: If applicable, add mockups / screenshots to help explain present your vision of the feature + description: Drag issues into the text input below + validations: + required: false \ No newline at end of file diff --git "a/.github/ISSUE_TEMPLATE/\360\237\220\234-bug-report.md" "b/.github/ISSUE_TEMPLATE/\360\237\220\234-bug-report.md" deleted file mode 100644 index 9c71bda..0000000 --- "a/.github/ISSUE_TEMPLATE/\360\237\220\234-bug-report.md" +++ /dev/null @@ -1,44 +0,0 @@ ---- -name: "\U0001F41C Bug report" -about: Create a bug report to help us improve -title: '' -labels: Bug Report -assignees: '' - ---- - -### Describe the bug - - - - - -### Steps to reproduce - -1. -2. -3. - -### Expected behavior - - - -### crate version - -### Operating system - - - -### Log - - -````paste below -```` - -### Screenshots - - - -### Additional information - - diff --git "a/.github/ISSUE_TEMPLATE/\360\237\232\200-feature-request.md" "b/.github/ISSUE_TEMPLATE/\360\237\232\200-feature-request.md" deleted file mode 100644 index c6c206d..0000000 --- "a/.github/ISSUE_TEMPLATE/\360\237\232\200-feature-request.md" +++ /dev/null @@ -1,28 +0,0 @@ ---- -name: "\U0001F680 Feature request" -about: Suggest a feature / idea -title: '' -labels: enhancement -assignees: '' - ---- - -### Is your feature request related to a problem? - - - -As a -I want to -so that I can - -### Provide a detailed description of the proposed feature - - - -### Alternatives you've considered - - - -### Additional information - - diff --git a/.github/workflows/audit.yaml b/.github/workflows/audit.yaml new file mode 100644 index 0000000..7f8839e --- /dev/null +++ b/.github/workflows/audit.yaml @@ -0,0 +1,36 @@ +name: Security audit + +permissions: + contents: read + issues: write # to create issues (actions-rs/audit-check) + checks: write # to create check (actions-rs/audit-check) + +on: + pull_request: + paths: + - "**/Cargo.toml" + - "**/Cargo.lock" + push: + branches: + - main + +env: + RUST_BACKTRACE: 1 + CARGO_TERM_COLOR: always + CLICOLOR: 1 + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +jobs: + security_audit: + runs-on: ubuntu-latest + # Prevent sudden announcement of a new advisory from failing ci: + continue-on-error: true + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - uses: actions-rs/audit-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..b8933ec --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,137 @@ +name: CI + +permissions: + contents: read + +on: + pull_request: + push: + branches: + - main + +env: + RUST_BACKTRACE: 1 + CARGO_TERM_COLOR: always + CLICOLOR: 1 + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +jobs: + ci: + permissions: + contents: none + name: CI + needs: [test, msrv, lockfile, docs, rustfmt, clippy] + runs-on: ubuntu-latest + if: "always()" + steps: + - name: Failed + run: exit 1 + if: "contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped')" + test: + name: Test + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + - uses: Swatinem/rust-cache@v2 + - uses: taiki-e/install-action@cargo-hack + - name: Build + run: cargo test --no-run + - name: Test + run: cargo hack test --feature-powerset + msrv: + name: "Check MSRV" + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + - uses: Swatinem/rust-cache@v2 + - uses: taiki-e/install-action@cargo-hack + - name: Default features + run: cargo hack check --feature-powerset --locked --rust-version --ignore-private --all-targets + lockfile: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + - uses: Swatinem/rust-cache@v2 + - name: "Is lockfile updated?" + run: cargo update --locked + docs: + name: Docs + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + - uses: Swatinem/rust-cache@v2 + - name: Check documentation + env: + RUSTDOCFLAGS: -D warnings + run: cargo doc --all-features --no-deps --document-private-items + rustfmt: + name: rustfmt + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + components: rustfmt + - uses: Swatinem/rust-cache@v2 + - name: Check formatting + run: cargo fmt --all -- --check --config format_code_in_doc_comments=true + clippy: + name: clippy + runs-on: ubuntu-latest + permissions: + contents: read + actions: read + security-events: write # to upload sarif results + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + components: clippy + - uses: Swatinem/rust-cache@v2 + - name: Install SARIF tools + run: cargo install clippy-sarif --locked + - name: Install SARIF tools + run: cargo install sarif-fmt --locked + - name: Check + run: > + cargo clippy --all-targets --message-format=json -- -D warnings + | clippy-sarif + | tee clippy-results.sarif + | sarif-fmt + continue-on-error: true + - name: Upload + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: clippy-results.sarif + wait-for-processing: true + - name: Report status + run: cargo clippy --all-features --all-targets -- -D warnings diff --git a/.github/workflows/committed.yaml b/.github/workflows/committed.yaml new file mode 100644 index 0000000..b206f84 --- /dev/null +++ b/.github/workflows/committed.yaml @@ -0,0 +1,28 @@ +# Not run as part of pre-commit checks because they don't handle sending the correct commit +# range to `committed` +name: Lint Commits +on: [pull_request] + +permissions: + contents: read + +env: + RUST_BACKTRACE: 1 + CARGO_TERM_COLOR: always + CLICOLOR: 1 + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +jobs: + committed: + name: Lint Commits + runs-on: ubuntu-latest + steps: + - name: Checkout Actions Repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Lint Commits + uses: crate-ci/committed@master \ No newline at end of file diff --git a/.github/workflows/spelling.yaml b/.github/workflows/spelling.yaml new file mode 100644 index 0000000..f72a784 --- /dev/null +++ b/.github/workflows/spelling.yaml @@ -0,0 +1,25 @@ +name: Spelling + +permissions: + contents: read + +on: [pull_request] + +env: + RUST_BACKTRACE: 1 + CARGO_TERM_COLOR: always + CLICOLOR: 1 + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +jobs: + spelling: + name: Spell Check with Typos + runs-on: ubuntu-latest + steps: + - name: Checkout Actions Repository + uses: actions/checkout@v4 + - name: Spell Check Repo + uses: crate-ci/typos@master \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index c3c82c4..e782655 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,8 @@ [package] name = "mongodb-cursor-pagination" version = "1.0.0-rc.1" +rust-version = "1.78.0" + authors = ["Kylian Lichtensteiger