Skip to content
Merged
218 changes: 218 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
name: Unit Tests

on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
workflow_dispatch:

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

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

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

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

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"

97 changes: 97 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,55 @@ cf --help

## Quick Start

### For New Projects (Starting from Template)

1. **Clone the template** (or create new directory):
```bash
git clone https://github.com/chipfoundry/caravel_user_project my_project
cd my_project
```

2. **Set up the project** (replaces `make setup`):
```bash
cf setup
```

3. **Generate SSH Key** (if you don't have one):
```bash
cf keygen
```

4. **Register your key** at [https://chipfoundry.io/sftp-registration](https://chipfoundry.io/sftp-registration)

5. **Configure your credentials**:
```bash
cf config
```

6. **Upload your project**:
```bash
cf push
```

7. **Download results** (when available):
```bash
cf pull
```

8. **View tapeout report**:
```bash
cf view-tapeout-report
```

9. **Confirm final tapeout** (when ready to send GDS to foundry):
```bash
cf confirm
```

### For Existing Projects

If you already have a project with a Makefile:

1. **Generate SSH Key** (if you don't have one):
```bash
cf keygen
Expand Down Expand Up @@ -153,6 +202,54 @@ cf init [--project-root DIRECTORY]
- Creates `.cf/project.json` with project metadata
- **Note**: GDS hash is generated during `push`, not `init`

### Setup a ChipFoundry Project

```bash
cf setup [OPTIONS]
```

**Replaces `make setup`** - Comprehensive project setup with all dependencies.

**What it does:**
1. Initializes project configuration (`.cf/project.json`)
2. Syncs with upstream repository
3. Installs Caravel/Caravel-Lite
4. Sets up timing scripts
5. Configures Cocotb testing environment
6. Installs precheck tools
7. Pulls Docker images for verification
8. Runs IPM for dependency management

**Key Options:**
- `--only-init`: Just create configuration, skip installations
- `--dry-run`: Preview actions without making changes
- `--pdk TEXT`: Specify PDK variant (default: sky130A)
- `--caravel-lite` / `--no-caravel-lite`: Choose Caravel variant
- `--skip-caravel`, `--skip-openlane`, `--skip-pdk`, etc.: Skip specific installations
- `--repo-owner`, `--repo-name`, `--branch`: Custom repository source

**Examples:**
```bash
# Full setup (replaces make setup)
cf setup

# Quick configuration only
cf setup --only-init

# Preview what will be installed
cf setup --dry-run

# Custom PDK
cf setup --pdk sky130B

# Skip time-consuming installations
cf setup --skip-openlane --skip-pdk
```

**See also:**
- Detailed documentation: [docs/cf-setup.md](docs/cf-setup.md)
- Migration guide: [docs/MIGRATION.md](docs/MIGRATION.md)

### Push a Project (Upload)

```bash
Expand Down
Loading
Loading