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
68 changes: 3 additions & 65 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,79 +34,17 @@
memory-sizes: '["256mb"]'
skip-full-test-modes: "[]"
caller-event-name: ${{ github.event_name }}
windows-test: false
windows-test: true
python-paths: ".nanvix/z.py tests/smoke_test_l2.py"
yaml-paths: ".github/workflows/ci.yml"
release-notes-extra: |
CPython 3.12.3 distribution for Nanvix with pure Python pip packages.
docker-image: "ghcr.io/nanvix/toolchain-python@sha256:2ef7213bfff85e927f18d8f0fc53063b9c6ffed236a6b30c92f6b4e148c2dec4" # yamllint disable-line rule:line-length

Check warning on line 42 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / ci / Format & Lint

42:127 [comments] too few spaces before comment
test-output-globs: '["nanvix_rootfs.img"]'
secrets:
GH_TOKEN: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
DISPATCH_TOKEN: ${{ secrets.DISPATCH_TOKEN || secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}

# Custom Windows test that reuses the ramfs image from the Linux build
# instead of rebuilding it (Docker can't run the Linux toolchain image
# on Windows CI runners, so .py→.pyc pre-compilation would be skipped).
windows-test:
needs: ci
if: >-
!cancelled()
&& needs.ci.result == 'success'
runs-on: windows-latest
env:
NANVIX_MACHINE: microvm
NANVIX_DEPLOYMENT_MODE: standalone
NANVIX_MEMORY_SIZE: 256mb
NANVIX_VERSION: ${{ needs.ci.outputs.nanvix_tag }}
steps:
- uses: actions/checkout@v5

- name: Install nanvix-zutil
env:
GH_TOKEN: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
shell: pwsh
run: |
$zutils_version = (Get-Content .zutils-version).Trim()
$jq = '.assets[] | select(.name | endswith(".whl")) | .browser_download_url'
$wheel = gh api "repos/nanvix/zutils/releases/tags/$zutils_version" --jq $jq
python -m pip install $wheel

- name: Setup
env:
GH_TOKEN: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
shell: pwsh
run: >-
nanvix-zutil setup --with-docker
ghcr.io/nanvix/toolchain-python@sha256:2ef7213bfff85e927f18d8f0fc53063b9c6ffed236a6b30c92f6b4e148c2dec4

- name: Download Linux build artifact
uses: actions/download-artifact@v5
with:
name: >-
nanvix-python-${{ needs.ci.outputs.package_version }}-x86-microvm-standalone-256mb
path: linux-build

- name: Extract ramfs from Linux tarball
shell: pwsh
run: |
$tarball = Get-ChildItem linux-build -Filter "*.tar.gz" | Select-Object -First 1
if (-not $tarball) { Write-Error "No .tar.gz tarball found in linux-build"; exit 1 }
Write-Host "Extracting ramfs from $($tarball.Name)"
tar -xzf $tarball.FullName -C linux-build
$ramfs = Get-ChildItem linux-build -Recurse -Filter "nanvix_rootfs.img" | Select-Object -First 1
if (-not $ramfs) { Write-Error "nanvix_rootfs.img not found in tarball"; exit 1 }
$dest = Join-Path $env:GITHUB_WORKSPACE ".nanvix" "out" "test" "nanvix_rootfs.img"
New-Item -ItemType Directory -Force -Path (Split-Path $dest) | Out-Null
Copy-Item $ramfs.FullName $dest
Write-Host "Placed ramfs at $dest ($('{0:N0}' -f (Get-Item $dest).Length) bytes)"
echo "NANVIX_PREBUILT_RAMFS=$dest" >> $env:GITHUB_ENV

- name: Test
env:
GH_TOKEN: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
shell: pwsh
run: nanvix-zutil test

release:
needs: ci
if: github.event_name != 'pull_request'
Expand Down Expand Up @@ -184,7 +122,7 @@
fi

windows-release:
needs: [ci, windows-test, release]
needs: [ci, release]
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
env:
Expand Down
16 changes: 12 additions & 4 deletions .nanvix/src/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from __future__ import annotations

import hashlib
from os import environ
import shutil
import subprocess
import sys
Expand Down Expand Up @@ -82,11 +83,18 @@ def _ramfs_input_hash(self, sysroot: Path) -> str:
def _ensure_ramfs(self, sysroot: Path) -> Path:
"""Validate that an up-to-date ramfs image exists.

Used by ``test``, ``release``, and ``benchmark``: never builds.
Building the ramfs requires Docker (for .pyc pre-compilation)
and is therefore confined to ``./z build`` via
:meth:`_build_ramfs`. A missing or stale image is fatal.
Used by ``test``, ``release``, and ``benchmark``: never builds. Building
the ramfs requires Docker (for .pyc pre-compilation) and is therefore
confined to ``./z build`` via :meth:`_build_ramfs`. A missing or stale
Comment on lines 84 to +88
image is fatal. In CI, this short-circuits if the expected ramfs image
is found.
"""
if environ.get("CI"):
img = test_out() / "nanvix_rootfs.img"
if img.is_file():
self._ramfs_img = img
return self._ramfs_img

if self._ramfs_img and self._ramfs_img.is_file():
return self._ramfs_img

Expand Down
14 changes: 1 addition & 13 deletions .nanvix/src/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,7 @@ def test(self) -> None:
if deployment == "standalone":
# Install _boot.py entry point into sysroot
self._install_boot_script(sysroot)

prebuilt = os.environ.get("NANVIX_PREBUILT_RAMFS")
if prebuilt:
p = Path(prebuilt)
if not p.is_file():
log.fatal(
f"NANVIX_PREBUILT_RAMFS points to non-existent file: {p}",
code=EXIT_MISSING_DEP,
)
log.info(f"using pre-built ramfs: {p}")
self._ramfs_img = p
else:
self._ensure_ramfs(sysroot)
self._ensure_ramfs(sysroot)

# Standalone exclusions
exclude_tests = os.environ.get("EXCLUDE_TESTS", "")
Expand Down
Loading