Skip to content

Commit

Permalink
Merge branch 'main' into advay/add-bazel-cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesfrye authored May 6, 2024
2 parents 2264a8b + 75d6c99 commit 1394470
Show file tree
Hide file tree
Showing 20 changed files with 881 additions and 326 deletions.
36 changes: 36 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: setup

description: Set up a Python environment for the examples.

inputs:
version:
description: Which Python version to install
required: false
default: "3.11"
devDependencies:
description: Whether to skip dependencies
required: false
default: "no-skip"

runs:
using: composite
steps:
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.version }}

- name: Install base packages
shell: bash
run: |
pip install uv
uv pip install --system setuptools wheel
- name: Install development Python packages
if: ${{ inputs.devDependencies != 'skip' }}
shell: bash
run: uv pip install --system -r internal/requirements.txt

- name: Install the modal client
shell: bash
run: uv pip install --system modal
8 changes: 2 additions & 6 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,9 @@ jobs:

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: "3.9"

- name: Install Modal client package and jupytext
run: pip install modal-client jupytext pydantic~=1.10
fetch-depth: 1
- uses: ./.github/actions/setup

- name: Run deployment script
run: |
Expand Down
27 changes: 7 additions & 20 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@ jobs:

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: "3.11"

# keep version here in sync with .pre-commit-config.yaml and other modal repos
- run: pip install ruff==0.2.1
fetch-depth: 1
- uses: ./.github/actions/setup

- run: ruff check

Expand All @@ -31,33 +27,24 @@ jobs:

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install NbConvert
run: pip install jupyter nbconvert
fetch-depth: 1
- uses: ./.github/actions/setup

- name: Check notebooks are cleaned
run: |
jupyter nbconvert --clear-output --inplace 11_notebooks/*.ipynb
git diff --quiet && git diff --cached --quiet || exit 1
git diff --quiet 11_notebooks/*.ipynb && git diff --cached --quiet 11_notebooks/*.ipynb || exit 1
pytest:
name: Pytest
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install dev dependencies
run: pip install pytest jupytext pydantic~=1.10

- name: Install the Modal client
run: pip install modal-client
fetch-depth: 1
- uses: ./.github/actions/setup

- name: Run
run: pytest -v .
76 changes: 76 additions & 0 deletions .github/workflows/run-examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Run

on:
pull_request:
branches:
- main
paths:
- "**.py"
push:
branches:
- main
paths:
- "**.py"
workflow_dispatch:

# Cancel previous runs of the same PR but do not cancel previous runs on main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

env:
TERM: linux
TERMINFO: /etc/terminfo
MODAL_TOKEN_ID: ${{ secrets.MODAL_MODAL_LABS_TOKEN_ID }}
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_MODAL_LABS_TOKEN_SECRET }}
MODAL_ENVIRONMENT: main

jobs:
# Output all changed files in a JSON format compatible with GitHub Actions job matrices
diff-matrix:
name: Generate matrix of changed examples
runs-on: ubuntu-20.04
outputs:
matrix: ${{ steps.diff.outputs.all_changed_files }}

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Find changed examples
id: diff
uses: tj-actions/changed-files@v44
with:
files: "**.py"
files_ignore: "internal/**,misc/**"
matrix: true

- name: List all changed examples
run: echo '${{ steps.diff.outputs.all_changed_files }}'

# Run each changed example, using the output of the previous step as a job matrix
run-changed:
name: Run changed example
needs: [diff-matrix]
if:
${{ needs.diff-matrix.outputs.matrix != '[]' &&
needs.diff-matrix.outputs.matrix != '' }}
runs-on: ubuntu-20.04
strategy:
matrix:
file: ${{ fromJson(needs.diff-matrix.outputs.matrix) }}
fail-fast: false

steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: ./.github/actions/setup

- name: Run example
run: |
echo "Running ${{ matrix.file }}"
stem=$(basename "${{ matrix.file }}" .py)
python3 -m internal.run_example $stem || exit $?
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@

venv
.venv

# secrets file for act, tool for local GitHub Actions testing
.secrets
Loading

0 comments on commit 1394470

Please sign in to comment.