Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infra: pdm, docs #22

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Code owner settings for `litestar`
# @maintainers should be assigned to all reviews.
# Most specific assignment takes precedence though, so if you add a more specific thing than the `*` glob, you must also add @maintainers
# For more info about code owners see https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-file-example

# Global Assignment
* @litestar-org/maintainers @litestar-org/members

# Documentation
docs/* @litestar-org/maintainers @JacobCoffee @provinzkraut
File renamed without changes.
46 changes: 26 additions & 20 deletions .github/workflows/ci.yaml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4

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

- name: Install Pre-Commit
run: python -m pip install pre-commit && pre-commit install
- name: Load cached Pre-Commit Dependencies
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pre-commit/
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}

- name: Execute Pre-Commit
run: pre-commit run --show-diff-on-failure --color=always --all-files

pyton_tests:
name: "Python Tests"
runs-on: ubuntu-latest
Expand All @@ -37,56 +35,61 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load Cached Venv
id: cached-poetry-dependencies
uses: actions/cache@v3

- uses: pdm-project/setup-pdm@v3
name: Set up PDM
with:
path: .venv
key: v1-venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
python-version: ${{ matrix.python-version }}

- name: Install Python Dependencies
run: poetry install --no-interaction --no-root
run: pdm install

- name: Set pythonpath
run: echo "PYTHONPATH=$PWD" >> $GITHUB_ENV

- name: Install library
run: poetry run maturin develop
run: pdm run maturin develop

- name: Test
run: poetry run pytest
run: pdm run pytest

rust_tests:
name: "Rust Tests"
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
target: x86_64-unknown-linux-musl
components: llvm-tools-preview

- name: Download grcov
run: |
mkdir -p "${HOME}/.local/bin"
curl -sL https://github.com/mozilla/grcov/releases/download/v0.8.10/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - -C "${HOME}/.local/bin"
echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Test with Coverage
run: CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw' cargo test

- name: Generate Coverage Report
run: mkdir coverage && grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o coverage.lcov

- uses: actions/upload-artifact@v3
with:
name: coverage-lcov
path: coverage.lcov

sonar:
name: "Sonar"
needs:
Expand All @@ -98,12 +101,15 @@ jobs:
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: coverage-lcov

- name: Fix coverage file for sonarcloud
run: sed -i "s/home\/runner\/work\/http_utils\/src/github\/workspace/g" coverage.lcov

- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
env:
Expand Down
72 changes: 72 additions & 0 deletions .github/workflows/docs-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Deploy Documentation Preview

on:
workflow_run:
workflows: [Tests And Linting]
types: [completed]

jobs:
deploy:
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' }}
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Download artifact
uses: dawidd6/action-download-artifact@v2
with:
workflow_conclusion: success
run_id: ${{ github.event.workflow_run.id }}
path: docs-preview
name: docs-preview

- name: Set PR number
run: echo "PR_NUMBER=$(cat docs-preview/.pr_number)" >> $GITHUB_ENV

- name: Deploy docs preview
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: docs-preview/docs/_build/html
token: ${{ secrets.DOCS_PREVIEW_DEPLOY_TOKEN }}
repository-name: litestar-org/fast-query-parsers-docs-preview
clean: false
target-folder: ${{ env.PR_NUMBER }}
branch: gh-pages

- uses: actions/github-script@v6
env:
PR_NUMBER: ${{ env.PR_NUMBER }}
with:
script: |
const issue_number = process.env.PR_NUMBER
const body = "Documentation preview will be available shortly at https://litestar-org.github.io/fast-query-parsers-docs-preview/" + issue_number

const opts = github.rest.issues.listComments.endpoint.merge({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
});

const comments = await github.paginate(opts)

for (const comment of comments) {
if (comment.user.id === 41898282 && comment.body === body) {
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment.id
})
}
}

await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
body: body,
})
46 changes: 46 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Documentation Building

on:
release:
types: [published]
push:
branches:
- main

jobs:
docs:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

- uses: pdm-project/setup-pdm@v3
name: Set up PDM
with:
python-version: "3.11"
allow-python-prereleases: true
cache: true

- name: Install dependencies
run: pdm install -G:docs

- name: Fetch gh pages
run: git fetch origin gh-pages --depth=1

- name: Build release docs
run: pdm run python tools/build_docs.py docs-build
if: github.event_name == 'release'

- name: Build dev docs
run: pdm run python tools/build_docs.py docs-build
if: github.event_name == 'push'

- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: docs-build
Loading
Loading