diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..a8efc68f --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,16 @@ +version: 2 +updates: + - package-ecosystem: "cargo" + directory: "/" + schedule: + interval: "daily" + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + + - package-ecosystem: "pip" + directory: "/py" + schedule: + interval: "daily" diff --git a/.github/workflows/c.yml b/.github/workflows/c.yml index 6aa7f629..56e5a519 100644 --- a/.github/workflows/c.yml +++ b/.github/workflows/c.yml @@ -3,21 +3,17 @@ name: C on: pull_request: push: - branches: [ main ] + branches: [main] jobs: test: name: Test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true + - uses: dtolnay/rust-toolchain@stable - name: Configure run: mkdir -p build && cd build && cmake ../c -DSUBSTRAIT_VALIDATOR_BUILD_TESTS=ON - name: Build @@ -29,8 +25,8 @@ jobs: name: Style runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: jidicula/clang-format-action@v4.5.0 with: - clang-format-version: '13' + clang-format-version: "13" check-path: c diff --git a/.github/workflows/misc.yml b/.github/workflows/misc.yml index 910ba296..a4af7ca1 100644 --- a/.github/workflows/misc.yml +++ b/.github/workflows/misc.yml @@ -8,31 +8,31 @@ jobs: name: Check license headers runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Check License Header - uses: enarx/spdx@master - with: - licenses: Apache-2.0 MIT + - uses: actions/checkout@v3 + - name: Check License Header + uses: enarx/spdx@master + with: + licenses: Apache-2.0 MIT editorconfig: name: Check editorconfig runs-on: ubuntu-latest steps: - - uses: editorconfig-checker/action-editorconfig-checker@v1 + - uses: editorconfig-checker/action-editorconfig-checker@v1 check-version-patch: name: Check version update patch file runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Check version update patch file - run: python3 ci/version.py check + - uses: actions/checkout@v3 + - name: Check version update patch file + run: python3 ci/version.py check verify-antlr: name: Verify ANTLR-generated code runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Check working-directory: rs/antlr run: python3 generate.py --ci @@ -41,10 +41,10 @@ jobs: name: Lint commits for semantic-release runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - uses: actions/setup-node@v2 - with: - node-version: "14" - - run: npx commitlint --from=${{ github.event.pull_request.base.sha }} --to=${{ github.sha }} --verbose + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-node@v3 + with: + node-version: "14" + - run: npx commitlint --from=${{ github.event.pull_request.base.sha }} --to=${{ github.sha }} --verbose diff --git a/.github/workflows/proto.yml b/.github/workflows/proto.yml index a9537e72..1820b00d 100644 --- a/.github/workflows/proto.yml +++ b/.github/workflows/proto.yml @@ -3,28 +3,30 @@ name: Protobuf on: pull_request: push: - branches: [ main ] + branches: [main] jobs: style: name: Style runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive - - uses: bufbuild/buf-setup-action@v1.4.0 + - uses: bufbuild/buf-setup-action@v1.9.0 - run: buf format --diff --exit-code check: name: Check runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive - uses: arduino/setup-protoc@v1 - - uses: bufbuild/buf-setup-action@v0.7.0 - - uses: bufbuild/buf-lint-action@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - uses: bufbuild/buf-setup-action@v1.9.0 + - uses: bufbuild/buf-lint-action@v1.0.3 - name: Compile protobuf run: buf generate diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 9ad47302..7824cfdd 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -3,8 +3,8 @@ name: Python on: pull_request: push: - branches: [ main ] - tags: [ 'v*.*.*' ] + branches: [main] + tags: ["v*.*.*"] jobs: build: @@ -16,93 +16,89 @@ jobs: python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] type: [wheel] include: - - os: ubuntu-latest - python-version: "3.7" - type: sdist + - os: ubuntu-latest + python-version: "3.7" + type: sdist runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - with: - submodules: recursive - - name: Fetch Substrait submodule tags - working-directory: substrait - run: | - git fetch --recurse-submodules=no origin +refs/tags/*:refs/tags/* - git describe --dirty --tags - - name: Install latest protoc - uses: arduino/setup-protoc@v1 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Install sdist-only dependencies - if: ${{ matrix.type == 'sdist' }} - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - name: sdist-only build prep - if: ${{ matrix.type == 'sdist' }} - working-directory: rs - run: cargo check - # ^ this ensures that its build.rs is run, which is all we need. Sadly - # there doesn't seem to be a way to do this that doesn't pull in all - # normal dependencies: https://github.com/rust-lang/cargo/issues/7178 - - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install Python build dependencies - run: python3 -m pip install --upgrade pip "maturin>=0.14,<0.15" - - name: Prepare build environment - working-directory: py - run: python3 prepare_build.py populate - - name: Create sdist - if: ${{ matrix.type == 'sdist' }} - uses: PyO3/maturin-action@v1.31.0 - with: - command: sdist - args: -o dist -m py/Cargo.toml - - name: Build manylinux wheels - if: ${{ matrix.type == 'wheel' && matrix.os == 'ubuntu-latest' }} - uses: PyO3/maturin-action@v1.31.0 - with: - manylinux: auto - command: build - args: -i ${{ matrix.python-version }} --release -o dist -m py/Cargo.toml - - name: Build Windows wheels - if: ${{ matrix.type == 'wheel' && matrix.os == 'windows-latest' }} - uses: PyO3/maturin-action@v1.31.0 - with: - command: build - args: --release -o dist -m py/Cargo.toml - - name: Build MacOS wheels - if: ${{ matrix.type == 'wheel' && matrix.os == 'macos-latest' }} - uses: PyO3/maturin-action@v1.31.0 - with: - command: build - args: --release -o dist --universal2 -m py/Cargo.toml - - name: Install runtime dependencies - run: python3 -m pip install --upgrade protobuf pytest click pyyaml jdot toml - - name: Install generated sdist - if: ${{ matrix.type == 'sdist' }} - run: python3 -m pip install dist/substrait_validator-*.tar.gz - - name: Install generated wheel - if: ${{ matrix.type == 'wheel' }} - run: python3 -m pip install --no-index --find-links=dist substrait-validator - - name: Test - working-directory: py/tests - run: python3 -m pytest - - name: Upload wheels - if: "startsWith(github.ref, 'refs/tags/')" - uses: actions/upload-artifact@v2 - with: - name: wheels - path: dist + - uses: actions/checkout@v3 + with: + submodules: recursive + - name: Fetch Substrait submodule tags + working-directory: substrait + run: | + git fetch --recurse-submodules=no origin +refs/tags/*:refs/tags/* + git describe --dirty --tags + - name: Install latest protoc + uses: arduino/setup-protoc@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Install sdist-only dependencies + if: ${{ matrix.type == 'sdist' }} + uses: dtolnay/rust-toolchain@stable + - name: sdist-only build prep + if: ${{ matrix.type == 'sdist' }} + working-directory: rs + run: cargo check + # ^ this ensures that its build.rs is run, which is all we need. Sadly + # there doesn't seem to be a way to do this that doesn't pull in all + # normal dependencies: https://github.com/rust-lang/cargo/issues/7178 + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install Python build dependencies + run: python3 -m pip install --upgrade pip "maturin>=0.14,<0.15" + - name: Prepare build environment + working-directory: py + run: python3 prepare_build.py populate + - name: Create sdist + if: ${{ matrix.type == 'sdist' }} + uses: PyO3/maturin-action@v1.31.0 + with: + command: sdist + args: -o dist -m py/Cargo.toml + - name: Build manylinux wheels + if: ${{ matrix.type == 'wheel' && matrix.os == 'ubuntu-latest' }} + uses: PyO3/maturin-action@v1.31.0 + with: + manylinux: auto + command: build + args: -i ${{ matrix.python-version }} --release -o dist -m py/Cargo.toml + - name: Build Windows wheels + if: ${{ matrix.type == 'wheel' && matrix.os == 'windows-latest' }} + uses: PyO3/maturin-action@v1.31.0 + with: + command: build + args: --release -o dist -m py/Cargo.toml + - name: Build MacOS wheels + if: ${{ matrix.type == 'wheel' && matrix.os == 'macos-latest' }} + uses: PyO3/maturin-action@v1.31.0 + with: + command: build + args: --release -o dist --universal2 -m py/Cargo.toml + - name: Install runtime dependencies + run: python3 -m pip install --upgrade protobuf pytest click pyyaml jdot toml + - name: Install generated sdist + if: ${{ matrix.type == 'sdist' }} + run: python3 -m pip install dist/substrait_validator-*.tar.gz + - name: Install generated wheel + if: ${{ matrix.type == 'wheel' }} + run: python3 -m pip install --no-index --find-links=dist substrait-validator + - name: Test + working-directory: py/tests + run: python3 -m pytest + - name: Upload wheels + if: "startsWith(github.ref, 'refs/tags/')" + uses: actions/upload-artifact@v2 + with: + name: wheels + path: dist release: name: Release runs-on: ubuntu-latest if: "startsWith(github.ref, 'refs/tags/')" - needs: [ build ] + needs: [build] environment: VALIDATOR_RELEASE steps: - uses: actions/download-artifact@v2 @@ -126,10 +122,10 @@ jobs: name: Style & lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Install dependencies - run: python3 -m pip install --upgrade pip black==22.3.0 flake8==4.0.1 - - name: Black - run: python3 -m black --diff --check . - - name: Flake8 - run: python3 -m flake8 . + - uses: actions/checkout@v3 + - name: Install dependencies + run: python3 -m pip install --upgrade pip black==22.3.0 flake8==4.0.1 + - name: Black + run: python3 -m black --diff --check . + - name: Flake8 + run: python3 -m flake8 . diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index bf8fe12b..5bce74fe 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -3,23 +3,19 @@ name: Rust on: pull_request: push: - branches: [ main ] - tags: [ 'v*.*.*' ] + branches: [main] + tags: ["v*.*.*"] jobs: check: name: Check runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - uses: Swatinem/rust-cache@v1 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 - name: Check run: cargo check --all-features @@ -31,15 +27,11 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - uses: Swatinem/rust-cache@v1 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 - name: Run unit tests run: cargo test --all-features - name: Install test runner dependencies @@ -55,16 +47,11 @@ jobs: name: Style runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - components: rustfmt - - uses: Swatinem/rust-cache@v1 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 - name: Rustfmt run: cargo fmt --all -- --check @@ -72,16 +59,11 @@ jobs: name: Lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - components: clippy - - uses: Swatinem/rust-cache@v1 + - uses: dtolnay/rust-toolchain@clippy + - uses: Swatinem/rust-cache@v2 - name: Clippy run: cargo clippy --all-features -- -D warnings @@ -89,15 +71,11 @@ jobs: name: Doc runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - uses: Swatinem/rust-cache@v1 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 - name: Doc run: RUSTDOCFLAGS="-Dwarnings" cargo doc --workspace --all-features @@ -105,17 +83,13 @@ jobs: name: Release runs-on: ubuntu-latest if: "startsWith(github.ref, 'refs/tags/')" - needs: [ check, test ] + needs: [check, test] environment: VALIDATOR_RELEASE steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true + - uses: dtolnay/rust-toolchain@stable - name: Fetch Substrait submodule tags working-directory: substrait run: | diff --git a/.github/workflows/yaml.yml b/.github/workflows/yaml.yml index bc7132b4..c33b7b14 100644 --- a/.github/workflows/yaml.yml +++ b/.github/workflows/yaml.yml @@ -3,13 +3,13 @@ name: YAML on: pull_request: push: - branches: [ main ] + branches: [main] jobs: lint: name: Lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Run yamllint run: yamllint . diff --git a/rs/src/parse/context.rs b/rs/src/parse/context.rs index 15338a3e..ea8501e1 100644 --- a/rs/src/parse/context.rs +++ b/rs/src/parse/context.rs @@ -152,13 +152,7 @@ impl<'a> Context<'a> { .unwrap_or(&(diagnostic::Level::Info, diagnostic::Level::Error)); // Adjust the level. - let adjusted_level = if diag.level < *min { - *min - } else if diag.level > *max { - *max - } else { - diag.level - }; + let adjusted_level = diag.level.clamp(*min, *max); let adjusted = diag.adjust_level(adjusted_level); // Actually push the data item. diff --git a/rs/src/parse/expressions/literals.rs b/rs/src/parse/expressions/literals.rs index f9e4581e..d3bc281b 100644 --- a/rs/src/parse/expressions/literals.rs +++ b/rs/src/parse/expressions/literals.rs @@ -174,7 +174,7 @@ impl Describe for Literal { _ => write!(f, "{i}"), }, LiteralValue::Float(v) => { - let max = std::cmp::min(std::cmp::max(3, limit.chars()), 10); + let max = limit.chars().clamp(3, 10); write!(f, "{:3.1$}", float_pretty_print::PrettyPrintFloat(*v), max) } LiteralValue::Data16(d) => match self.data_type.class() {