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
154 changes: 73 additions & 81 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ name: CI checks

on:
push:
branches: [ "master" ]
branches: ["master"]
pull_request:
branches: [ "master" ]
branches: ["master"]
merge_group:

permissions:
Expand All @@ -18,70 +18,66 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v4
with:
fetch-depth: 0 # Required so we can lint commit messages.

- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: DeterminateSystems/flake-checker-action@main

- name: Install uv
uses: astral-sh/setup-uv@v6

- name: Nix Format Check
run: nix fmt -- . --check

- name: Set up Python
run: uv python install 3.13

- name: Install the project
run: |
uv sync --all-extras
source .venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV

- name: Commit metadata
run: |
merge_base="$(git merge-base "origin/$GITHUB_BASE_REF" HEAD)" || {
echo >&2 "Failed to find fork point for origin/$GITHUB_BASE_REF."
exit 1
}
# Notes:
# * Merge commits are not checked. We always use rebases instead of
# merges to keep a linear history, which makes merge commits disappear
# ultimately, making them only a CI artifact which should not be
# checked.
scripts/lint_commits.py "$merge_base"

if: ${{ github.event_name == 'pull_request' }}

- name: License header check
run: scripts/license_check.py

- name: Dependency license check
run: |
# Ignore MPL 2.0 which is weak copy left
uv tool run licensecheck --zero --ignore-licenses "MPL 2.0"

- name: Lint with Ruff
run: |
ruff format --check

- name: Check with Ruff (All rules)
run: |
ruff check --statistics
continue-on-error: true

- name: Check with Ruff
run: |
ruff check --config=ruff-ci.toml --output-format=github

- name: Type check with pyright
run: |
pyright
continue-on-error: true
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Required so we can lint commit messages.

- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: DeterminateSystems/flake-checker-action@main

- name: Install uv
uses: astral-sh/setup-uv@v6

- name: Nix Format Check
run: nix fmt -- . --check

- name: Install the project
run: |
uv sync --all-extras --python 3.14
source .venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV

- name: Commit metadata
run: |
merge_base="$(git merge-base "origin/$GITHUB_BASE_REF" HEAD)" || {
echo >&2 "Failed to find fork point for origin/$GITHUB_BASE_REF."
exit 1
}
# Notes:
# * Merge commits are not checked. We always use rebases instead of
# merges to keep a linear history, which makes merge commits disappear
# ultimately, making them only a CI artifact which should not be
# checked.
scripts/lint_commits.py "$merge_base"

if: ${{ github.event_name == 'pull_request' }}

- name: License header check
run: scripts/license_check.py

- name: Dependency license check
run: |
# Ignore MPL 2.0 which is weak copy left
uv tool run licensecheck --zero --ignore-licenses "MPL 2.0"

- name: Lint with Ruff
run: |
ruff format --check

- name: Check with Ruff (All rules)
run: |
ruff check --statistics
continue-on-error: true

- name: Check with Ruff
run: |
ruff check --config=ruff-ci.toml --output-format=github

- name: Type check with pyright
run: |
pyright
continue-on-error: true

test:
runs-on: ubuntu-latest
Expand All @@ -94,21 +90,17 @@ jobs:
- "3.13"
- "3.14"
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v6

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- uses: actions/checkout@v4

- name: Install the project
run: |
uv sync --all-extras
source .venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
- name: Install uv
uses: astral-sh/setup-uv@v6

- name: Test with pytest
run: |
pytest
- name: Install the project
run: |
uv sync --all-extras --python ${{ matrix.python-version }}
source .venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV

- name: Test with pytest
run: |
pytest
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.12
3.14
30 changes: 15 additions & 15 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/dvsim/utils/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def rm_path(path: Path, *, ignore_error: bool = False) -> None:
path = Path(path)

# Nothing to do
if not path.exists(follow_symlinks=False):
if not path.exists():
return

if path.is_file() or path.is_symlink():
Expand Down
23 changes: 20 additions & 3 deletions tests/utils/test_fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,30 @@ def test_symlink_creation(tmp_path: Path) -> None:

mk_symlink(path=dest_path, link=src_path)

assert_that(src_path.is_symlink(), equal_to(True))

# Despite the dest_path not yet existing the two paths should still
# resolve to the same path
assert_that(src_path.resolve(), equal_to(dest_path))

# Make a temporary file in the destination directory
dest_path.mkdir(parents=True)
(dest_path / "temp").touch()

# Check the file is now visible from the symlink
assert_that((src_path / "temp").exists(), equal_to(True))

# remove the created file via the symlink
rm_path(src_path / "temp")

# Check it's gone
assert_that((src_path / "temp").exists(), equal_to(False))

rm_path(src_path)

# Check the symlink itself exists
assert_that(src_path.is_symlink(), equal_to(False))
assert_that(src_path.exists(follow_symlinks=False), equal_to(False))
# Check the symlink itself has been removed and not the destination dir
assert_that(src_path.exists(), equal_to(False))
assert_that(dest_path.exists(), equal_to(True))


def test_overwrite_file_with_symlink_raises(tmp_path: Path) -> None:
Expand Down
Loading
Loading