From 3136baef909000e94c9b36101ebd6000284c9dcb Mon Sep 17 00:00:00 2001 From: Garry O'Donnell Date: Tue, 16 Apr 2024 08:37:39 +0000 Subject: [PATCH] Generate and verify subgraph schema in CI --- .github/workflows/_schema.yml | 58 +++++++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 7 +++++ 2 files changed, 65 insertions(+) create mode 100644 .github/workflows/_schema.yml diff --git a/.github/workflows/_schema.yml b/.github/workflows/_schema.yml new file mode 100644 index 0000000..d96aa58 --- /dev/null +++ b/.github/workflows/_schema.yml @@ -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 }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34a4f76..89d9249 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 == ''