|
| 1 | +name: Publish Documentation |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - docs-update |
| 8 | + tags: |
| 9 | + - '**' |
| 10 | + |
| 11 | +env: |
| 12 | + COLUMNS: 150 |
| 13 | + PDM_DEPS: 'urllib3<2' |
| 14 | + |
| 15 | +jobs: |
| 16 | + lint: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - uses: actions/setup-python@v5 |
| 23 | + with: |
| 24 | + python-version: '3.11' |
| 25 | + |
| 26 | + - uses: actions/setup-node@v4 |
| 27 | + with: |
| 28 | + node-version: 18 |
| 29 | + |
| 30 | + - run: pip install -r src/python-fastui/requirements/all.txt |
| 31 | + - run: pip install src/python-fastui |
| 32 | + |
| 33 | + - run: npm install |
| 34 | + |
| 35 | + - uses: pre-commit/[email protected] |
| 36 | + with: |
| 37 | + extra_args: --all-files |
| 38 | + env: |
| 39 | + SKIP: no-commit-to-branch |
| 40 | + |
| 41 | + test: |
| 42 | + name: test ${{ matrix.python-version }} on ${{ matrix.os }} |
| 43 | + strategy: |
| 44 | + fail-fast: false |
| 45 | + matrix: |
| 46 | + os: [ubuntu-latest, macos-13, macos-latest] |
| 47 | + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] |
| 48 | + exclude: |
| 49 | + # Python 3.8 and 3.9 are not available on macOS 14 |
| 50 | + - os: macos-13 |
| 51 | + python-version: '3.10' |
| 52 | + - os: macos-13 |
| 53 | + python-version: '3.11' |
| 54 | + - os: macos-13 |
| 55 | + python-version: '3.12' |
| 56 | + - os: macos-latest |
| 57 | + python-version: '3.8' |
| 58 | + - os: macos-latest |
| 59 | + python-version: '3.9' |
| 60 | + |
| 61 | + runs-on: ${{ matrix.os }} |
| 62 | + |
| 63 | + env: |
| 64 | + PYTHON: ${{ matrix.python-version }} |
| 65 | + OS: ${{ matrix.os }} |
| 66 | + |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v4 |
| 69 | + |
| 70 | + - name: set up python |
| 71 | + uses: actions/setup-python@v5 |
| 72 | + with: |
| 73 | + python-version: ${{ matrix.python-version }} |
| 74 | + |
| 75 | + - run: pip install -r src/python-fastui/requirements/test.txt |
| 76 | + - run: pip install -r src/python-fastui/requirements/pyproject.txt |
| 77 | + - run: pip install -e src/python-fastui |
| 78 | + |
| 79 | + - run: coverage run -m pytest src |
| 80 | + # display coverage and fail if it's below 80%, which shouldn't happen |
| 81 | + - run: coverage report --fail-under=80 |
| 82 | + |
| 83 | + # test demo on 3.11 and 3.12, these tests are intentionally omitted from coverage |
| 84 | + - if: matrix.python-version == '3.11' || matrix.python-version == '3.12' |
| 85 | + run: pytest demo/tests.py |
| 86 | + |
| 87 | + - run: coverage xml |
| 88 | + |
| 89 | + - uses: codecov/codecov-action@v4 |
| 90 | + with: |
| 91 | + file: ./coverage.xml |
| 92 | + env_vars: PYTHON,OS |
| 93 | + |
| 94 | + publish: |
| 95 | + # Compare with the docs-build job in .github/workflows/ci.yml |
| 96 | + needs: [lint, test] |
| 97 | + runs-on: ubuntu-latest |
| 98 | + timeout-minutes: 30 |
| 99 | + |
| 100 | + steps: |
| 101 | + - name: checkout docs-site |
| 102 | + uses: actions/checkout@v4 |
| 103 | + with: |
| 104 | + ref: docs-site |
| 105 | + |
| 106 | + - name: checkout current branch |
| 107 | + uses: actions/checkout@v4 |
| 108 | + |
| 109 | + - uses: actions/setup-python@v4 |
| 110 | + with: |
| 111 | + python-version: '3.11' |
| 112 | + |
| 113 | + - name: install |
| 114 | + run: | |
| 115 | + pip install --upgrade pip |
| 116 | + pip install -r requirements/docs.txt |
| 117 | + pip install --extra-index-url https://pydantic:${PPPR_TOKEN}@pppr.pydantic.dev/simple/ mkdocs-material mkdocstrings-python griffe-typedoc mkdocstrings-typescript |
| 118 | + npm install |
| 119 | + npm install -g typedoc |
| 120 | + env: |
| 121 | + PPPR_TOKEN: ${{ secrets.PPPR_TOKEN }} |
| 122 | + |
| 123 | + - run: python -c 'import docs.plugins.main' |
| 124 | + |
| 125 | + - name: Set git credentials |
| 126 | + run: | |
| 127 | + git config --global user.name "${{ github.actor }}" |
| 128 | + git config --global user.email "${{ github.actor }}@users.noreply.github.com" |
| 129 | +
|
| 130 | + - run: mike deploy -b docs-site dev --push |
| 131 | + if: "github.ref == 'refs/heads/main'" |
| 132 | + |
| 133 | + - if: "github.ref == 'refs/heads/docs-update' || startsWith(github.ref, 'refs/tags/')" |
| 134 | + id: check-version |
| 135 | + uses: samuelcolvin/[email protected] |
| 136 | + with: |
| 137 | + version_file_path: 'pydantic/version.py' |
| 138 | + skip_env_check: true |
| 139 | + |
| 140 | + - run: mike deploy -b docs-site ${{ steps.check-version.outputs.VERSION_MAJOR_MINOR }} latest --update-aliases --push |
| 141 | + if: "(github.ref == 'refs/heads/docs-update' || startsWith(github.ref, 'refs/tags/')) && !fromJSON(steps.check-version.outputs.IS_PRERELEASE)" |
| 142 | + env: |
| 143 | + PYDANTIC_VERSION: v${{ steps.check-version.outputs.VERSION }} |
0 commit comments