-
Notifications
You must be signed in to change notification settings - Fork 21
126 lines (113 loc) · 4.01 KB
/
continuous-integration.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: Continuous Integration
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build-products:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Set up Java 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu'
- name: Set up Gradle cache
uses: gradle/gradle-build-action@v2
- name: Build products subgraph with Gradle
run: ./gradlew :products-subgraph:clean :products-subgraph:build :products-subgraph:bootJar
- name: Upload JAR
uses: actions/upload-artifact@v3
with:
name: products.jar
path: ./products-subgraph/build/libs/products.jar
retention-days: 1
build-reviews:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Set up Java 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu'
- name: Set up Gradle cache
uses: gradle/gradle-build-action@v2
- name: Build reviews subgraph with Gradle
run: ./gradlew :reviews-subgraph:clean :reviews-subgraph:build :reviews-subgraph:bootJar
- name: Upload JAR
uses: actions/upload-artifact@v3
with:
name: reviews.jar
path: ./reviews-subgraph/build/libs/reviews.jar
retention-days: 1
build-supergraph:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup rover CLI
run: |
curl -sSL https://rover.apollo.dev/nix/latest | sh -s -- --elv2-license accept
echo "$HOME/.rover/bin" >> ${GITHUB_PATH}
- name: Compose Supergraph
run: APOLLO_ELV2_LICENSE=accept rover supergraph compose --config supergraph.yaml > supergraph.graphql
- name: Upload Supergraph config
uses: actions/upload-artifact@v3
with:
name: supergraph.graphql
path: supergraph.graphql
retention-days: 1
federation-test:
timeout-minutes: 10
runs-on: ubuntu-latest
needs: [build-products, build-reviews, build-supergraph]
steps:
- uses: actions/checkout@v3
# we are using separate download actions as otherwise artifacts are placed in folders
- name: Download products JAR
uses: actions/download-artifact@v3
with:
name: products.jar
- name: Download reviews JAR
uses: actions/download-artifact@v3
with:
name: reviews.jar
- name: Download Supergraph config
uses: actions/download-artifact@v3
with:
name: supergraph.graphql
- name: Start up Supergraph
run: docker compose up --build --detach --wait
- name: Federation Tests
run: |
set -x
echo "verify router is up"
curl --verbose http://localhost:8088/health
echo "sending a test query"
curl --request POST \
--verbose \
--header 'content-type: application/json' \
--url http://localhost:3000/ \
--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"}}' \
> response.json
echo "received GraphQL response"
cat response.json
echo "verifying response"
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
- name: Error Logs
if: ${{ failure() }}
run: docker-compose logs
- name: Stop Supergraph
if: ${{ always() }}
run: docker compose down --remove-orphans