From 0a2796c454635a123537c3f0b472defef9a98263 Mon Sep 17 00:00:00 2001 From: Abid Sikder <41392423+abidsikder@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:12:02 -0500 Subject: [PATCH] github actions for testing and pages preview deployments --- .github/workflows/pages-main.yaml | 35 ++++++++++++++++++++++++ .github/workflows/pages-preview.yaml | 41 ++++++++++++++++++++++++++++ .github/workflows/run-checks.yaml | 31 +++++++++++++++++++++ .github/workflows/tox.yml | 25 ----------------- 4 files changed, 107 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/pages-main.yaml create mode 100644 .github/workflows/pages-preview.yaml create mode 100644 .github/workflows/run-checks.yaml delete mode 100644 .github/workflows/tox.yml diff --git a/.github/workflows/pages-main.yaml b/.github/workflows/pages-main.yaml new file mode 100644 index 0000000..73a93d4 --- /dev/null +++ b/.github/workflows/pages-main.yaml @@ -0,0 +1,35 @@ +name: Deploy static site generated by pdoc to GitHub Pages +on: + push: + branches: ["main"] +permissions: + contents: read + pages: write + id-token: write +jobs: + build: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + permissions: + contents: read + pages: write + id-token: write + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + - name: Setup Pages + uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5 + - name: Install uv + uses: astral-sh/setup-uv@v3 + - name: Create project environment + run: uv sync + - name: Build with pdoc + run: uv run pdoc ipldstore -o ./_site + - name: Upload artifact + # Automatically uploads an artifact from the './_site' directory by default + uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3 + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4 diff --git a/.github/workflows/pages-preview.yaml b/.github/workflows/pages-preview.yaml new file mode 100644 index 0000000..fddc819 --- /dev/null +++ b/.github/workflows/pages-preview.yaml @@ -0,0 +1,41 @@ +# Adapted from https://github.com/github/opensource.guide/blob/main/.github/workflows/jekyll-preview.yml + +name: Deploy static site generated by pdoc to GitHub Pages preview environment +on: pull_request +permissions: + contents: read + pages: write + id-token: write +jobs: + build: + environment: + name: "Pages Preview" + url: ${{ steps.deployment.outputs.page_url }} + permissions: + contents: read + pages: write + id-token: write + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + with: + # For PRs make sure to checkout the PR branch + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - name: Setup Pages + uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5 + - name: Install uv + uses: astral-sh/setup-uv@v3 + - name: Create project environment + run: uv sync + - name: Build with pdoc + run: uv run pdoc ipldstore -o ./_site + - name: Upload artifact + # Automatically uploads an artifact from the './_site' directory by default + uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3 + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4 + with: + preview: "true" diff --git a/.github/workflows/run-checks.yaml b/.github/workflows/run-checks.yaml new file mode 100644 index 0000000..e9ddb0c --- /dev/null +++ b/.github/workflows/run-checks.yaml @@ -0,0 +1,31 @@ +name: Run checks +run-name: Triggered on push from ${{ github.actor }} to branch/tag ${{ github.ref_name }} +on: push +# Should be the same as ipldstore/run-checks.sh + +jobs: + run_checks: + name: Create project environment, run all checks + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v3 + + - name: Create project environment + run: uv sync + + - name: Run pytest with coverage + run: uv run pytest --cov=py_hamt tests/ + + - name: Check coverage + run: uv run coverage report --fail-under=100 --show-missing + + - name: Check linting with ruff + run: uv run ruff check + + - name: Check formatting with ruff + run: uv run ruff format --check diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml deleted file mode 100644 index 8d21014..0000000 --- a/.github/workflows/tox.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Python package - -on: - - push - - pull_request - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ['3.8', '3.9', '3.10'] - - steps: - - uses: actions/checkout@v1 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install tox tox-gh-actions - - name: Test with tox - run: tox