|
| 1 | +name: Lint, Test, and Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + types: [opened, synchronize, reopened] |
| 9 | + |
| 10 | +env: |
| 11 | + POETRY_VERSION: "1.7.1" |
| 12 | + |
| 13 | +jobs: |
| 14 | + fix: |
| 15 | + name: Check Ruff Fix |
| 16 | + runs-on: ubuntu-latest |
| 17 | + permissions: |
| 18 | + contents: write |
| 19 | + pull-requests: write |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + - uses: actions/setup-python@v5 |
| 23 | + - name: Ruff Fix Attempt |
| 24 | + id: ruff_fix |
| 25 | + uses: chartboost/ruff-action@v1 |
| 26 | + with: |
| 27 | + args: --fix-only --exit-non-zero-on-fix |
| 28 | + continue-on-error: true |
| 29 | + |
| 30 | + - name: Fail Workflow if Ruff Fix Failed |
| 31 | + if: steps.ruff_fix.outcome == 'failure' |
| 32 | + run: | |
| 33 | + echo "Ruff fix failed, failing the workflow." |
| 34 | + echo "Please run 'ruff check . --fix-only' locally and push the changes." |
| 35 | + exit 1 |
| 36 | +
|
| 37 | + test: |
| 38 | + name: Run Tests |
| 39 | + runs-on: ubuntu-latest |
| 40 | + strategy: |
| 41 | + matrix: |
| 42 | + python-version: ["3.9"] |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v4 |
| 45 | + - name: Load cached Poetry installation |
| 46 | + id: cached-poetry |
| 47 | + uses: actions/cache@v3 |
| 48 | + with: |
| 49 | + path: ~/.local |
| 50 | + key: poetry-${{ env.POETRY_VERSION }}-${{ hashFiles('**/poetry.lock') }} |
| 51 | + - name: Install Poetry |
| 52 | + if: steps.cached-poetry.outputs.cache-hit != 'true' |
| 53 | + uses: snok/install-poetry@v1 |
| 54 | + - name: Set up python ${{ matrix.python-version }} |
| 55 | + uses: actions/setup-python@v5 |
| 56 | + with: |
| 57 | + python-version: ${{ matrix.python-version }} |
| 58 | + cache: "poetry" |
| 59 | + - name: Install dependencies |
| 60 | + run: poetry install --no-interaction |
| 61 | + - name: Run lint with tests |
| 62 | + uses: chartboost/ruff-action@v1 |
| 63 | + with: |
| 64 | + args: --fix-only |
| 65 | + - name: Run tests with pytest |
| 66 | + run: poetry run pytest tests/ |
| 67 | + |
| 68 | + build_poetry: |
| 69 | + name: Build Poetry |
| 70 | + runs-on: ubuntu-latest |
| 71 | + strategy: |
| 72 | + matrix: |
| 73 | + python-version: ["3.9"] |
| 74 | + steps: |
| 75 | + - uses: actions/checkout@v4 |
| 76 | + - name: Load cached Poetry installation |
| 77 | + id: cached-poetry |
| 78 | + uses: actions/cache@v3 |
| 79 | + with: |
| 80 | + path: ~/.local |
| 81 | + key: poetry-${{ env.POETRY_VERSION }}-${{ hashFiles('**/poetry.lock') }} |
| 82 | + - name: Install Poetry |
| 83 | + if: steps.cached-poetry.outputs.cache-hit != 'true' |
| 84 | + uses: snok/install-poetry@v1 |
| 85 | + - name: Set up python ${{ matrix.python-version }} |
| 86 | + uses: actions/setup-python@v5 |
| 87 | + with: |
| 88 | + python-version: ${{ matrix.python-version }} |
| 89 | + cache: "poetry" |
| 90 | + - name: Build |
| 91 | + run: poetry build |
| 92 | + - name: Install built package |
| 93 | + run: python -m pip install dist/*.whl |
| 94 | + - name: Test import dspy |
| 95 | + run: python -c "import dspy" |
| 96 | + - name: Test import dsp |
| 97 | + run: python -c "import dsp" |
| 98 | + |
| 99 | + build_setup: |
| 100 | + name: Build Setup |
| 101 | + runs-on: ubuntu-latest |
| 102 | + strategy: |
| 103 | + matrix: |
| 104 | + python-version: ["3.9"] |
| 105 | + steps: |
| 106 | + - uses: actions/checkout@v4 |
| 107 | + - name: Load cached Poetry installation |
| 108 | + id: cached-poetry |
| 109 | + uses: actions/cache@v3 |
| 110 | + with: |
| 111 | + path: ~/.local |
| 112 | + key: poetry-${{ env.POETRY_VERSION }}-${{ hashFiles('**/poetry.lock') }} |
| 113 | + - name: Install Poetry |
| 114 | + if: steps.cached-poetry.outputs.cache-hit != 'true' |
| 115 | + uses: snok/install-poetry@v1 |
| 116 | + - name: Set up python ${{ matrix.python-version }} |
| 117 | + uses: actions/setup-python@v5 |
| 118 | + with: |
| 119 | + python-version: ${{ matrix.python-version }} |
| 120 | + cache: "poetry" |
| 121 | + - name: Run setup.py build |
| 122 | + run: python setup.py build |
0 commit comments