-
Notifications
You must be signed in to change notification settings - Fork 156
87 lines (84 loc) · 3.2 KB
/
update-api-schema.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: graphql
on:
pull_request:
paths:
- 'src/ai/backend/manager/models/**'
jobs:
graphql-updated:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Calculate the fetch depth
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
echo "GIT_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
else
echo "GIT_FETCH_DEPTH=2" >> "${GITHUB_ENV}"
fi
- name: Checkout the revision with minimal required history
uses: actions/checkout@v4
with:
fetch-depth: ${{ env.GIT_FETCH_DEPTH }}
ref: ${{ github.head_ref }}
token: ${{ secrets.OCTODOG }}
lfs: false
- name: Extract Python version from pants.toml
run: |
PYTHON_VERSION=$(grep -m 1 -oP '(?<=CPython==)([^"]+)' pants.toml)
echo "PANTS_CONFIG_FILES=pants.ci.toml" >> $GITHUB_ENV
echo "PROJECT_PYTHON_VERSION=$PYTHON_VERSION" >> $GITHUB_ENV
- name: Set up Python as Runtime
uses: actions/setup-python@v5
with:
python-version: ${{ env.PROJECT_PYTHON_VERSION }}
- name: Set up remote cache backend (if applicable)
run: |
echo "PANTS_REMOTE_STORE_ADDRESS=${REMOTE_CACHE_BACKEND_ENDPOINT}" >> $GITHUB_ENV
echo "PANTS_REMOTE_CACHE_READ=true" >> $GITHUB_ENV
echo "PANTS_REMOTE_CACHE_WRITE=true" >> $GITHUB_ENV
echo "PANTS_REMOTE_INSTANCE_NAME=main" >> $GITHUB_ENV
env:
REMOTE_CACHE_BACKEND_ENDPOINT: ${{ secrets.PANTS_REMOTE_CACHE_ENDPOINT_ARC }}
if: ${{ env.REMOTE_CACHE_BACKEND_ENDPOINT != '' }}
- name: Bootstrap Pants
uses: ./actions/init-pants
# See: github.com/pantsbuild/actions/tree/main/init-pants/
# ref) https://github.com/pantsbuild/example-python/blob/main/.github/workflows/pants.yaml#L30-L49
with:
named-caches-hash: ${{ hashFiles('python*.lock', 'tools/*.lock') }}
cache-lmdb-store: 'true'
- name: Pants export
run: pants export --resolve=python-default
- name: Create GraphQL schema dump
run: |
./backend.ai mgr api dump-gql-schema --output src/ai/backend/manager/api/schema.graphql
- name: Make commit message for changing change log file
run: |
git add src/ai/backend/manager/api/schema.graphql
author_name=$(git show -q --pretty='format:%an')
author_email=$(git show -q --pretty='format:%ae')
git config user.email "$author_email"
git config user.name "$author_name"
if [ -n "$(git diff --staged)" ]; then
git commit \
-m "chore: update GraphQL schema dump" \
--author="$author_name <$author_email>" \
--trailer "Co-authored-by: octodog <[email protected]>"
git push
fi
graphql-inspector:
needs: graphql-updated
name: Check Schema
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
checks: write
steps:
- uses: actions/checkout@v4
- uses: kamilkisiela/graphql-inspector@release-1717403590269
with:
schema: '${{ github.base_ref }}:src/ai/backend/manager/api/schema.graphql'
rules: |
gql-inspector-checker.js