feat: add nexuslims extract CLI command for single-file extraction #330
Workflow file for this run
This file contains hidden or 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
| name: Unit Tests | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| jobs: | |
| test: | |
| name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.11", "3.12", "3.13", "3.14"] | |
| os: [ubuntu-latest, macos-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install system dependencies (Ubuntu) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y findutils | |
| - name: Install system dependencies (macOS) | |
| if: matrix.os == 'macos-latest' | |
| run: | | |
| brew install findutils | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: uv sync | |
| - name: Run unit tests | |
| run: | | |
| uv run pytest tests/unit/ --cov=nexusLIMS \ | |
| --cov-report html:tests/coverage \ | |
| --cov-report term-missing \ | |
| --cov-report=xml \ | |
| --mpl --mpl-baseline-path=tests/unit/files/figs | |
| - name: Upload coverage database | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-db-${{ matrix.python-version }}-${{ matrix.os }} | |
| path: .coverage | |
| include-hidden-files: true | |
| - name: Upload HTML coverage report | |
| if: matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-html-${{ matrix.python-version }} | |
| path: tests/coverage | |
| coverage: | |
| # Combine coverage from all test runs and upload to Codecov | |
| name: Coverage Reports | |
| needs: test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install coverage tools | |
| run: pip install coverage | |
| - name: Download all coverage artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: coverage-db-* | |
| path: coverage-reports | |
| - name: Combine coverage reports | |
| run: | | |
| # List downloaded files for debugging | |
| find coverage-reports -name .coverage -type f | |
| # Move all .coverage files to current directory with unique names | |
| find coverage-reports -name .coverage -type f -exec sh -c 'cp "$1" ".coverage.$(basename $(dirname $1))"' _ {} \; | |
| # Combine all .coverage.* files | |
| coverage combine | |
| # Generate combined XML report | |
| coverage xml -o combined-coverage.xml | |
| # Show report in logs | |
| coverage report | |
| package-smoke-test: | |
| # Smoke test for package installation | |
| # Verifies that the built wheel can be installed and all functionality works | |
| name: Package Installation Smoke Test (Python ${{ matrix.python-version }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.11", "3.12", "3.13", "3.14"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Build wheel | |
| run: uv build --wheel | |
| - name: Create fresh virtual environment and install wheel | |
| run: | | |
| # Create a fresh venv using Python's built-in venv module | |
| python${{ matrix.python-version }} -m venv /tmp/test-venv | |
| # Install the wheel | |
| /tmp/test-venv/bin/pip install --no-deps dist/*.whl | |
| # Install dependencies separately to verify package metadata is correct | |
| /tmp/test-venv/bin/pip install dist/*.whl | |
| - name: Test CLI entry points exist | |
| run: | | |
| echo "Testing CLI entry points..." | |
| /tmp/test-venv/bin/nexuslims --version | |
| /tmp/test-venv/bin/nexuslims --help | |
| /tmp/test-venv/bin/nexuslims build-records --help | |
| /tmp/test-venv/bin/nexuslims config --help | |
| /tmp/test-venv/bin/nexuslims db --help | |
| /tmp/test-venv/bin/nexuslims instruments manage --help | |
| - name: Test CLI help works without .env file | |
| run: | | |
| echo "Testing CLI help commands work without .env..." | |
| /tmp/test-venv/bin/nexuslims config --help | |
| /tmp/test-venv/bin/nexuslims config edit --help | |
| /tmp/test-venv/bin/nexuslims config dump --help | |
| /tmp/test-venv/bin/nexuslims config load --help | |
| - name: Test package data files are loadable | |
| run: | | |
| echo "Testing package data files..." | |
| /tmp/test-venv/bin/python << 'EOF' | |
| from pathlib import Path | |
| # Test XSD file | |
| from nexusLIMS.schemas import activity | |
| xsd_path = Path(activity.__file__).parent / "nexus-experiment.xsd" | |
| assert xsd_path.exists(), f"XSD not found: {xsd_path}" | |
| print(f"✓ XSD file: {xsd_path}") | |
| # Test OWL file | |
| from nexusLIMS.schemas import em_glossary | |
| assert em_glossary.EMG_OWL_PATH.exists(), f"OWL not found" | |
| print(f"✓ OWL file: {em_glossary.EMG_OWL_PATH}") | |
| # Test TTL file | |
| from nexusLIMS.schemas import units | |
| assert units.QUDT_UNIT_TTL_PATH.exists(), f"TTL not found" | |
| print(f"✓ TTL file: {units.QUDT_UNIT_TTL_PATH}") | |
| # Test migration files | |
| from nexusLIMS.db import migrations | |
| migrations_dir = Path(migrations.__file__).parent | |
| env_py = migrations_dir / "env.py" | |
| assert env_py.exists(), f"Migration env.py not found" | |
| print(f"✓ Migration files: {migrations_dir}") | |
| print("\n✓ All package data files verified!") | |
| EOF | |
| - name: Test basic module imports | |
| run: | | |
| echo "Testing basic imports..." | |
| /tmp/test-venv/bin/python -c " | |
| from nexusLIMS import __version__ | |
| print(f'✓ NexusLIMS version: {__version__}') | |
| # Test that config module can be imported without triggering validation | |
| from nexusLIMS.config import Settings | |
| print('✓ Settings class importable') | |
| # Test TUI can be imported without .env | |
| from nexusLIMS.tui.apps.config.app import ConfiguratorApp | |
| print('✓ ConfiguratorApp importable') | |
| " |