-
Notifications
You must be signed in to change notification settings - Fork 98
88 lines (81 loc) · 2.8 KB
/
pr-rust.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
name: pr
on:
pull_request:
paths:
- 'packages/libraries/router/**'
- 'docker/router.dockerfile'
- 'scripts/compress/**'
- 'configs/cargo/Cargo.lock'
- 'Cargo.lock'
- 'Cargo.toml'
env:
HIVE_TOKEN: ${{ secrets.HIVE_TOKEN }}
jobs:
# Builds Rust crates, and creates Docker images
build-rust:
name: build_rust
uses: ./.github/workflows/build-and-dockerize.yaml
with:
dockerize: ${{ !github.event.pull_request.head.repo.fork }}
imageTag: ${{ github.event.pull_request.head.sha }}
publishLatest: false
targets: 'rust'
build: false
publishPrComment: false
uploadJavaScriptArtifacts: false
secrets: inherit
# Run Docker image
run-docker:
name: run-docker
runs-on: ubuntu-22.04
needs: build-rust
if: ${{ !github.event.pull_request.head.repo.fork }}
steps:
- name: Run Docker image
run: |
# Create router.yaml
cat << EOF > router.yaml
supergraph:
listen: 0.0.0.0:4000
health_check:
listen: 0.0.0.0:8088
enabled: true
path: /health
plugins:
hive.usage:
enabled: false
EOF
# Download supergraph
curl -sSL https://supergraph.demo.starstuff.dev/ > ./supergraph.graphql
# Run Docker image
docker run -p 4000:4000 -p 8088:8088 --name apollo_router_test -d \
--env HIVE_TOKEN="fake" \
--mount "type=bind,source=/$(pwd)/router.yaml,target=/dist/config/router.yaml" \
--mount "type=bind,source=/$(pwd)/supergraph.graphql,target=/dist/config/supergraph.graphql" \
ghcr.io/kamilkisiela/graphql-hive/apollo-router:${{ github.event.pull_request.head.sha }} \
--log debug \
--supergraph /dist/config/supergraph.graphql \
--config /dist/config/router.yaml
# Wait for the container to be ready
echo "Waiting for the container to be ready..."
sleep 20
HTTP_RESPONSE=$(curl --retry 5 --retry-delay 5 --max-time 30 --write-out "%{http_code}" --silent --output /dev/null "http://127.0.0.1:8088/health")
# Check if the HTTP response code is 200 (OK)
if [ $HTTP_RESPONSE -eq 200 ]; then
echo "Health check successful."
docker stop apollo_router_test
docker rm apollo_router_test
exit 0
else
echo "Health check failed with HTTP status code $HTTP_RESPONSE."
docker stop apollo_router_test
docker rm apollo_router_test
exit 1
fi
# Builds binaries from Rust crates
build-rust-binaries:
name: build-rust-binaries
uses: ./.github/workflows/publish-rust.yaml
with:
publish: false
secrets: inherit