From 3a8b96a3b1260692f01076f91dddfde9908b4ea1 Mon Sep 17 00:00:00 2001 From: Yuxiang Cao Date: Thu, 2 Nov 2023 15:59:06 -0700 Subject: [PATCH] ci: setup ci --- .github/ISSUE_TEMPLATE/bug_report.md | 29 +++ .github/ISSUE_TEMPLATE/dependency-update.md | 33 +++ .github/ISSUE_TEMPLATE/feature_request.md | 23 +++ .github/codecov.yml | 8 + .github/dependabot.yml | 15 ++ .github/workflows/build.yml | 213 ++++++++++++++++++++ .github/workflows/ci.yml | 28 --- .gitignore | 12 +- .rustfmt.toml | 2 +- admin/coverage | 10 + 10 files changed, 343 insertions(+), 30 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/dependency-update.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/codecov.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/ci.yml create mode 100755 admin/coverage diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..80d1dac --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,29 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Checklist** +* [ ] I've searched the issue tracker for similar bugs. + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Use one of the examples to connect to `....` +2. ... +3. See error + +**Applicable Version(s)** +A list of versions and platforms you've tested with. + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/dependency-update.md b/.github/ISSUE_TEMPLATE/dependency-update.md new file mode 100644 index 0000000..952f25b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/dependency-update.md @@ -0,0 +1,33 @@ +--- +name: Dependency Update +about: Request a dependency be updated +title: Dependency update request +labels: '' +assignees: '' + +--- + + + +**Checklist** +* [ ] I've searched the issue tracker for similar requests +* [ ] I've confirmed my request is for a semver-incompatible update + +**Is your dependency update request related to a problem? Please describe.** +A clear and concise description of what the problem is. + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..65494eb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,23 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Checklist** +* [ ] I've searched the issue tracker for similar requests + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/codecov.yml b/.github/codecov.yml new file mode 100644 index 0000000..1c9c964 --- /dev/null +++ b/.github/codecov.yml @@ -0,0 +1,8 @@ +coverage: + status: + patch: + default: + threshold: 0.05% + project: + default: + threshold: 0.05% diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..ce1ffcc --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +version: 2 +updates: +- package-ecosystem: cargo + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 10 + groups: + crates-io: + patterns: + - "*" +- package-ecosystem: github-actions + directory: "/" + schedule: + interval: weekly diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..27ad325 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,213 @@ +name: rustls-mbedcrypto-provider + +permissions: + contents: read + +on: + pull_request: + paths-ignore: + - '*.md' + - 'LICENSE' + branches: + - master + merge_group: + schedule: + - cron: '30 13 * * 1,5' + +env: + CARGO_TERM_COLOR: always + CARGO_NET_RETRY: 10 + +jobs: + build: + name: Build+test + runs-on: ${{ matrix.os }} + strategy: + matrix: + # test a bunch of toolchains on ubuntu + rust: + - stable + - beta + - nightly + os: [ubuntu-20.04] + # but only stable on macos/windows (slower platforms) + include: + - os: macos-latest + rust: stable + - os: windows-latest + rust: stable + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + with: + key: ${{ matrix.rust }}-${{ matrix.os }} + + - name: Install ${{ matrix.rust }} toolchain + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.rust }} + + - name: cargo build (debug; default features) + run: cargo build --locked + shell: bash + + - name: cargo test (debug; all features) + run: cargo test --locked --all-features + shell: bash + env: + RUST_BACKTRACE: 1 + + features: + name: Features + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + + - name: Install stable toolchain + uses: dtolnay/rust-toolchain@stable + + - name: cargo build (debug; default features) + run: cargo build --locked + + - name: cargo test (debug; default features) + run: cargo test --locked + env: + RUST_BACKTRACE: 1 + + - name: cargo test (debug; no default features) + run: cargo test --locked --no-default-features + + - name: cargo test (rustls_mbedcrypto_provider; debug; no default features; tls12) + run: cargo test --locked --no-default-features --features tls12 --package rustls-mbedcrypto-provider + + - name: cargo test (rustls_mbedcrypto_provider; debug; no default features; tls12, rdrand) + run: cargo test --locked --no-default-features --features tls12,rdrand --package rustls-mbedcrypto-provider + + - name: cargo test (release; no run) + run: cargo test --locked --release --no-run + +# TODO: add fuzz tests +# TODO: add benchmarks + + docs: + name: Check for documentation errors + runs-on: ubuntu-20.04 + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Install rust toolchain + uses: dtolnay/rust-toolchain@nightly + + - name: cargo doc (all packages; all features) + run: cargo doc --locked --all-features --no-deps --document-private-items + env: + RUSTDOCFLAGS: -Dwarnings + + coverage: + name: Measure coverage + runs-on: ubuntu-20.04 + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + + - name: Install rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + components: llvm-tools + + - name: Install cargo-llvm-cov + run: cargo install cargo-llvm-cov + + - name: Measure coverage + run: ./admin/coverage --lcov --output-path final.info + + - name: Report to codecov.io + uses: codecov/codecov-action@v3 + with: + file: final.info + fail_ci_if_error: false + + # TODO: enable this after crate is published + # semver: + # name: Check semver compatibility + # runs-on: ubuntu-latest + # steps: + # - name: Checkout sources + # uses: actions/checkout@v4 + # with: + # persist-credentials: false + + # - name: Check semver + # uses: obi1kenobi/cargo-semver-checks-action@v2 + + format: + name: Format + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Install rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + - name: Check formatting + run: cargo fmt --all -- --check + + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + + - name: Install rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + components: clippy + - run: cargo clippy --locked --package rustls-mbedcrypto-provider --all-features --all-targets -- --deny warnings + - run: cargo clippy --locked --package rustls-mbedcrypto-provider --no-default-features --all-targets -- --deny warnings + + clippy-nightly: + name: Clippy (Nightly) + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + + - name: Install rust toolchain + uses: dtolnay/rust-toolchain@nightly + with: + components: clippy + - run: cargo clippy --locked --package rustls-mbedcrypto-provider --all-features --all-targets + - run: cargo clippy --locked --package rustls-mbedcrypto-provider --no-default-features --all-targets \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 9933fdf..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Rust - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: check mbedpki-provider - working-directory: rustls-mbedpki-provider - env: - RUSTFLAGS: -D warnings - run: cargo check - - - name: Run mbedpki-provider tests - working-directory: rustls-mbedpki-provider - run: cargo test diff --git a/.gitignore b/.gitignore index 50baf8f..d26870e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,13 @@ .vscode/ target/ - +*.gcda +*.gcno +*.info +sslkeylogfile.txt +admin/rustfmt +.DS_Store +._.DS_Store +**/.DS_Store +**/._.DS_Store +/.idea +/default.profraw diff --git a/.rustfmt.toml b/.rustfmt.toml index 25f60b4..08f25ef 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1,3 +1,3 @@ chain_width=40 max_width = 128 -struct_lit_width = 80 \ No newline at end of file +struct_lit_width = 80 diff --git a/admin/coverage b/admin/coverage new file mode 100755 index 0000000..c4c0d85 --- /dev/null +++ b/admin/coverage @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -e + +source <(cargo llvm-cov show-env --export-prefix) +cargo llvm-cov clean --workspace + +cargo build --locked --all-targets --all-features +cargo test --locked --all-features +cargo llvm-cov report "$@"