Skip to content

Commit ad25f49

Browse files
committed
Debug windows-11-arm
1 parent f67aa5f commit ad25f49

File tree

3 files changed

+77
-36
lines changed

3 files changed

+77
-36
lines changed

.github/workflows/dissect-ci.yml

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,45 +17,78 @@ jobs:
1717

1818
build-native:
1919
runs-on: ${{ matrix.os }}
20+
continue-on-error: true
2021
strategy:
2122
matrix:
2223
os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, windows-11-arm, macos-13, macos-14]
2324
steps:
24-
- uses: fox-it/dissect-workflow-templates/.github/actions/git-checkout@main
25+
- uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
29+
- run: git lfs install --local
2530

26-
- if: runner.os == 'Linux' && runner.arch == 'X64'
31+
- name: Create LFS file list
32+
run: git lfs ls-files --long | cut -d ' ' -f1 | sort > .lfs-assets-id
33+
34+
- name: Cache LFS
35+
uses: actions/cache@v4
36+
with:
37+
path: .git/lfs
38+
key: lfs-${{ hashFiles('.lfs-assets-id') }}-v1
39+
40+
- name: Pull LFS
41+
run: git lfs pull
42+
43+
- name: Setup QEMU (Linux only)
44+
if: runner.os == 'Linux' && runner.arch == 'X64'
2745
uses: docker/setup-qemu-action@v3
2846
with:
2947
platforms: all
3048

31-
- run: curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable
49+
- name: Setup Rust
50+
if: ${{ matrix.os != 'windows-11-arm' }}
51+
run: curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable
52+
53+
- name: Setup Rust (Windows 11 ARM)
54+
if: ${{ matrix.os == 'windows-11-arm' }}
55+
run: |
56+
Invoke-WebRequest -Uri "https://win.rustup.rs/aarch64" -OutFile "$env:TEMP\rustup-init.exe"
57+
& "$env:TEMP\rustup-init.exe" -y
58+
"$env:USERPROFILE\.cargo\bin" | Out-File -Append -Encoding ascii $env:GITHUB_PATH
59+
"CARGO_HOME=$env:USERPROFILE\.cargo" | Out-File -Append -Encoding ascii $env:GITHUB_ENV
60+
shell: pwsh
3261

33-
- uses: actions/setup-python@v5
62+
- name: Setup Python
63+
uses: actions/setup-python@v5
3464
with:
35-
python-version: "3.12"
65+
python-version: "3.13"
3666

37-
- run: python -m pip install cibuildwheel==2.23.2
67+
- name: Install cibuildwheel
68+
run: python -m pip install cibuildwheel==2.23.2
3869

39-
- run: python -m cibuildwheel --output-dir dist
70+
- name: Build wheels
71+
run: python -m cibuildwheel --output-dir dist
4072
env:
4173
CIBW_ARCHS_LINUX: ${{ runner.arch == 'X64' && 'auto ppc64le s390x' || 'auto armv7l' }}
74+
CIBW_ARCHS_WINDOWS: ${{ runner.arch == 'X64' && 'AMD64 x86' || 'ARM64' }}
4275
CIBW_BEFORE_ALL_LINUX: curl -sSf https://sh.rustup.rs | sh -s -- -y
4376
CIBW_BEFORE_ALL_WINDOWS: ${{ runner.arch == 'X64' && 'rustup target add i686-pc-windows-msvc' || '' }}
4477
# Manually install setuptools-rust to enable building native wheels
4578
CIBW_BEFORE_BUILD: >
4679
python -m pip install -U setuptools>=77.0.0 setuptools_scm[toml]>=6.4.0 setuptools-rust
4780
CIBW_BUILD_FRONTEND: "build; args: --no-isolation"
48-
CIBW_CONFIG_SETTINGS: "--build-option=--py-limited-api=cp39"
81+
CIBW_CONFIG_SETTINGS: --build-option=--py-limited-api=cp39
4982
CIBW_ENABLE: pypy
50-
CIBW_ENVIRONMENT_LINUX: 'PATH="$HOME/.cargo/bin:$PATH"'
51-
CIBW_ENVIRONMENT_MACOS: 'MACOSX_DEPLOYMENT_TARGET=10.12'
52-
CIBW_ENVIRONMENT_WINDOWS: 'PATH="$UserProfile\.cargo\bin;$PATH"'
83+
CIBW_ENVIRONMENT_LINUX: PATH="$HOME/.cargo/bin:$PATH"
84+
CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET=10.12
5385
CIBW_SKIP: '*-musllinux_i686'
5486
# Run tests
5587
CIBW_TEST_REQUIRES: tox
5688
CIBW_TEST_COMMAND: tox -e native -c {package}/tox.ini --installpkg {wheel}
5789

