Skip to content

Commit

Permalink
Update Uplink schema via GitHub Actions and remove Rust assert test (#…
Browse files Browse the repository at this point in the history
…3120)

This uses a combination of Rover and
https://github.com/peter-evans/create-pull-request to create a pull
request when a schema's introspection has changed.
  • Loading branch information
abernix authored May 25, 2023
1 parent c679c16 commit 3ed3e85
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 34 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/update_uplink_schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Update Uplink Schema
run-name: ${{ github.actor }} is updating the Uplink schema 🚀
on:
workflow_dispatch:
schedule:
# On the 5 of every hour
- cron: '5 * * * *'
jobs:
Update-Uplink-Schema:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Rover
run: |
curl -sSL https://rover.apollo.dev/nix/v0.14.1 | sh
echo "$HOME/.rover/bin" >> $GITHUB_PATH
- name: Make changes to pull request
run: |
rover graph introspect https://uplink.api.apollographql.com/ | perl -pe 'chomp if eof' > ./apollo-router/src/uplink/uplink.graphql
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v5
with:
commit-message: Update Uplink schema
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
branch: create-pull-request/uplink-schema-updates
add-paths: |
apollo-router/src/uplink/uplink.graphql
delete-branch: true
title: 'chore: Update Uplink schema'
body: |
This updates the copy of `uplink.graphql` which this repository relies on with the latest copy fetched via `rover graph introspect`.
34 changes: 0 additions & 34 deletions apollo-router/src/uplink/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,40 +418,6 @@ mod test {
}
}

#[test]
#[cfg(not(windows))] // Don’t bother with line ending differences
fn test_uplink_schema_is_up_to_date() {
use std::path::PathBuf;

use introspector_gadget::blocking::GraphQLClient;
use introspector_gadget::introspect;
use introspector_gadget::introspect::GraphIntrospectInput;

let client = GraphQLClient::new(
"https://uplink.api.apollographql.com/",
reqwest::blocking::Client::new(),
);

let should_retry = true;
let introspection_response = introspect::run(
GraphIntrospectInput {
headers: Default::default(),
},
&client,
should_retry,
)
.unwrap();
if introspection_response.schema_sdl != include_str!("uplink.graphql") {
let path = PathBuf::from(std::env::var_os("OUT_DIR").unwrap()).join("uplink.graphql");
std::fs::write(&path, introspection_response.schema_sdl).unwrap();
panic!(
"\n\nUplink schema is out of date. Run this command to update it:\n\n \
mv {} apollo-router/src/uplink/uplink.graphql\n\n",
path.to_str().unwrap()
);
}
}

#[test]
fn test_round_robin_endpoints() {
let url1 = Url::parse("http://example1.com").expect("url must be valid");
Expand Down

0 comments on commit 3ed3e85

Please sign in to comment.