Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
filters: |
src:
- 'core/**'
- 'macros/**'
- 'bindings/java/**'
- 'Cargo.*'
- '.github/workflows/java.yml'
Expand Down
24 changes: 1 addition & 23 deletions .github/workflows/js-wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
filters: |
src:
- 'core/**'
- 'macros/**'
- 'bindings/js/**'
- 'Cargo.*'
- '.github/workflows/js-wasm.yml'
Expand All @@ -51,29 +52,6 @@ jobs:
echo "test=$test" >> "$GITHUB_OUTPUT"
echo "gate=$gate" >> "$GITHUB_OUTPUT"

lint:
name: JS/WASM Lints
needs: [plan]
if: needs.plan.outputs.test == 'true'
runs-on: ubuntu-24.04
defaults:
run:
working-directory: bindings/js

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: 24
cache: npm
cache-dependency-path: bindings/js/package-lock.json

- name: Install dependencies
run: npm ci

- name: Run linter
run: npm run lint

test:
name: JS/WASM Tests
needs: [plan]
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/prek.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Prek (linting and formatting)

on:
push:
branches: [main]
tags: ["*"]
pull_request:
branches: [main]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: j178/prek-action@b0ae0c600be6176aa296014b4eab1974096ebd69 # v2

ci-gate:
name: Prek CI Gate
needs: [test]
if: github.event_name == 'pull_request' && !cancelled()
runs-on: ubuntu-slim
steps:
- run: |
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then
exit 1
fi
34 changes: 3 additions & 31 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
src:
- 'bindings/py/**'
- 'core/**'
- 'macros/**'
- 'sysand/**'
- 'Cargo.*'
- '.github/workflows/python.yml'
Expand All @@ -59,35 +60,6 @@ jobs:
echo "test=$test" >> "$GITHUB_OUTPUT"
echo "gate=$gate" >> "$GITHUB_OUTPUT"

lint:
needs: [plan]
if: needs.plan.outputs.test == 'true'
runs-on: ubuntu-24.04
defaults:
run:
working-directory: bindings/py

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: "3.14"
- uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7

- name: Setup environment
run: |
uv sync --group linters --active --no-install-project --locked
echo "$(pwd)/.venv/bin" >> "$GITHUB_PATH"

- name: ruff format ...
run: ruff format --check python tests

- name: ruff check ...
run: ruff check python

- name: mypy ...
run: mypy --strict python

windows:
needs: [plan]
if: needs.plan.outputs.test == 'true'
Expand Down Expand Up @@ -319,7 +291,7 @@ jobs:

