Repository navigation
199 lines (197 loc) · 8.47 KB
/
Copy pathruntime-e2e.yml
File metadata and controls
199 lines (197 loc) · 8.47 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: Rust Runtime E2E
on:
push:
pull_request:
workflow_dispatch:
inputs:
source_sha:
description: Exact generated proposal commit to test
type: string
required: true
permissions:
contents: read
jobs:
validate-source:
runs-on: ubuntu-latest
steps:
- env:
SOURCE_SHA: ${{ inputs.source_sha || github.sha }}
run: '[[ "$SOURCE_SHA" =~ ^[0-9a-f]{40}$ ]]'
runtime-e2e:
needs: validate-source
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
postgres: ['15', '18']
steps:
- name: Use an isolated Docker client configuration
run: |
set -eu
docker_config=$(mktemp -d "$RUNNER_TEMP/plex-docker-config.XXXXXX")
printf '{}\n' > "$docker_config/config.json"
chmod 700 "$docker_config"
chmod 600 "$docker_config/config.json"
echo "DOCKER_CONFIG=$docker_config" >> "$GITHUB_ENV"
- uses: actions/checkout@v4
with:
ref: ${{ inputs.source_sha || github.sha }}
persist-credentials: false
- name: Start the owned PostgreSQL fixture
id: postgres
env:
POSTGRES_IMAGE: postgres:${{ matrix.postgres }}
run: |
set -eu
ownership="runtime-e2e-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT"
container_file=$(mktemp "$RUNNER_TEMP/runtime-e2e-postgres.XXXXXX")
echo "RUNTIME_E2E_CONTAINER_FILE=$container_file" >> "$GITHUB_ENV"
docker pull "$POSTGRES_IMAGE"
container=$(docker create \
--label plex-postgresql.test=runtime-e2e \
--label "plex-postgresql.run=$ownership" \
-e POSTGRES_USER=runtime_e2e_admin \
-e POSTGRES_PASSWORD=runtime_e2e_fixture_password \
-e POSTGRES_DB=runtime_e2e_admin \
-p 127.0.0.1::5432 "$POSTGRES_IMAGE")
printf '%s\n' "$container" > "$container_file"
docker start "$container" >/dev/null
ready=0
for attempt in $(seq 1 60); do
if docker exec "$container" pg_isready -h 127.0.0.1 -p 5432 -U runtime_e2e_admin -d runtime_e2e_admin >/dev/null 2>&1; then
ready=1
break
fi
sleep 1
done
test "$ready" = 1
binding=$(docker port "$container" 5432/tcp)
[[ "$binding" =~ ^127\.0\.0\.1:([0-9]+)$ ]]
echo "port=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
- uses: dtolnay/rust-toolchain@stable
- name: Install existing native link prerequisites
run: sudo apt-get update && sudo apt-get install -y libpq-dev libsqlite3-dev postgresql-client
- name: Exercise the real interpose shared artifact
env:
RUNTIME_E2E_EXTERNAL_FIXTURE: '1'
RUNTIME_E2E_ADMIN_HOST: 127.0.0.1
RUNTIME_E2E_ADMIN_PORT: ${{ steps.postgres.outputs.port }}
RUNTIME_E2E_ADMIN_USER: runtime_e2e_admin
RUNTIME_E2E_ADMIN_PASSWORD: runtime_e2e_fixture_password
RUNTIME_E2E_ADMIN_DATABASE: runtime_e2e_admin
run: bash scripts/run-runtime-e2e.sh --reconnect
- name: Clean up the owned PostgreSQL fixture
if: always()
run: |
set -eu
if [[ -z "${RUNTIME_E2E_CONTAINER_FILE:-}" || ! -s "$RUNTIME_E2E_CONTAINER_FILE" ]]; then
exit 0
fi
container=$(cat "$RUNTIME_E2E_CONTAINER_FILE")
[[ "$container" =~ ^[0-9a-f]{64}$ ]]
expected="runtime-e2e-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT"
actual=$(docker inspect --format '{{ index .Config.Labels "plex-postgresql.run" }}' "$container")
kind=$(docker inspect --format '{{ index .Config.Labels "plex-postgresql.test" }}' "$container")
[[ "$actual" == "$expected" && "$kind" == runtime-e2e ]]
if [[ "${{ job.status }}" != success ]]; then
docker logs --tail 80 "$container" || true
fi
docker rm -fv "$container"
rm "$RUNTIME_E2E_CONTAINER_FILE"
metadata-descriptor-e2e:
needs: validate-source
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
postgres: ['15', '18']
steps:
- name: Use an isolated Docker client configuration
run: |
set -eu
docker_config=$(mktemp -d "$RUNNER_TEMP/plex-docker-config.XXXXXX")
printf '{}\n' > "$docker_config/config.json"
chmod 700 "$docker_config"
chmod 600 "$docker_config/config.json"
echo "DOCKER_CONFIG=$docker_config" >> "$GITHUB_ENV"
- uses: actions/checkout@v4
with:
ref: ${{ inputs.source_sha || github.sha }}
persist-credentials: false
- name: Start the owned PostgreSQL fixture
id: postgres
env:
POSTGRES_IMAGE: postgres:${{ matrix.postgres }}
run: |
set -eu
ownership="metadata-e2e-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT"
container_file=$(mktemp "$RUNNER_TEMP/metadata-e2e-postgres.XXXXXX")
echo "METADATA_E2E_CONTAINER_FILE=$container_file" >> "$GITHUB_ENV"
docker pull "$POSTGRES_IMAGE"
container=$(docker create \
--label plex-postgresql.test=metadata-e2e \
--label "plex-postgresql.run=$ownership" \
-e POSTGRES_USER=runtime_e2e_admin \
-e POSTGRES_PASSWORD=runtime_e2e_fixture_password \
-e POSTGRES_DB=runtime_e2e_admin \
-p 127.0.0.1::5432 "$POSTGRES_IMAGE")
printf '%s\n' "$container" > "$container_file"
docker start "$container" >/dev/null
ready=0
for attempt in $(seq 1 60); do
if docker exec "$container" pg_isready -h 127.0.0.1 -p 5432 -U runtime_e2e_admin -d runtime_e2e_admin >/dev/null 2>&1; then
ready=1
break
fi
sleep 1
done
test "$ready" = 1
binding=$(docker port "$container" 5432/tcp)
[[ "$binding" =~ ^127\.0\.0\.1:([0-9]+)$ ]]
echo "port=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
- name: Exercise prepared descriptors across empty results, outage and recovery
env:
RUNTIME_E2E_EXTERNAL_FIXTURE: '1'
RUNTIME_E2E_ADMIN_HOST: 127.0.0.1
RUNTIME_E2E_ADMIN_PORT: ${{ steps.postgres.outputs.port }}
RUNTIME_E2E_ADMIN_USER: runtime_e2e_admin
RUNTIME_E2E_ADMIN_PASSWORD: runtime_e2e_fixture_password
RUNTIME_E2E_ADMIN_DATABASE: runtime_e2e_admin
# Pinned alpine 3.15 (musl 1.2.2, the release builder base) via the
# ECR mirror to stay independent of Docker Hub auth outages.
ALPINE_BUILDER_IMAGE: docker.io/library/alpine@sha256:19b4bcc4f60e99dd5ebdca0cbce22c503bbcff197549d7e19dab4f22254dc864
run: |
set -eu
docker run --rm --network host \
-e RUNTIME_E2E_EXTERNAL_FIXTURE -e RUNTIME_E2E_ADMIN_HOST \
-e RUNTIME_E2E_ADMIN_PORT -e RUNTIME_E2E_ADMIN_USER \
-e RUNTIME_E2E_ADMIN_PASSWORD -e RUNTIME_E2E_ADMIN_DATABASE \
-v "$GITHUB_WORKSPACE":/src -w /src \
"$ALPINE_BUILDER_IMAGE" sh -c '
set -eu
apk add --no-cache bash build-base postgresql-dev postgresql14-client sqlite-dev sqlite-libs linux-headers curl
export CARGO_HOME=/usr/local/cargo RUSTUP_HOME=/usr/local/rustup RUSTUP_TOOLCHAIN=stable
export PATH="/usr/local/cargo/bin:$PATH"
curl --proto =https --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile minimal
exec bash scripts/run-metadata-descriptor-e2e.sh
'
- name: Clean up the owned PostgreSQL fixture
if: always()
run: |
set -eu
if [[ -z "${METADATA_E2E_CONTAINER_FILE:-}" || ! -s "$METADATA_E2E_CONTAINER_FILE" ]]; then
exit 0
fi
container=$(cat "$METADATA_E2E_CONTAINER_FILE")
[[ "$container" =~ ^[0-9a-f]{64}$ ]]
expected="metadata-e2e-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT"
actual=$(docker inspect --format '{{ index .Config.Labels "plex-postgresql.run" }}' "$container")
kind=$(docker inspect --format '{{ index .Config.Labels "plex-postgresql.test" }}' "$container")
[[ "$actual" == "$expected" && "$kind" == metadata-e2e ]]
if [[ "${{ job.status }}" != success ]]; then
docker logs --tail 80 "$container" || true
fi
docker rm -fv "$container"
rm "$METADATA_E2E_CONTAINER_FILE"