Skip to content

Commit 37338f4

Browse files
authored
fix federation integration workflows (#1687)
Conditional steps do not work in workflows that are invoked from other workflows :(
1 parent 06f7c2d commit 37338f4

File tree

4 files changed

+198
-133
lines changed

4 files changed

+198
-133
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 97 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,103 @@ jobs:
2020
needs: build-libraries
2121
uses: ./.github/workflows/build-examples.yml
2222

23-
federation-integration:
24-
uses: ./.github/workflows/federation-integration.yml
25-
secrets:
26-
token: ${{ secrets.GITHUB_TOKEN }}
23+
federation-composition:
24+
timeout-minutes: 30
25+
runs-on: ubuntu-latest
26+
defaults:
27+
run:
28+
working-directory: examples/federation
29+
30+
steps:
31+
- name: Checkout Repository
32+
if: ${{ inputs.fork }} == false
33+
uses: actions/checkout@v3
34+
35+
- name: Set up Java 17
36+
uses: actions/setup-java@v3
37+
with:
38+
java-version: 17
39+
distribution: 'zulu'
40+
41+
- name: Set up Gradle cache
42+
uses: gradle/gradle-build-action@v2
43+
44+
- name: Build Subgraphs
45+
working-directory: examples
46+
run: ./gradlew :federation-products-subgraph:build :federation-reviews-subgraph:build
47+
48+
- name: Setup rover CLI
49+
run: |
50+
curl -sSL https://rover.apollo.dev/nix/latest | sh -s -- --elv2-license accept
51+
echo "$HOME/.rover/bin" >> ${GITHUB_PATH}
52+
53+
- name: Compose Supergraph
54+
run: APOLLO_ELV2_LICENSE=accept rover supergraph compose --config supergraph.yaml > supergraph.graphql
55+
56+
- name: Start router
57+
run: docker compose up --build --detach --wait
58+
59+
- name: Federation Tests
60+
run: |
61+
set -x
62+
echo "verify router is up"
63+
curl --verbose http://localhost:8088/health
64+
65+
echo "sending a test query"
66+
curl --request POST \
67+
--verbose \
68+
--header 'content-type: application/json' \
69+
--url http://localhost:3000/ \
70+
--data '{"query":"query($productId: ID!) {\n product(id: $productId) {\n id\n reviews {\n id\n text\n starRating\n }\n name\n description\n }\n}","variables":{"productId":"5"}}' \
71+
> response.json
72+
73+
echo "received GraphQL response"
74+
cat response.json
75+
76+
echo "verifying response"
77+
jq -e '.data.product?.id == "5" and .data.product?.name == "Dragon" and (.data.product?.reviews | length == 2) and (.data.product?.reviews[0]?.text | length > 0)' response.json
78+
- name: Error Logs
79+
if: ${{ failure() }}
80+
run: docker-compose logs
81+
- name: Stop Supergraph
82+
if: ${{ always() }}
83+
run: docker compose down --remove-orphans
84+
85+
federation-compatibility:
86+
timeout-minutes: 30
87+
runs-on: ubuntu-latest
88+
defaults:
89+
run:
90+
working-directory: integration/federation-compatibility
91+
92+
steps:
93+
- name: Checkout Repository
94+
if: ${{ inputs.fork }} == false
95+
uses: actions/checkout@v3
96+
97+
- name: Validate Gradle wrapper
98+
uses: gradle/wrapper-validation-action@v1
99+
100+
- name: Set up Java 17
101+
uses: actions/setup-java@v3
102+
with:
103+
java-version: 17
104+
distribution: 'zulu'
105+
106+
- name: Set up Gradle cache
107+
uses: gradle/gradle-build-action@v2
108+
109+
- name: Build compatibility app with Gradle
110+
run: ./gradlew bootJar graphqlGenerateSDL
111+
112+
- name: Compatibility Test
113+
uses: apollographql/federation-subgraph-compatibility@v1
114+
with:
115+
compose: 'docker-compose.yaml'
116+
schema: 'build/schema.graphql'
117+
failOnWarning: true
118+
failOnRequired: true
119+
workingDirectory: 'integration/federation-compatibility'
27120

28121
release-notes:
29122
timeout-minutes: 10

.github/workflows/federation-integration.yml

Lines changed: 0 additions & 121 deletions
This file was deleted.

.github/workflows/pr-check-federation.yml

Lines changed: 100 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,103 @@ on:
99
- 'integration/federation-compatibility/**'
1010

1111
jobs:
12-
federation-integration:
13-
uses: ./.github/workflows/federation-integration.yml
14-
with:
15-
fork: true
16-
secrets:
17-
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
12+
federation-composition:
13+
timeout-minutes: 30
14+
runs-on: ubuntu-latest
15+
defaults:
16+
run:
17+
working-directory: examples/federation
18+
19+
steps:
20+
- name: Checkout Repository
21+
uses: actions/checkout@v3
22+
with:
23+
ref: ${{ github.event.pull_request.head.sha }}
24+
25+
- name: Set up Java 17
26+
uses: actions/setup-java@v3
27+
with:
28+
java-version: 17
29+
distribution: 'zulu'
30+
31+
- name: Set up Gradle cache
32+
uses: gradle/gradle-build-action@v2
33+
34+
- name: Build Subgraphs
35+
working-directory: examples
36+
run: ./gradlew :federation-products-subgraph:build :federation-reviews-subgraph:build
37+
38+
- name: Setup rover CLI
39+
run: |
40+
curl -sSL https://rover.apollo.dev/nix/latest | sh -s -- --elv2-license accept
41+
echo "$HOME/.rover/bin" >> ${GITHUB_PATH}
42+
43+
- name: Compose Supergraph
44+
run: APOLLO_ELV2_LICENSE=accept rover supergraph compose --config supergraph.yaml > supergraph.graphql
45+
46+
- name: Start router
47+
run: docker compose up --build --detach --wait
48+
49+
- name: Federation Tests
50+
run: |
51+
set -x
52+
echo "verify router is up"
53+
curl --verbose http://localhost:8088/health
54+
55+
echo "sending a test query"
56+
curl --request POST \
57+
--verbose \
58+
--header 'content-type: application/json' \
59+
--url http://localhost:3000/ \
60+
--data '{"query":"query($productId: ID!) {\n product(id: $productId) {\n id\n reviews {\n id\n text\n starRating\n }\n name\n description\n }\n}","variables":{"productId":"5"}}' \
61+
> response.json
62+
63+
echo "received GraphQL response"
64+
cat response.json
65+
66+
echo "verifying response"
67+
jq -e '.data.product?.id == "5" and .data.product?.name == "Dragon" and (.data.product?.reviews | length == 2) and (.data.product?.reviews[0]?.text | length > 0)' response.json
68+
- name: Error Logs
69+
if: ${{ failure() }}
70+
run: docker-compose logs
71+
- name: Stop Supergraph
72+
if: ${{ always() }}
73+
run: docker compose down --remove-orphans
74+
75+
federation-compatibility:
76+
timeout-minutes: 30
77+
runs-on: ubuntu-latest
78+
defaults:
79+
run:
80+
working-directory: integration/federation-compatibility
81+
82+
steps:
83+
- name: Checkout Repository
84+
uses: actions/checkout@v3
85+
with:
86+
ref: ${{ github.event.pull_request.head.sha }}
87+
88+
- name: Validate Gradle wrapper
89+
uses: gradle/wrapper-validation-action@v1
90+
91+
- name: Set up Java 17
92+
uses: actions/setup-java@v3
93+
with:
94+
java-version: 17
95+
distribution: 'zulu'
96+
97+
- name: Set up Gradle cache
98+
uses: gradle/gradle-build-action@v2
99+
100+
- name: Build compatibility app with Gradle
101+
run: ./gradlew bootJar graphqlGenerateSDL
102+
103+
- name: Compatibility Test
104+
uses: apollographql/federation-subgraph-compatibility@v1
105+
with:
106+
compose: 'docker-compose.yaml'
107+
schema: 'build/schema.graphql'
108+
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
109+
failOnWarning: true
110+
failOnRequired: true
111+
workingDirectory: 'integration/federation-compatibility'
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
services:
22
products:
3-
# must be relative to the root of the project
4-
build: integration/federation-compatibility
3+
build: .
54
ports:
65
- 4001:4001

0 commit comments

Comments
 (0)