-
Notifications
You must be signed in to change notification settings - Fork 7
144 lines (142 loc) · 6.98 KB
/
Copy pathtest-sample-apps.yml
File metadata and controls
144 lines (142 loc) · 6.98 KB
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Sample apps test and update
on:
pull_request_target:
branches: [ main ]
types: [ opened, synchronize, reopened ]
workflow_dispatch:
permissions:
pull-requests: write
contents: write
jobs:
sample-app-test:
runs-on: ubuntu-latest
concurrency: test-landscape
environment: cf_env
env:
HOSTNAME_PREFIX: gh-run-${{ github.run_id }}-
steps:
- name: Limit access
if: |
github.event_name == 'pull_request_target' &&
github.event.pull_request.head.repo.fork == 'true'
run: |
echo "Deployment not possible!"
exit 1
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event_name == 'pull_request_target' && format('refs/pull/{0}/merge', github.event.number) || '' }}
- name: Setup java/jdk
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
java-package: jdk
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 'stable'
- name: Install grpcurl
run: go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest
- name: Install yq
run: go install github.com/mikefarah/yq/v4@latest
- name: Install CloudFoundry cf cli
run: |
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
sudo apt-get update
sudo apt-get install cf8-cli -y
cf8 --version
- name: Build Java apps
run: ./http2/gradlew clean build -p http2
- name: Logging into target CloudFoundry
run: cf8 login -a "${{ secrets.CF_API }}" -u "${{ secrets.CF_USERNAME }}" -p "${{ secrets.CF_PASSWORD }}" -o "${{ secrets.CF_ORG }}" -s "${{ secrets.CF_SPACE }}" --origin uaa
- name: Deploy HTTP/2 sample apps
run: cf8 push -f "${GITHUB_WORKSPACE}/http2/apps-manifest.yml" --var domain=${{ secrets.CF_DOMAIN }} --var hostname_prefix="$HOSTNAME_PREFIX" --vars-file "${GITHUB_WORKSPACE}/http2/gradle.properties"
- name: Test HTTP/2 Sample apps
run: |
get_route() {
echo "${HOSTNAME_PREFIX}${1}.${{ secrets.CF_DOMAIN }}"
}
echo "### Testing HTTP2_APP app ###"
yq e '.applications.[].name' "${GITHUB_WORKSPACE}/http2/apps-manifest.yml" | grep -i 'http2' | while read -r HTTP2_APP; do
curl -v --http2-prior-knowledge -H 'Connection: close' "https://$(get_route "$HTTP2_APP")"
done
echo "Testing GRPC apps"
grpcurl $(get_route go-grpc-test):443 example.Example.Run
grpcurl -proto http2/java-grpc/app/src/main/proto/example.proto $(get_route java-grpc-test):443 example.Example.Run
grpcurl -proto http2/node-grpc/example.proto $(get_route node-grpc-test):443 Example.Run
grpcurl -proto http2/python-grpc/example.proto $(get_route python-grpc-test):443 Example.Run
grpcurl -proto http2/ruby-grpc/example.proto $(get_route ruby-grpc-test):443 Example.Run
- name: Deploy IP Allow-List Sample App
run: |
cf8 push --var "domain=${{ secrets.CF_DOMAIN }}" --var "prefix=${HOSTNAME_PREFIX}" --manifest "${GITHUB_WORKSPACE}/ip-allow-listing-route-service/manifest.yml"
cf8 create-user-provided-service "${HOSTNAME_PREFIX}allow-list" -r "https://${HOSTNAME_PREFIX}ip-allow-list-rs.${{ secrets.CF_DOMAIN }}"
cf8 bind-route-service "${{ secrets.CF_DOMAIN }}" --hostname "${HOSTNAME_PREFIX}ok" "${HOSTNAME_PREFIX}allow-list"
- name: Test IP Allow-List Sample App
run: |
echo "Test IPv4 is accessible"
# Wait for route update propagation after route-service-binding
max_attempts=4
attempt=0
until [ $attempt -ge $max_attempts ]; do
http_code=$(curl --silent --output /dev/null --write-out "%{http_code}" -4 "https://${HOSTNAME_PREFIX}ok.${{ secrets.CF_DOMAIN }}")
if [ "$http_code" -eq 200 ]; then
echo "Route is accessible (HTTP $http_code)"
exit 0
fi
attempt=$((attempt + 1))
if [ $attempt -lt $max_attempts ]; then
echo "Route not yet accessible (HTTP $http_code), retrying in 5 seconds... (attempt $attempt/$max_attempts)"
sleep 5
fi
done
echo "Route failed to become accessible after $max_attempts attempts (HTTP $http_code)"
exit 1
- name: Deploy Per-Route Loadbalancing Sample App
run: cf8 push --var "domain=${{ secrets.CF_DOMAIN }}" --var "hostname_prefix=${HOSTNAME_PREFIX}" --manifest "${GITHUB_WORKSPACE}/per-route/loadbalancing/manifest.yml" --path "${GITHUB_WORKSPACE}/per-route/loadbalancing"
- name: Test Per-Route Loadbalancing Sample App
run: |
echo "Testing per-route loadbalancing routes"
for route in per-route-lb per-route-lb-lc per-route-lb-rr per-route-lb-hb; do
echo "Testing route: ${HOSTNAME_PREFIX}${route}.${{ secrets.CF_DOMAIN }}"
http_code=$(curl --silent --output /dev/null --write-out "%{http_code}" "https://${HOSTNAME_PREFIX}${route}.${{ secrets.CF_DOMAIN }}/requests")
if [ "$http_code" -ne 200 ]; then
echo "Route ${route} failed with HTTP $http_code"
exit 1
fi
echo "Route ${route} accessible (HTTP $http_code)"
done
- name: Clean-up
if: success() || failure()
run: |
echo "Deleting service instance ${HOSTNAME_PREFIX}allow-list"
cf8 delete-service "${HOSTNAME_PREFIX}allow-list" -f || true
echo "Deleting apps and routes"
yq e '.applications.[].name' "${GITHUB_WORKSPACE}/http2/apps-manifest.yml" | while read -r app_name; do
echo "Deleting app: $app_name"
cf8 delete "$app_name" -r -f || true
done
yq e '.applications.[].name' "${GITHUB_WORKSPACE}/ip-allow-listing-route-service/manifest.yml" | while read -r app_name; do
echo "Deleting app: $app_name"
cf8 delete "$app_name" -r -f || true
done
yq e '.applications.[].name' "${GITHUB_WORKSPACE}/per-route/loadbalancing/manifest.yml" | while read -r app_name; do
echo "Deleting app: $app_name"
cf8 delete "$app_name" -r -f || true
done
automerge:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
needs: [sample-app-test]
steps:
- name: Approve
run: gh pr review "${{ github.event.pull_request.html_url }}" --approve --body "Auto-approving dependency bump."
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Enable auto-merge
run: gh pr merge "${{ github.event.pull_request.html_url }}" --auto --rebase
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}