Skip to content

Commit

Permalink
Generate and verify subgraph schema in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
garryod committed Apr 16, 2024
1 parent 77635fc commit 3136bae
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/_schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
on:
workflow_call:
secrets:
APOLLO_STUDIO:
required: true

jobs:
generate:
runs-on: ubuntu-latest
services:
ispyb:
image: ghcr.io/diamondlightsource/ispyb-database:v3.0.0
ports:
- 3306:3306
env:
MARIADB_ROOT_PASSWORD: rootpassword
options: >
--health-cmd "/usr/local/bin/healthcheck.sh --defaults-file=/ispyb/.my.cnf --connect"
env:
DATABASE_URL: mysql+pymysql://root:rootpassword@localhost/ispyb_build
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install python packages
uses: ./.github/actions/install_requirements

- name: Generate schema
run: graph-energy-scan schema -p energy-scan.graphql

- name: Upload schema artifact
uses: actions/upload-artifact@v4
with:
name: energy-scan.graphql
path: energy-scan.graphql

- name: Install Rover CLI
run: |
curl -sSL https://rover.apollo.dev/nix/v0.23.0-rc.3 | sh
echo "$HOME/.rover/bin" >> $GITHUB_PATH
- name: Check subgraph schema
run: >
rover subgraph check data-gateway-n63jcf@current
--schema energy-scan.graphql
--name energy-scan
env:
APOLLO_KEY: ${{ secrets.APOLLO_STUDIO }}

- name: Publish subgraph schema to Apollo Studio
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
run: >
rover subgraph publish data-gateway-n63jcf@current
--routing-url http://sessions:80
--schema energy-scan.graphql
--name energy-scan
env:
APOLLO_KEY: ${{ secrets.APOLLO_STUDIO }}
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ jobs:
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

schema:
needs: check
if: needs.check.outputs.branch-pr == ''
uses: ./.github/workflows/_schema.yml
secrets:
APOLLO_STUDIO: ${{ secrets.APOLLO_STUDIO }}

container:
needs: check
if: needs.check.outputs.branch-pr == ''
Expand Down

0 comments on commit 3136bae

Please sign in to comment.