ci-gate:
name: Python CI Gate
needs: [plan, lint, windows, linux, macos, sdist]
needs: [plan, windows, linux, macos, sdist]
if: needs.plan.outputs.gate == 'true' && !cancelled()
runs-on: ubuntu-slim
steps:
Expand All @@ -331,7 +303,7 @@ jobs:
release:
name: Release to PyPI
environment: pypi-publish
needs: [lint, linux, macos, windows, sdist]
needs: [linux, macos, windows, sdist]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-24.04
permissions:
Expand Down
30 changes: 23 additions & 7 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
outputs:
test: ${{ steps.decisions.outputs.test }}
gate: ${{ steps.decisions.outputs.gate }}
lint_and_format: ${{ steps.decisions.outputs.lint_and_format }}
steps:
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4
if: github.event_name == 'pull_request'
Expand All @@ -41,19 +42,26 @@ jobs:
filters: |
src:
- 'core/**'
- 'macros/**'
- 'sysand/**'
- 'Cargo.*'
- '.github/workflows/rust.yml'
rs_src:
- '**/Cargo.*'
- '**/*.rs'
- id: decisions
run: |
test=${{ steps.filter.outputs.src == 'true' || github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
gate=${{ github.event_name == 'pull_request' }}
echo "test=$test" >> "$GITHUB_OUTPUT"
echo "gate=$gate" >> "$GITHUB_OUTPUT"

lint_and_format=${{ steps.filter.outputs.rs_src == 'true' || github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
echo "lint_and_format=$lint_and_format" >> "$GITHUB_OUTPUT"

lint-and-format:
needs: [plan]
if: needs.plan.outputs.test == 'true'
if: needs.plan.outputs.lint_and_format == 'true'
runs-on: ubuntu-24.04

steps:
Expand All @@ -62,14 +70,22 @@ jobs:

- uses: taiki-e/install-action@6eec77b572d917fad00b2d3429df5ca9b6a0512c # cargo-hack

- name: cargo hack clippy ...
run: cargo hack clippy --each-feature --no-dev-deps --features std --ignore-unknown-features -- --deny warnings
# cargo clippy is run with variants of features enabled, where
# --all-features is done by prek so we don't do it here

- name: cargo clippy ...
run: cargo clippy --locked --all-targets --all-features -- --deny warnings
- name: cargo clippy ... (no features)
run: cargo clippy --workspace --locked --all-targets -- --deny warnings

- name: cargo fmt ...
run: cargo fmt --check
- name: cargo clippy --features std,filesystem,alltests ... (specific feature set 1)
run: cargo clippy --workspace --locked --all-targets --no-default-features --features std,filesystem,alltests -- --deny warnings

- name: cargo clippy --features std,networking,alltests ... (specific feature set 2)
run: cargo clippy --workspace --locked --all-targets --no-default-features --features std,networking,alltests -- --deny warnings

# since we use --no-dev-deps below (as recommended), we don't do
# --all-targets to include tests with required development dependencies
- name: cargo hack clippy --each-feature ... (individual features)
run: cargo hack clippy --each-feature --no-dev-deps --features std --ignore-unknown-features -- --deny warnings

test:
needs: [plan]
Expand Down
113 changes: 61 additions & 52 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,44 +1,31 @@
# pre-commit is a tool to perform a predefined set of tasks manually and/or
# automatically before git commits are made.
# prek (Rust version of the Python based pre-commit) is a tool to perform a
# predefined set of tasks manually and/or automatically before git commits are
# made.
#
# Config reference: https://pre-commit.com/#pre-commit-configyaml---top-level
# We require prek specifically, since we want support for rust based hooks.
#
# pre-commit reference: https://pre-commit.com/#pre-commit-configyaml---top-level
# prek reference: https://prek.j178.dev/configuration/
#
# Common tasks
#
# - Run once on all files: pre-commit run --all-files
# - Register git hooks: pre-commit install --install-hooks
# - Run once on all files: prek run -a
# - Register git hooks: prek install
#
# FIXME: transition to a prek official config as we now require prek
# FIXME: ensure hooks gets updated over time automatically
#
repos:
# Autoformat: python
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.4
hooks:
- id: ruff-check
args: [--fix]
- id: ruff-format

# Autoformat: markdown, yaml, json, js
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.8.1
hooks:
- id: prettier
exclude: |
(?x)^(
.*stdlib_assets/.*|
.*\.lock
)$

# Lint: javascript
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v10.1.0
hooks:
- id: eslint
files: ^bindings/js/
types: [javascript]
additional_dependencies:
- eslint@^10.1.0
- "@eslint/js@^10.0.1"
- globals@^17.4.0
exclude: |-
(?x)(
stdlib_assets/|
\.lock
)

# Autoformat: rust
- repo: local
Expand All @@ -47,35 +34,57 @@ repos:
name: cargo fmt
entry: cargo fmt
description: Formats all bin and lib files of the current workspace using rustfmt.
language: system
language: rust
types: [rust]
args: ["--"]

- id: cargo-clippy
name: cargo clippy
entry: cargo clippy
description: Checks all packages in the workspace to catch common mistakes and improve your Rust code.
language: system
language: rust
types: [rust]
args:
[
"--workspace",
"--all-targets",
"--all-features",
"--",
"--deny",
"warnings",
]
- --workspace
- --all-targets
- --all-features
- --allow-dirty
- --fix
- --
- --deny
- warnings
pass_filenames: false

# pre-commit.ci is a free automation service that can both run a validation job
# and push commits with fixes to PRs, and keep the versions of configured
# pre-commit hooks up to date by creating version bumping PRs.
#
# pre-commit.ci config reference: https://pre-commit.ci/#configuration
ci:
autoupdate_schedule: monthly
skip:
# The hooks rely on cargo being available, which it won't be in
# pre-commit.ci's runners, so we skip them from running there.
- cargo-fmt
- cargo-clippy
# Autoformat: python
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.4
hooks:
- id: ruff-check
args: [--fix]
- id: ruff-format

# Lint: python type checking
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.20.0
hooks:
- id: mypy
args:
- --strict
# lint only what is known to use typings
files: |-
(?x)^(
bindings/py/python/|
bindings/java/scripts/
)

# Lint: javascript
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v10.1.0
hooks:
- id: eslint
files: ^bindings/js/
types: [javascript]
additional_dependencies:
- eslint@^10.1.0
- "@eslint/js@^10.0.1"
- globals@^17.4.0
19 changes: 4 additions & 15 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,21 +127,8 @@ Run tests for all crates and language bindings (requires bindings dependencies):

## Formatting and linting

Format Rust code in core crates:

```sh
cargo fmt -p sysand-core -p sysand
```

Format and lint all Rust and bindings code (requires bindings dependencies):

```sh
./scripts/run_chores.sh
```

Format and lint all other code based on configuration in
`.pre-commit-config.yaml`, either with prek or pre-commit, available to install
via uv or pip.
Format and lint all code based on configuration in `.pre-commit-config.yaml`
with `prek` ([installation options]).

```sh
prek run -a
Expand All @@ -150,6 +137,8 @@ prek run -a
prek install
```

[installation options]: https://github.com/j178/prek?tab=readme-ov-file#installation

## Commits and pull requests

Committing your changes:
Expand Down
4 changes: 4 additions & 0 deletions bindings/java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,7 @@ Only run tests:
```sh
./scripts/java-builder.py test
```

## Formatting and linting

Refer to the main [DEVELOPMENT.md](../../DEVELOPMENT.md).
2 changes: 1 addition & 1 deletion bindings/java/scripts/java-builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def parse_version() -> str:
metadata = json.loads(output)
for package in metadata["packages"]:
if package["name"] == "sysand-java":
version = package["version"]
version: str = package["version"]
return version
raise ValueError("sysand-java not found in Cargo.toml")

Expand Down
Loading
Loading