|
|
|
|
|
|
|
|
|
|
|
name: CI |
|
|
|
on: |
|
push: |
|
branches: [main] |
|
pull_request: |
|
branches: [main] |
|
|
|
env: |
|
PYTHON_VERSION_MATRIX: "3.9,3.10,3.11" |
|
DOCKER_IMAGE: anycoder:latest |
|
|
|
jobs: |
|
|
|
|
|
|
|
lint-and-test: |
|
runs-on: ubuntu-latest |
|
strategy: |
|
matrix: |
|
python-version: [${{ fromJSON(env.PYTHON_VERSION_MATRIX) }}] |
|
steps: |
|
- uses: actions/checkout@v4 |
|
|
|
- name: Set up Python ${{ matrix.python-version }} |
|
uses: actions/setup-python@v5 |
|
with: |
|
python-version: ${{ matrix.python-version }} |
|
|
|
- name: Install dependencies |
|
run: | |
|
python -m pip install --upgrade pip |
|
pip install -r requirements.txt |
|
pip install flake8 pytest nbmake |
|
# style / typing (optional) |
|
pip install black==24.2.0 mypy |
|
|
|
- name: Lint with flake8 & black‑check |
|
run: | |
|
black --check . |
|
flake8 . |
|
|
|
- name: Run pytest |
|
run: | |
|
pytest -q |
|
|
|
- name: Validate notebooks with nbmake |
|
run: | |
|
pytest --nbmake notebooks/ |
|
|
|
|
|
|
|
|
|
build-frontend: |
|
runs-on: ubuntu-latest |
|
needs: lint-and-test |
|
steps: |
|
- uses: actions/checkout@v4 |
|
- name: Archive static assets |
|
uses: actions/upload-artifact@v4 |
|
with: |
|
name: static-assets |
|
path: | |
|
static/index.html |
|
static/style.css |
|
static/index.js |
|
|
|
|
|
|
|
|
|
build-and-deploy: |
|
runs-on: ubuntu-latest |
|
needs: |
|
- lint-and-test |
|
- build-frontend |
|
if: github.ref == 'refs/heads/main' && github.event_name == 'push' |
|
steps: |
|
- uses: actions/checkout@v4 |
|
|
|
- name: Build Docker image |
|
run: | |
|
docker build -t ${{ env.DOCKER_IMAGE }} . |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|