forked from sqlfluff/sqlfluff
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tweak Coveralls settings (sqlfluff#4199)
* Add .gitpod.yml * Remove .gitpod.yml * Tweak Coveralls * Tweak base-path * Trigger build * Specify "--cov=" appropriate to each build * Tweaks * Tweaks * Change .tox paths to src/sqlfluff paths * Run patch_lcov.py from tox, not from ci-tests.yml * Fail-safe the script * Add debug message * Do nothing if coverage file not found * Only try and patch lines where path begins with ".tox" * Move Coveralls coverage builds first so we get results sooner * Revert "Move Coveralls coverage builds first so we get results sooner" This reverts commit b5df02b. * PR review: more detailed docstring
- Loading branch information
1 parent
df09b33
commit e62e278
Showing
7 changed files
with
64 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"""pytest fixtures.""" | ||
import dbt.flags | ||
import pytest | ||
|
||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def dbt_flags(): | ||
"""Set dbt flags for dbt templater tests.""" | ||
# Setting this to True disables some code in dbt-core that randomly runs | ||
# some test code in core/dbt/parser/models.py, ModelParser. render_update(). | ||
# We've seen occasional runtime errors from that code: | ||
# TypeError: cannot pickle '_thread.RLock' object | ||
dbt.flags.USE_EXPERIMENTAL_PARSER = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Replaces .tox/ paths in the lcov file with paths relative to repo root. | ||
Context: When the CI build runs tests, it uses tox, which installs SQLFluff | ||
in a virtual environment. Thus, the coverage.lcov file generated by the tests | ||
contains paths to the virtual environment. This script replaces those paths | ||
with paths relative to the repo root. This allows the lcov file to be used by | ||
Coveralls. Without this, Coveralls has valid coverage info, but it generates | ||
URLs that point to source files that don't exist in the SQLFluff GitHub repo. | ||
For example, we want to change this: | ||
SF:.tox/py/lib/python3.10/site-packages/sqlfluff/__init__.py | ||
to this: | ||
SF:src/sqlfluff/__init__.py | ||
""" | ||
import re | ||
from pathlib import Path | ||
|
||
path = Path("coverage.lcov") | ||
if path.exists(): | ||
lines = path.read_text().splitlines() | ||
modified_lines = [] | ||
for line in lines: | ||
if line.startswith("SF:.tox"): | ||
m = re.search(r"^(SF:).*(sqlfluff/.*)", line) | ||
if m: | ||
modified_lines.append(f"{m.group(1)}src/{m.group(2)}") | ||
else: | ||
print(f"Could not patch line: {line}") | ||
modified_lines.append(line) | ||
else: | ||
modified_lines.append(line) | ||
path.write_text("\n".join(modified_lines)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters