Skip to content
Draft
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
79 changes: 79 additions & 0 deletions .github/workflows/codegen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Code Generation

on:
workflow_dispatch: {}
pull_request: {}

jobs:
codegen:
name: Regenerate Ariadne Codegen
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v6

- name: Git Config
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "mickey.mouse@playerdata.com"
git config --global push.autoSetupRemote true

- name: Generate Branch Name
id: branch-name
run: echo "branch-name=codegen-$(openssl rand -hex 4)" >> "$GITHUB_OUTPUT"

- run: git checkout -b ${{ steps.branch-name.outputs.branch-name }}

- uses: actions/setup-python@v6
with:
python-version: '3.12'

- name: Install uv
uses: astral-sh/setup-uv@v6.6.1
with:
enable-cache: true
cache-suffix: '-venv-codegen'
activate-environment: true

- name: Install Dependencies
run: uv sync --group codegen --locked

- name: Fetch the Schema
run: uv run --no-sync scripts/fetch_schema.py

- name: Code Generation
run: uv run --no-sync ariadne-codegen

- name: Fix Imports
run: uv run --no-sync scripts/fixup.py

- name: Generate GitHub App Token
id: app_token
uses: actions/create-github-app-token@v2
with:
app-id: 73365
private-key: ${{ secrets.BEAVERBOT_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}

- name: Create PR
env:
GH_TOKEN: ${{ steps.app_token.outputs.token }}
run: |
git add .
git commit -m "chore: update graphql schema"
git fetch origin
git rebase origin/main -X theirs
git push --force
gh pr create \
--title "Code Generation" \
--body "Automagically generated schema updates." \
--base main \
--head ${{ steps.branch-name.outputs.branch-name }}

# - name: Enable Automerge
# if: steps.create-pr.outputs.pull-request-number
# run: gh pr merge ${{ steps.create-pr.outputs.pull-request-number }} --auto --squash
# env:
# GH_TOKEN: ${{ github.token }}
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
activate-environment: true

- name: Install Dependencies
run: uv sync --extra dev --locked
run: uv sync --group test --locked

- name: Lint Check (Ruff)
run: uv run --no-sync ruff check .
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
activate-environment: true

- name: Install Dependencies
run: uv sync --extra dev --locked
run: uv sync --group test --locked

- name: Run Tests
run: uv run --no-sync pytest
19 changes: 10 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ dependencies = [
"requests-oauthlib>=2.0.0",
]

[project.optional-dependencies]
dev = [
"ariadne-codegen>=0.17.0",
"ruff>=0.14.14",
"pytest>=8.4.2",
"pytest-asyncio>=0.24.0",
"ipykernel>=7.1.0",
[dependency-groups]
codegen = [
"ariadne-codegen>=0.17.2",
]
test = [
"ipykernel>=7.2.0",
"pytest>=9.0.2",
"pytest-asyncio>=1.3.0",
"ruff>=0.15.1",
]

[build-system]
Expand All @@ -40,12 +42,11 @@ remove-unused-variables = true
ignore-init-module-imports = true

[tool.ariadne-codegen]
remote_schema_url = "https://app.playerdata.co.uk/api/graphql"
schema_path = "schema.graphql"
target_package_name = "playerdatapy"
enable_custom_operations = true
client_file_name = "gqlclient"
client_class_name = "GraphqlClient"
remote_schema_headers = {"Authorization" = "$AUTH_TOKEN"}

[tool.ruff.lint]
ignore = ["F405", "F403"]
Loading
Loading