| # Licensed to the Apache Software Foundation (ASF) under one | |
| # or more contributor license agreements. See the NOTICE file | |
| # distributed with this work for additional information | |
| # regarding copyright ownership. The ASF licenses this file | |
| # to you under the Apache License, Version 2.0 (the | |
| # "License"); you may not use this file except in compliance | |
| # with the License. You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, | |
| # software distributed under the License is distributed on an | |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
| # KIND, either express or implied. See the License for the | |
| # specific language governing permissions and limitations | |
| # under the License. | |
| name: Rust | |
| on: | |
| push: | |
| # Feature branches get CI from pull_request, so push runs only the long-lived branches. | |
| branches: | |
| - main | |
| - 'branch-*' | |
| pull_request: | |
| merge_group: | |
| permissions: | |
| contents: read | |
| # Only PR runs are disposable. Main, schedule and merge-queue runs keep their verdicts. | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| jobs: | |
| codestyle: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust Toolchain | |
| uses: ./.github/actions/setup-builder | |
| - run: cargo fmt --all -- --check | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust Toolchain | |
| uses: ./.github/actions/setup-builder | |
| - run: cargo clippy --locked --all-targets --all-features -- -D warnings | |
| benchmark-lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust Toolchain | |
| uses: ./.github/actions/setup-builder | |
| - run: cd sqlparser_bench && cargo clippy --locked --all-targets --all-features -- -D warnings | |
| compile: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust Toolchain | |
| uses: ./.github/actions/setup-builder | |
| - run: cargo check --locked --all-targets --all-features | |
| docs: | |
| runs-on: ubuntu-latest | |
| env: | |
| RUSTDOCFLAGS: "-Dwarnings" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust Toolchain | |
| uses: ./.github/actions/setup-builder | |
| - run: cargo doc --locked --document-private-items --no-deps --workspace --all-features | |
| compile-no-std: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust Toolchain | |
| uses: ./.github/actions/setup-builder | |
| with: | |
| targets: 'thumbv6m-none-eabi' | |
| - run: cargo test --locked --release --no-default-features --test no_std_recursion | |
| - run: cargo check --locked --no-default-features --target thumbv6m-none-eabi | |
| - run: cargo check --locked --no-default-features --features visitor --target thumbv6m-none-eabi | |
| test: | |
| strategy: | |
| matrix: | |
| rust: [stable, beta, nightly] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust Toolchain | |
| uses: ./.github/actions/setup-builder | |
| with: | |
| rust-version: ${{ matrix.rust }} | |
| - uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 | |
| - name: Test | |
| run: cargo test --locked --all-features | |
| coverage: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Rust Toolchain | |
| uses: ./.github/actions/setup-builder | |
| - run: rustup component add llvm-tools-preview | |
| - uses: taiki-e/install-action@7623a79cdfecb99d681017af368ca353d9f49bb5 # v2.87.19 | |
| with: | |
| tool: cargo-llvm-cov | |
| - uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 | |
| - run: cargo llvm-cov --locked --all-features --no-report | |
| - run: cargo llvm-cov report --codecov --output-path target/codecov.json | |
| - uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1 | |
| with: | |
| files: target/codecov.json | |
| fail_ci_if_error: false | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| - run: cargo llvm-cov report --summary-only --fail-under-lines 90 | |
| - name: Changed lines must be covered | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| cargo llvm-cov report --lcov --output-path target/lcov.info | |
| pipx run --spec diff-cover==10.6.0 diff-cover target/lcov.info \ | |
| --compare-branch ${{ github.event.pull_request.base.sha }} --fail-under 80 |