]> git.ipfire.org Git - thirdparty/fastapi/sqlmodel.git/commitdiff
👷 Add GitHub Actions to Build Docs, Test, and Publish
authorSebastián Ramírez <tiangolo@gmail.com>
Tue, 24 Aug 2021 14:21:34 +0000 (16:21 +0200)
committerSebastián Ramírez <tiangolo@gmail.com>
Tue, 24 Aug 2021 14:21:34 +0000 (16:21 +0200)
.github/workflows/build-docs.yml [new file with mode: 0644]
.github/workflows/publish.yml [new file with mode: 0644]
.github/workflows/test.yml [new file with mode: 0644]

diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml
new file mode 100644 (file)
index 0000000..3559874
--- /dev/null
@@ -0,0 +1,58 @@
+name: Build Docs
+on:
+  push:
+  pull_request:
+    types: [opened, synchronize]
+jobs:
+  build-docs:
+    runs-on: ubuntu-20.04
+    steps:
+      - name: Dump GitHub context
+        env:
+          GITHUB_CONTEXT: ${{ toJson(github) }}
+        run: echo "$GITHUB_CONTEXT"
+      - uses: actions/checkout@v2
+      - name: Set up Python
+        uses: actions/setup-python@v2
+        with:
+          python-version: "3.7"
+      - uses: actions/cache@v2
+        id: cache
+        with:
+          path: ${{ env.pythonLocation }}
+          key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-docs
+      - name: Install poetry
+        if: steps.cache.outputs.cache-hit != 'true'
+        run: |
+          python -m pip install --upgrade pip
+          python -m pip install "poetry>=1.2.0a1"
+          python -m poetry plugin add poetry-version-plugin 
+      - name: Configure poetry
+        run: python -m poetry config virtualenvs.in-project true
+      - name: Ensure cache is healthy
+        if: steps.cache.outputs.cache-hit == 'true'
+        run: python -m poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
+      - name: Install Dependencies
+        if: steps.cache.outputs.cache-hit != 'true'
+        run: python -m poetry install
+      - name: Install Material for MkDocs Insiders
+        if: github.event.pull_request.head.repo.fork == false && steps.cache.outputs.cache-hit != 'true'
+        run: pip install git+https://${{ secrets.ACTIONS_TOKEN }}@github.com/squidfunk/mkdocs-material-insiders.git
+      - name: Build Docs
+        run: python3.7 -m mkdocs build
+      - name: Zip docs
+        run: bash ./scripts/zip-docs.sh
+      - uses: actions/upload-artifact@v2
+        with:
+          name: docs-zip
+          path: ./docs.zip
+      - name: Deploy to Netlify
+        uses: nwtgck/actions-netlify@v1.1.5
+        with:
+          publish-dir: './site'
+          production-branch: main
+          github-token: ${{ secrets.GITHUB_TOKEN }}
+          enable-commit-comment: false
+        env:
+          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
+          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
new file mode 100644 (file)
index 0000000..c75ecc0
--- /dev/null
@@ -0,0 +1,41 @@
+name: Publish
+
+on:
+  release:
+    types:
+      - created
+
+jobs:
+  publish:
+    runs-on: ubuntu-20.04
+    steps:
+      - uses: actions/checkout@v2
+      - name: Set up Python
+        uses: actions/setup-python@v2
+        with:
+          python-version: "3.7"
+      - uses: actions/cache@v2
+        id: cache
+        with:
+          path: ${{ env.pythonLocation }}
+          key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-test
+      - name: Install poetry
+        if: steps.cache.outputs.cache-hit != 'true'
+        run: |
+          python -m pip install --upgrade pip
+          python -m pip install "poetry>=1.2.0a1"
+          python -m poetry plugin add poetry-version-plugin 
+      - name: Configure poetry
+        run: python -m poetry config virtualenvs.in-project true
+      - name: Ensure cache is healthy
+        if: steps.cache.outputs.cache-hit == 'true'
+        run: python -m poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
+      - name: Install Dependencies
+        if: steps.cache.outputs.cache-hit != 'true'
+        run: python -m poetry install
+      - name: Publish
+        env:
+          PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
+        run: |
+          python -m poetry config pypi-token.pypi $PYPI_TOKEN
+          bash scripts/publish.sh
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644 (file)
index 0000000..aa60d7f
--- /dev/null
@@ -0,0 +1,44 @@
+name: Test
+
+on:
+  push:
+  pull_request:
+    types: [opened, synchronize]
+
+jobs:
+  test:
+    runs-on: ubuntu-20.04
+    strategy:
+      matrix:
+        python-version: [3.6, 3.7, 3.8, 3.9]
+      fail-fast: false
+
+    steps:
+      - uses: actions/checkout@v2
+      - name: Set up Python
+        uses: actions/setup-python@v2
+        with:
+          python-version: ${{ matrix.python-version }}
+      - uses: actions/cache@v2
+        id: cache
+        with:
+          path: ${{ env.pythonLocation }}
+          key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-test
+      - name: Install poetry
+        if: steps.cache.outputs.cache-hit != 'true'
+        run: |
+          python -m pip install --upgrade pip
+          python -m pip install "poetry>=1.2.0a1"
+          python -m poetry plugin add poetry-version-plugin 
+      - name: Configure poetry
+        run: python -m poetry config virtualenvs.in-project true
+      - name: Ensure cache is healthy
+        if: steps.cache.outputs.cache-hit == 'true'
+        run: python -m poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
+      - name: Install Dependencies
+        if: steps.cache.outputs.cache-hit != 'true'
+        run: python -m poetry install
+      - name: Test
+        run: bash scripts/test.sh
+      - name: Upload coverage
+        uses: codecov/codecov-action@v1