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
247 changes: 47 additions & 200 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,217 +2,64 @@ name: Unit Tests

on:
push:
branches:
- main
- develop
branches: [ main, develop ]
pull_request:
branches:
- main
- develop
workflow_dispatch:
branches: [ main, develop ]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true

- name: Cache dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
venv-${{ runner.os }}-${{ matrix.python-version }}-

- name: Install dependencies
run: |
poetry install --no-interaction --no-root

- name: Install project
run: |
poetry install --no-interaction

- name: Run unit tests
run: |
poetry run pytest tests/ -v --cov=chipfoundry_cli --cov-report=xml --cov-report=term

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]

test-setup-command:
runs-on: ubuntu-latest
needs: test

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install dependencies
run: |
poetry install --no-interaction

- name: Test cf setup --dry-run
run: |
poetry run cf setup --dry-run --only-init

- name: Test cf setup with skip flags
run: |
mkdir -p test-project
cd test-project
poetry run cf setup --only-init --skip-ipm

- name: Verify project.json created
run: |
test -f test-project/.cf/project.json
echo "✓ project.json created successfully"

- name: Test cf setup help
run: |
poetry run cf setup --help
- uses: actions/checkout@v4

lint:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install dependencies
run: |
poetry install --no-interaction

- name: Run ruff linter
run: |
poetry run ruff check chipfoundry_cli/ tests/ || true

- name: Run black formatter check
run: |
poetry run black --check chipfoundry_cli/ tests/ || true

- name: Run mypy type checker
run: |
poetry run mypy chipfoundry_cli/ || true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

test-docker:
runs-on: ubuntu-latest
needs: test

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install dependencies
run: |
poetry install --no-interaction

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Test Docker availability for setup
run: |
docker --version
docker info

- name: Test cf setup with Docker checks (dry-run)
run: |
poetry run cf setup --dry-run
- name: Install Poetry
run: |
python -m pip install --upgrade pip
pip install poetry

integration-test:
runs-on: ubuntu-latest
needs: test

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install dependencies
run: |
poetry install --no-interaction

- name: Run integration tests
run: |
# Create a test project directory
mkdir -p integration-test-project
cd integration-test-project

# Create a dummy GDS file to test detection
mkdir -p gds
echo "dummy gds" > gds/user_project_wrapper.gds

# Run cf init
cd ..
poetry run cf init --project-root integration-test-project <<EOF
test-project
digital
EOF || true

# Run cf setup with only-init
poetry run cf setup --project-root integration-test-project --only-init

# Verify files were created
test -f integration-test-project/.cf/project.json
echo "✓ Integration test passed"

- name: Display project.json
run: |
cat integration-test-project/.cf/project.json
echo "✓ Project configuration looks good"
- name: Configure Poetry
run: |
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
run: poetry install --no-interaction --no-root

- name: Install project
run: poetry install --no-interaction

- name: Run unit tests for all commands
run: |
poetry run pytest tests/ -v --cov=chipfoundry_cli --cov-report=term-missing --cov-report=json --cov-report=html

- name: Upload coverage to GitHub
uses: actions/upload-artifact@v4
with:
name: coverage-report-${{ matrix.os }}-py${{ matrix.python-version }}
path: htmlcov/
retention-days: 30

- name: Generate coverage summary
if: github.event_name == 'pull_request'
run: |
echo "## Coverage Summary (${{ matrix.os }}, Python ${{ matrix.python-version }})" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
poetry run pytest tests/ --cov=chipfoundry_cli --cov-report=term --quiet 2>&1 | grep -A 10 "TOTAL" >> $GITHUB_STEP_SUMMARY || echo "Coverage: See artifacts for detailed report" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
Loading
Loading