Skip to content
Open
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
9 changes: 0 additions & 9 deletions setup.cfg → .flake8
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[aliases]
test = pytest
flake8 = flake8

[flake8]
exclude = .git,__pycache__,documentation
max-line-length = 160
Expand All @@ -12,8 +8,3 @@ per-file-ignores =
flexmeasures/__init__.py:F401
flexmeasures/data/schemas/__init__.py:F401
flexmeasures/ui/crud/assets/__init__.py:F401

[tool:pytest]
addopts = --strict-markers --ignore=docker-compose-data
markers =
skip_github: skip test in GitHub Actions. Useful in case the test passes, but breaks the test suite on GH Actions.
4 changes: 2 additions & 2 deletions .github/agents/architecture-domain-specialist.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,11 @@ When reviewing or implementing domain model fixes:
2. **Test the fix end-to-end**:
```bash
# Example: Test a CLI fix
make install-for-dev
uv sync --group dev --group test
flexmeasures <command> <args> # The exact command from bug report
```
3. **Verify domain invariants still hold**:
- Run relevant test suite: `make test` or `pytest path/to/tests`
- Run relevant test suite: `uv run poe test`
- Check database constraints are satisfied
- Verify no regressions in related functionality
4. **Document verification in commit**:
Expand Down
4 changes: 2 additions & 2 deletions .github/agents/coordinator.md
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ Required verification:
**Agents must make successful use of working FlexMeasures dev environment.**
Key capabilities:

- Set up environment: `make install-for-dev` or `make install-for-test`
- Run tests: `pytest` or `make test`
- Set up environment: `uv sync --group dev --group test`
- Run tests: `uv run poe test`
- Test CLI: `flexmeasures <command> <args>`
- Run pre-commit: `pre-commit run --all-files`
- Build docs: `make update-docs`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ When writing documentation:
2. **Test examples in FlexMeasures dev environment**:
```bash
# Verify examples actually work
make install-for-dev
uv sync --group dev --group test
flexmeasures <command from docs>
```
3. **Verify code behavior before documenting**:
Expand Down Expand Up @@ -297,7 +297,7 @@ Before finalizing documentation:

1. **Set up dev environment**:
```bash
make install-for-dev
uv sync --group dev --group test
```
2. **Test CLI examples**:
```bash
Expand Down
2 changes: 1 addition & 1 deletion .github/agents/performance-scalability-specialist.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ Before claiming performance improvements:

1. **Set up dev environment with realistic data**:
```bash
make install-for-dev
uv sync --group dev --group test
# Seed database with production-like data volume
```
2. **Profile existing code**:
Expand Down
8 changes: 3 additions & 5 deletions .github/agents/review-lead.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ Before committing any code changes:

1. **Install pre-commit** (if not already installed):
```bash
pip install pre-commit
uv tool install pre-commit
```

2. **Run hooks on all files**:
Expand Down Expand Up @@ -243,13 +243,11 @@ When conducting a review:

1. **Set up the test environment**:
```bash
make install-for-test
uv sync --group test
```
2. **Run the test suite**:
```bash
pytest
# Or use make target
make test
uv run poe test
```
3. **Show test output** - Include actual results in review:
- Number of tests run
Expand Down
19 changes: 10 additions & 9 deletions .github/agents/test-specialist.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ Setup instructions:

### Running Tests

- **Make command**: `make test` (installs dependencies and runs pytest)
- **Install test dependencies**: `uv sync --group test`
- **Poethepoet command**: `uv run poe test` (Runs pytest 'normally')
- **Direct pytest**: `pytest` (after installing test dependencies)
- **Test a specific file**: `pytest path/to/test_file.py`
- **Test a specific function**: `pytest path/to/test_file.py::test_function_name`
Expand Down Expand Up @@ -117,7 +118,7 @@ The project uses `.pre-commit-config.yaml` to enforce code quality standards. Al

```bash
# Install pre-commit (if not already installed)
pip install pre-commit
uv tool install pre-commit

# Run all pre-commit hooks on all files
pre-commit run --all-files
Expand All @@ -138,7 +139,7 @@ The following hooks are configured in FlexMeasures:
- Auto-fixes code formatting issues

- **mypy**: Performs static type checking
- Custom script: `ci/run_mypy.sh`
- Task: `uv run poe type-check`
- Checks type hints and type safety

