Skip to content

Commit a4af80b

Browse files
authored
Merge branch 'main' into fix/6017-resolve-table-mapping
2 parents 07e2ddf + 76225c6 commit a4af80b

15 files changed

Lines changed: 1377 additions & 466 deletions

File tree

.github/workflows/pr.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,10 @@ jobs:
470470
path: vscode/extension/playwright-report/
471471
retention-days: 30
472472
test-dbt-versions:
473+
needs: changes
474+
if:
475+
needs.changes.outputs.python == 'true' || needs.changes.outputs.ci ==
476+
'true' || github.ref == 'refs/heads/main'
473477
runs-on: ubuntu-latest
474478
strategy:
475479
fail-fast: false

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ docs
3030
examples
3131
posts
3232
.circleci
33+
.github/
3334
README.md
3435
mkdocs.yml
3536
.readthedocs.yaml

CONTRIBUTING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,12 @@ See [docs/development.md](docs/development.md) for full setup instructions. Key
6565
python -m venv .venv
6666
source .venv/bin/activate
6767
make install-dev
68-
make style # Run before submitting
68+
make style # Run before submitting
6969
make fast-test # Quick test suite
7070
```
7171

72+
Optionally, `make install-pre-commit` installs git hooks so ruff and mypy run on `git commit`. Hooks do not replace `make style`: they run on staged files, while CI runs `make style` across the tree.
73+
7274
## Coding Standards
7375

7476
- Run `make style` before submitting a pull request

docs/concepts/tests.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,37 @@ You can also run tests that match a pattern or substring using a glob pathname e
463463
$ sqlmesh test tests/test_*
464464
```
465465

466+
Passing the path of a model file runs the tests for that model, which is useful for commit hooks and other tools that work with changed files rather than test names:
467+
468+
```
469+
$ sqlmesh test models/full_model.sql
470+
```
471+
472+
Model files and test files can be mixed, and the results are unioned. A test selected by more than one argument still runs only once, so the following runs each of `full_model`'s tests a single time even though both arguments cover them:
473+
474+
```
475+
$ sqlmesh test models/full_model.sql tests/test_full_model.yaml
476+
```
477+
478+
An argument that is neither a known model file nor a known test file is an error, so a mistyped or stale path fails instead of quietly running no tests. A model that simply has no tests is not an error.
479+
480+
You can pass `--local` to run tests without loading state from the configured state connection:
481+
482+
``` bash
483+
$ sqlmesh test --local
484+
```
485+
486+
This keeps offline runs and commit hooks from opening a connection to the state backend.
487+
488+
In multi-repository setups, or when running tests for only a subset of projects, models that exist only in remote state are not loaded under `--local`. Unlike [`sqlmesh lint --local`](../guides/linter.md), which reports additional errors in that situation, a test whose model is missing is **skipped with a warning and the run still succeeds**:
489+
490+
```
491+
[WARNING] Model '"memory"."bronze"."a"' was not found at tests/test_a.yaml
492+
.**Successfully Ran `1` Tests Against `duckdb`**
493+
```
494+
495+
So a passing exit code alone does not mean every test you expected actually ran. Watch the output for these warnings, and keep in mind that a hook using `--local` will not fail on them.
496+
466497
### Testing using notebooks
467498

468499
You can execute tests on demand using the `%run_test` notebook magic as follows:

docs/development.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Once you have activated your virtual environment, you can install the dependenci
4242
make install-dev
4343
```
4444

45-
Optionally, you can use pre-commit to automatically run linters/formatters:
45+
Optionally, `make install-pre-commit` installs git hooks so ruff and mypy run on `git commit`. Hooks do not replace `make style`: they run on staged files, while CI runs `make style` across the tree.
4646

4747
```bash
4848
make install-pre-commit

docs/reference/cli.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,13 +623,20 @@ Usage: sqlmesh test [OPTIONS] [TESTS]...
623623
624624
Run model unit tests.
625625
626+
TESTS are test files, `file.yaml::test_name` selectors, or model files, in
627+
which case the tests for those models are run. They are unioned, and a test
628+
selected more than once still only runs once.
629+
626630
Options:
627631
-k TEXT Only run tests that match the pattern of substring.
628632
-v, --verbose Verbose output.
629633
--preserve-fixtures Preserve the fixture tables in the testing database,
630634
useful for debugging.
631635
--select-model TEXT Select specific models to run unit tests for. Can be
632636
specified multiple times.
637+
--local Run tests using only locally loaded project files
638+
without loading state. Tests whose model is not loaded
639+
are skipped with a warning rather than failing.
633640
--help Show this message and exit.
634641
```
635642

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
},
66
"scripts": {
77
"ci": "pnpm run lint && pnpm run -r ci",
8-
"fmt": "prettier --write .",
9-
"fmt:check": "prettier --check .",
8+
"fmt": "prettier --write vscode web/client web/common",
9+
"fmt:check": "prettier --check vscode web/client web/common",
1010
"lint": "pnpm run fmt:check && pnpm run -r lint",
1111
"lint:fix": "pnpm run fmt && pnpm run -r lint:fix"
1212
},

0 commit comments

Comments
 (0)