From 6e883de03e076a62acd67f36e14d57f58d0ee279 Mon Sep 17 00:00:00 2001 From: "alon.dotan" Date: Mon, 11 Mar 2024 09:40:23 +0200 Subject: [PATCH] Initial commit --- .github/.codecov.yml | 16 +++++ .github/workflows/ci.yml | 114 ++++++++++++++++++++++++++++++ .github/workflows/coverage.yml | 25 +++++++ .github/workflows/post-merge.yml | 19 +++++ .github/workflows/verify-deps.yml | 20 ++++++ commitlint.config.js | 53 ++++++++++++++ 6 files changed, 247 insertions(+) create mode 100644 .github/.codecov.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/coverage.yml create mode 100644 .github/workflows/post-merge.yml create mode 100644 .github/workflows/verify-deps.yml create mode 100644 commitlint.config.js diff --git a/.github/.codecov.yml b/.github/.codecov.yml new file mode 100644 index 00000000..c88b947e --- /dev/null +++ b/.github/.codecov.yml @@ -0,0 +1,16 @@ +ignore: + - "crates/**/*test*.rs" +coverage: + status: + project: + default: + target: auto # set the target coverage to the value of the parent commit + threshold: 0% # pct of drop in coverage that is still considered as success + informational: true # if true does not fail the CI is coverage is bellow the target value + only_pulls: true # run only on PRs + patch: + default: + target: 100% + threshold: 0% + informational: true + only_pulls: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..2c21d571 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,114 @@ +name: CI + +on: + push: + branches: + - main + - main-v[0-9]+.** + tags: + - v[0-9]+.** + + pull_request: + types: + - opened + - reopened + - synchronize + - auto_merge_enabled + - edited + + merge_group: + types: [checks_requested] + +jobs: + commitlint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install commitlint + run: npm install --global @commitlint/cli @commitlint/config-conventional + + - name: Validate PR commits with commitlint + if: github.event_name == 'pull_request' && !(contains(github.event.pull_request.title, '/merge-main') || contains(github.event.pull_request.title, '/merge main')) + run: commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose + + - name: Validate PR title with commitlint + if: github.event_name != 'merge_group' && github.event_name != 'push' && !(contains(github.event.pull_request.title, '/merge-main') || contains(github.event.pull_request.title, '/merge main')) + run: echo "${{ github.event.pull_request.title }}" | commitlint --verbose + + format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master + with: + components: rustfmt + toolchain: nightly-2024-01-12 + - uses: Swatinem/rust-cache@v2 + - run: scripts/rust_fmt.sh --check + + clippy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy + - uses: Swatinem/rust-cache@v2 + - run: scripts/clippy.sh + + run-python-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v2 + with: + python-version: '3.9' + - run: | + python -m pip install --upgrade pip + pip install pytest + - run: pytest scripts/merge_paths_test.py + + run-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + - run: cargo test + + udeps: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master + name: "Rust Toolchain Setup" + with: + toolchain: nightly-2024-01-12 + - uses: Swatinem/rust-cache@v2 + id: "cache-cargo" + - if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }} + name: "Download and run cargo-udeps" + run: | + wget -O - -c https://github.com/est31/cargo-udeps/releases/download/v0.1.45/cargo-udeps-v0.1.45-x86_64-unknown-linux-gnu.tar.gz | tar -xz + cargo-udeps-*/cargo-udeps udeps + env: + RUSTUP_TOOLCHAIN: nightly-2024-01-12 + + + all-tests: + runs-on: ubuntu-latest + needs: + - clippy + - commitlint + - format + - run-python-tests + - run-tests + - udeps + steps: + - name: Decide whether all the needed jobs succeeded or failed + uses: re-actors/alls-green@v1.2.2 + with: + jobs: ${{ toJSON(needs) }} diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 00000000..1e2bbc89 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,25 @@ +name: Coverage + +on: [pull_request, push] + +jobs: + coverage: + runs-on: ubuntu-latest + env: + CARGO_TERM_COLOR: always + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + - name: Install cargo-llvm-cov + uses: taiki-e/install-action@cargo-llvm-cov + - name: Generate code coverage + run: cargo llvm-cov --codecov --output-path codecov.json + env: + SEED: 0 + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true + fail_ci_if_error: true diff --git a/.github/workflows/post-merge.yml b/.github/workflows/post-merge.yml new file mode 100644 index 00000000..bf484c6f --- /dev/null +++ b/.github/workflows/post-merge.yml @@ -0,0 +1,19 @@ +name: post-merge + +on: + pull_request: + types: + - closed +jobs: + if_merged: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master + with: + components: rustfmt + toolchain: nightly-2024-01-12 + - uses: Swatinem/rust-cache@v2 + - run: + cargo test -- --include-ignored diff --git a/.github/workflows/verify-deps.yml b/.github/workflows/verify-deps.yml new file mode 100644 index 00000000..3d773321 --- /dev/null +++ b/.github/workflows/verify-deps.yml @@ -0,0 +1,20 @@ +name: Nightly Latest Dependencies Check + +on: + schedule: + - cron: '0 0 * * *' # Runs at 00:00 UTC every day + +jobs: + latest_deps: + name: Latest Dependencies + runs-on: ubuntu-latest + continue-on-error: true + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - name: Update Dependencies + run: cargo update --verbose + - name: Build + run: cargo build --verbose + - name: Test + run: cargo test --verbose diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 00000000..9b454b82 --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1,53 @@ +const Configuration = { + /* + * Resolve and load @commitlint/config-conventional from node_modules. + * Referenced packages must be installed. + * See [the README](https://github.com/conventional-changelog/commitlint/blob/master/%40commitlint/config-conventional/README.md) + * for applied rules. + */ + extends: ['@commitlint/config-conventional'], + /* + * Resolve and load conventional-changelog-atom from node_modules. + * Referenced packages must be installed + */ + // parserPreset: 'conventional-changelog-atom', + /* + * Resolve and load @commitlint/format from node_modules. + * Referenced package must be installed + */ + formatter: '@commitlint/format', + /* + * Any rules defined here will override rules from @commitlint/config-conventional + */ + rules: { + 'scope-enum': [2, 'always', [ + 'ci', + ]], + }, + /* + * Functions that return true if commitlint should ignore the given message. + */ + ignores: [(commit) => commit === ''], + /* + * Whether commitlint uses the default ignore rules. + */ + defaultIgnores: true, + /* + * Custom URL to show upon failure + */ + helpUrl: + 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint', + /* + * Custom prompt configs, not used currently. + */ + prompt: { + messages: {}, + questions: { + type: { + description: 'please input type:', + }, + }, + }, +}; + +module.exports = Configuration;