-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5791c10
commit 995876a
Showing
20 changed files
with
632 additions
and
1,225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
name: Build | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
jobs: | ||
validate: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- 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-pre-commit-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 | ||
|
||
test: | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
python-version: ["3.11", "3.12.0b2"] | ||
uses: ./.github/workflows/test.yaml | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
coverage: ${{ matrix.python-version == '3.11' }} | ||
integration: ${{ matrix.python-version == '3.11' }} | ||
|
||
test-platform-compat: | ||
if: github.event_name == 'push' | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
os: ["macos-latest", "windows-latest"] | ||
uses: ./.github/workflows/test.yaml | ||
with: | ||
python-version: "3.11" | ||
os: ${{ matrix.os }} | ||
|
||
sonarcloud: | ||
name: SonarCloud | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: SonarCloud Scan | ||
uses: SonarSource/sonarcloud-github-action@master | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
|
||
snyk: | ||
needs: | ||
- test | ||
- validate | ||
if: github.event.pull_request.head.repo.fork == false && github.repository_owner == 'litestar-org' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Run Snyk Monitor | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
uses: snyk/actions/python-3.8@master | ||
with: | ||
command: monitor | ||
env: | ||
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | ||
- name: Run Snyk Test | ||
if: ${{ github.ref != 'refs/heads/main' }} | ||
uses: snyk/actions/python-3.8@master | ||
with: | ||
command: test | ||
env: | ||
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | ||
|
||
codeql: | ||
needs: | ||
- test | ||
- validate | ||
runs-on: ubuntu-latest | ||
permissions: | ||
security-events: write | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Initialize CodeQL Without Dependencies | ||
uses: github/codeql-action/init@v2 | ||
with: | ||
setup-python-dependencies: false | ||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v2 | ||
|
||
build-docs: | ||
needs: | ||
- validate | ||
if: github.event_name == 'pull_request' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
- 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 | ||
with: | ||
path: .venv | ||
key: v1-venv-docs-${{ hashFiles('**/poetry.lock') }} | ||
- name: Install dependencies | ||
run: poetry install --no-interaction --with docs | ||
- name: Build docs | ||
run: poetry run make docs | ||
- name: Save PR number | ||
env: | ||
PR_NUMBER: ${{ github.event.number }} | ||
run: echo $PR_NUMBER > .pr_number | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: docs-preview | ||
path: | | ||
docs/_build/html | ||
.pr_number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
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@v3 | ||
|
||
- 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: jacobcoffee/niapi-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://jacobcoffee.github.io/niapi-docs-preview/" + issue_number | ||
const opts = github.rest.issues.li stComments.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, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Documentation Building | ||
on: | ||
release: | ||
types: [published] | ||
jobs: | ||
docs: | ||
permissions: | ||
contents: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
virtualenvs-create: false | ||
installer-parallel: true | ||
virtualenvs-in-project: true | ||
- name: Load cached venv | ||
id: cached-poetry-dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: .venv | ||
key: venv-${{ hashFiles('**/poetry.lock') }} | ||
- name: Install App Dependencies | ||
run: poetry install --no-interaction --with docs | ||
- name: Fetch gh pages | ||
run: git fetch origin gh-pages --depth=1 | ||
- name: Build docs | ||
run: poetry run python tools/build_docs.py docs-build | ||
- name: Deploy | ||
uses: JamesIves/github-pages-deploy-action@v4 | ||
with: | ||
folder: docs-build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Latest Release | ||
on: | ||
release: | ||
types: [published] | ||
jobs: | ||
publish-release: | ||
if: always() | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
- name: Set up python 3.11 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
- name: Install dependencies | ||
run: poetry install --no-interaction --no-root --no-dev | ||
- name: publish | ||
shell: bash | ||
run: | | ||
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} | ||
poetry publish --build --no-interaction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: Test | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
python-version: | ||
required: true | ||
type: string | ||
coverage: | ||
required: false | ||
type: boolean | ||
default: false | ||
os: | ||
required: false | ||
type: string | ||
default: "ubuntu-latest" | ||
integration: | ||
required: false | ||
type: boolean | ||
default: false | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ inputs.os }} | ||
timeout-minutes: ${{ inputs.integrations && 15 || 30 }} | ||
defaults: | ||
run: | ||
shell: bash | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
- name: Set up python ${{ inputs.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ inputs.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 | ||
if: runner.os != 'Windows' | ||
id: cached-poetry-dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: .venv | ||
key: v1-venv-${{ runner.os }}-${{ inputs.python-version }}-${{ hashFiles('**/poetry.lock') }} | ||
- name: Load cached pip wheels | ||
if: runner.os == 'Windows' | ||
id: cached-pip-wheels | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.cache | ||
key: cache-${{ runner.os }}-${{ inputs.python-version }}-${{ hashFiles('**/poetry.lock') }} | ||
- name: Install dependencies | ||
run: poetry install --no-interaction | ||
- name: Set pythonpath | ||
run: echo "PYTHONPATH=$PWD" >> $GITHUB_ENV | ||
- name: Test | ||
if: ${{ !inputs.coverage }} | ||
run: | | ||
source $VENV | ||
pytest | ||
- name: Test with coverage | ||
if: inputs.coverage | ||
run: poetry run pytest tests --cov=niapi --cov-report=xml | ||
- uses: actions/upload-artifact@v3 | ||
if: inputs.coverage | ||
with: | ||
name: coverage-xml | ||
path: coverage.xml |
Oops, something went wrong.