- **generate-openapi-specs**: Generates OpenAPI specifications (local only, skipped in GitHub Actions)
Expand Down Expand Up @@ -198,7 +199,7 @@ When reviewing or writing tests:
1. **Set up the test environment** if not already done:
```bash
# Install test dependencies
make install-for-test
uv sync --locked --group test
```
2. **Run the tests you write or review**:
```bash
Expand Down Expand Up @@ -241,12 +242,12 @@ When fixing bugs:
FlexMeasures provides convenient make targets:

```bash
# Install dependencies and run all tests
make test
# Install for development (includes test deps)
make install-for-dev
# Install dependencies
uv sync --group dev --group test
# Run all test
uv run poe test
# Update documentation (includes generating OpenAPI specs)
make update-docs
uv run poe update-docs
```

### FlexMeasures CLI Testing
Expand Down
41 changes: 23 additions & 18 deletions .github/agents/tooling-ci-specialist.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Keep FlexMeasures automation reliable and maintainable by reviewing GitHub Actio
- [ ] **Hook versions**: Hooks use recent, stable versions
- [ ] **Hook coverage**: Appropriate hooks for code quality
- [ ] **Performance**: Hooks run in reasonable time
- [ ] **Configuration**: Hooks configured via `setup.cfg` or `pyproject.toml`
- [ ] **Configuration**: Hooks configured via `pyproject.toml`
- [ ] **Local vs CI**: Some hooks can skip in CI

### Caching Strategy
Expand All @@ -62,7 +62,7 @@ Keep FlexMeasures automation reliable and maintainable by reviewing GitHub Actio

### Linter Configuration

- [ ] **Flake8**: Configured in `setup.cfg` with appropriate rules
- [ ] **Flake8**: Configured in `.flake8` with appropriate rules
- [ ] **Black**: Line length and style consistent
- [ ] **Mypy**: Type checking configuration appropriate
- [ ] **Consistency**: Settings match across local and CI
Expand All @@ -87,9 +87,8 @@ This file defines standardized environment setup for GitHub Copilot agents. When
- Other system tools

- [ ] **Python environment**:
- Is Python version appropriate? (Default: 3.11)
- Are dependencies installed correctly? (`pip-sync`, `pip install -e .`)
- Is pip-tools version pinned?
- Is Python version appropriate according to `.python-version`?
- Are dependencies installed correctly? (`uv sync`)

- [ ] **Database setup**:
- Is PostgreSQL service started?
Expand Down Expand Up @@ -145,23 +144,30 @@ This file defines standardized environment setup for GitHub Copilot agents. When

1. **flake8** (v7.1.1) - Python linting
2. **black** (v24.8.0) - Code formatting
3. **mypy** (local script) - Type checking via `ci/run_mypy.sh`
3. **mypy** (local task) - Type checking via `uv run poe type-check`
4. **generate-openapi-specs** (local, skipped in CI)

Setup:
```bash
pip install pre-commit
uv tool install pre-commit
pre-commit run --all-files
```

### Flake8 Configuration

`setup.cfg`:
`.flake8`:
```ini
[flake8]
exclude = .git,__pycache__,documentation
max-line-length = 160
max-complexity = 13
select = B,C,E,F,W,B9
ignore = E501, W503, E203
per-file-ignores =
flexmeasures/__init__.py:F401
flexmeasures/data/schemas/__init__.py:F401
flexmeasures/ui/crud/assets/__init__.py:F401

```

Ignored rules:
Expand All @@ -179,13 +185,13 @@ Ignored rules:

**Test execution**:
```bash
make install-for-test # Install dependencies
make test # Run pytest
uv sync --group test # Install dependencies
uv run poe test # Run pytest
```

### Caching Strategy

Pip cache configuration:
Uv cache configuration:
```yaml
uses: actions/cache@v4
with:
Expand Down Expand Up @@ -222,10 +228,9 @@ pytest -k test_auth_token # Ensure auth setup runs

- Workflows: `.github/workflows/`
- Pre-commit: `.pre-commit-config.yaml`
- Linter config: `setup.cfg`
- Mypy runner: `ci/run_mypy.sh`
- Linter config: `.flake8`
- Task runner: `pyproject.toml` (poethepoet tasks)
- PostgreSQL setup: `ci/setup-postgres.sh`
- Makefile: `Makefile`
- Docker: `Dockerfile`, `docker-compose.yml`

## Interaction Rules
Expand Down Expand Up @@ -312,15 +317,15 @@ Before committing CI changes:

1. **Test pre-commit hooks locally**:
```bash
pip install pre-commit
uv tool install pre-commit
pre-commit install
pre-commit run --all-files
```
2. **Test make targets**:
```bash
make install-for-test
make test
make update-docs
uv sync --group test
uv run poe test
uv run poe update-docs
```
3. **Verify pytest configuration**:
```bash
Expand Down
46 changes: 17 additions & 29 deletions .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,52 +15,40 @@ jobs:
steps:
- name: Install system dependencies
run: |
# Update package list
sudo apt-get update

# Install PostgreSQL client libraries (required for psycopg2)
sudo apt-get install -y libpq-dev

# Install Redis (used for job queuing)
sudo apt-get install -y redis-server
# Install PostgreSQL client libraries (required for psycopg2) and Redis (used for job queuing)
sudo apt-get update && sudo apt-get install -y --no-install-recommends \
libpq-dev redis-server && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Start Redis service
sudo service redis-server start

- name: Set Python version
run: |
# FlexMeasures supports Python 3.10-3.12
# Use Python 3.11 as the default for agent development
python --version || python3 --version

- name: Install pip-tools
run: |
# Install pip-tools for dependency management
pip3 install -q "pip-tools>=7.2"
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
uv-version: 0.10
python-version-file: ".python-version"

- name: Install Python dependencies for testing
run: |
# Get Python version (major.minor)
PYV=$(python -c "import sys;t='{v[0]}.{v[1]}'.format(v=list(sys.version_info[:2]));sys.stdout.write(t)")

# Install pinned test and app dependencies
pip-sync requirements/${PYV}/app.txt requirements/${PYV}/test.txt

# Install FlexMeasures in editable mode
pip install -e .
run: uv sync --locked --group test --group dev

- name: Install pre-commit hooks
run: |
# Install pre-commit for code quality checks
pip install pre-commit
uv tool install pre-commit

# Install the pre-commit hooks
pre-commit install

- name: Setup PostgreSQL for testing
run: |
# Install PostgreSQL if not already available
sudo apt-get install -y postgresql postgresql-contrib
sudo apt-get install -y --no-install-recommends \
postgresql postgresql-contrib && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Start PostgreSQL service
sudo service postgresql start
Expand Down
Loading