58-
- run: pip install abi3audit && abi3audit --strict --report dist/*-abi3-*.whl
90+
- name: Run abi3audit
91+
run: pip install abi3audit && abi3audit --strict --report dist/*-abi3-*.whl
5992

6093
- uses: actions/upload-artifact@v4
6194
with:

dissect/util/ts.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
from __future__ import annotations
22

33
import struct
4-
import sys
54
from datetime import datetime, timedelta, timezone, tzinfo
65

7-
if sys.platform in ("win32", "emscripten"):
6+
try:
7+
datetime.fromtimestamp(-6969696969, tz=timezone.utc)
8+
9+
def _calculate_timestamp(ts: float) -> datetime:
10+
"""Calculate timestamps normally."""
11+
return datetime.fromtimestamp(ts, tz=timezone.utc)
12+
except (OSError, OverflowError):
813
_EPOCH = datetime(1970, 1, 1, tzinfo=timezone.utc)
914

1015
def _calculate_timestamp(ts: float) -> datetime:
@@ -16,12 +21,6 @@ def _calculate_timestamp(ts: float) -> datetime:
1621
"""
1722
return _EPOCH + timedelta(seconds=ts)
1823

19-
else:
20-
21-
def _calculate_timestamp(ts: float) -> datetime:
22-
"""Calculate timestamps normally."""
23-
return datetime.fromtimestamp(ts, tz=timezone.utc)
24-
2524

2625
def now() -> datetime:
2726
"""Return an aware datetime object of the current time in UTC."""

tests/test_ts.py

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
1-
import platform
21
from datetime import datetime, timedelta, timezone
32
from importlib import reload
43
from types import ModuleType
4+
from typing import NoReturn
55
from unittest.mock import patch
66

77
import pytest
88

99

10-
@pytest.fixture(params=["windows", "emscripten", "linux"])
10+
@pytest.fixture(params=[True, False])
1111
def imported_ts(request: pytest.FixtureRequest) -> ModuleType:
12-
with patch.object(platform, "system", return_value=request.param):
13-
from dissect.util import ts
12+
from dissect.util import ts
13+
14+
if request.param:
15+
16+
class MockDatetime(datetime):
17+
@classmethod
18+
def fromtimestamp(cls, *args, **kwargs) -> NoReturn:
19+
raise OverflowError("Mock overflow error")
1420

15-
return reload(ts)
21+
with patch("datetime.datetime", MockDatetime):
22+
return reload(ts)
23+
24+
return reload(ts)
1625

1726

1827
@pytest.fixture
@@ -32,32 +41,32 @@ def test_now(ts: ModuleType) -> None:
3241
assert ts_now.tzinfo == timezone.utc
3342

3443

35-
def test_unix_now(imported_ts: ModuleType) -> None:
36-
timestamp = imported_ts.unix_now()
44+
def test_unix_now(ts: ModuleType) -> None:
45+
timestamp = ts.unix_now()
3746

3847
assert isinstance(timestamp, int)
3948
assert datetime.fromtimestamp(timestamp, tz=timezone.utc).microsecond == 0
4049

4150

42-
def test_unix_now_ms(imported_ts: ModuleType) -> None:
43-
timestamp = imported_ts.unix_now_ms()
51+
def test_unix_now_ms(ts: ModuleType) -> None:
52+
timestamp = ts.unix_now_ms()
4453

4554
assert isinstance(timestamp, int)
46-
assert imported_ts.from_unix_ms(timestamp).microsecond == (timestamp % 1e3) * 1000
55+
assert ts.from_unix_ms(timestamp).microsecond == (timestamp % 1e3) * 1000
4756

4857

49-
def test_unix_now_us(imported_ts: ModuleType) -> None:
50-
timestamp = imported_ts.unix_now_us()
58+
def test_unix_now_us(ts: ModuleType) -> None:
59+
timestamp = ts.unix_now_us()
5160

5261
assert isinstance(timestamp, int)
53-
assert imported_ts.from_unix_us(timestamp).microsecond == timestamp % 1e6
62+
assert ts.from_unix_us(timestamp).microsecond == timestamp % 1e6
5463

5564

56-
def test_unix_now_ns(imported_ts: ModuleType) -> None:
57-
timestamp = imported_ts.unix_now_ns()
65+
def test_unix_now_ns(ts: ModuleType) -> None:
66+
timestamp = ts.unix_now_ns()
5867

5968
assert isinstance(timestamp, int)
60-
assert imported_ts.from_unix_ns(timestamp).microsecond == int((timestamp // 1000) % 1e6)
69+
assert ts.from_unix_ns(timestamp).microsecond == int((timestamp // 1000) % 1e6)
6170

6271

6372
def test_to_unix(ts: ModuleType) -> None:

0 commit comments

Comments
 (0)