From 2dbfc6a65171b0c4c31fdc8105ce35cf9caf11d1 Mon Sep 17 00:00:00 2001 From: Garry O'Donnell Date: Tue, 19 Mar 2024 16:32:40 +0000 Subject: [PATCH] Publish schema to apollo studio --- .github/dependabot.yml | 3 ++ .github/workflows/schema.yml | 85 ++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 .github/workflows/schema.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 8b54aee..10a7531 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,6 +5,9 @@ updates: schedule: interval: weekly groups: + github-artifacts: + patterns: + - actions/*-artifact minor: update-types: - minor diff --git a/.github/workflows/schema.yml b/.github/workflows/schema.yml new file mode 100644 index 0000000..9a4bc97 --- /dev/null +++ b/.github/workflows/schema.yml @@ -0,0 +1,85 @@ +name: Schema + +on: + push: + pull_request: + +jobs: + generate: + # Deduplicate jobs from pull requests and branch pushes within the same repo. + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository + 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://root:rootpassword@localhost:3306/ispyb_build + steps: + - name: Checkout source + uses: actions/checkout@v4.1.2 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1.0.7 + with: + toolchain: stable + default: true + + - name: Cache Rust Build + uses: Swatinem/rust-cache@v2.7.3 + + - name: Generate Schema + uses: actions-rs/cargo@v1.0.3 + with: + command: run + args: > + schema + -- + --path sessions.graphql + + - name: Upload Schema Artifact + uses: actions/upload-artifact@v4.3.1 + with: + name: sessions.graphql + path: sessions.graphql + + publish: + # Deduplicate jobs from pull requests and branch pushes within the same repo. + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository + needs: + - generate + runs-on: ubuntu-latest + steps: + - 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: Download Schema Artifact + uses: actions/download-artifact@v4.1.4 + with: + name: sessions.graphql + path: sessions.graphql + + - name: Check Subgraph Schema + run: > + rover subgraph check data-gateway@current + --schema sessions.graphql + --name sessions + 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@current + --routing-url http://sessions:80 + --schema sessions.graphql + --name sessions + env: + APOLLO_KEY: ${{ secrets.APOLLO_STUDIO }}