Skip to content

Commit fb8514d

Browse files
committed
GHA: added smoke tests for gitea + pgsql.
1 parent 86d8103 commit fb8514d

5 files changed

Lines changed: 254 additions & 0 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: smoke-gitea-service
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: ['**']
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
smoke:
14+
name: Smoke-test Gitea service
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 30
17+
steps:
18+
- uses: actions/checkout@v6
19+
20+
- name: Set up Java
21+
uses: actions/setup-java@v5
22+
with:
23+
distribution: 'temurin'
24+
java-version: '21'
25+
26+
- name: Generate certificates
27+
working-directory: security/scripts
28+
run: |
29+
set -euo pipefail
30+
./create_root_ca_cert.sh
31+
32+
- name: Start Gitea service
33+
run: |
34+
set -euo pipefail
35+
make -C deploy start-git-ea
36+
37+
- name: Smoke tests
38+
env:
39+
GITEA_SMOKE_START_SERVICES: "0"
40+
run: |
41+
set -euo pipefail
42+
./scripts/tests/smoke_gitea_service.sh
43+
44+
- name: Dump container logs
45+
if: failure()
46+
run: |
47+
set -euo pipefail
48+
source deploy/export_env_vars.sh
49+
docker compose -f deploy/services.yml ps
50+
docker compose -f deploy/services.yml logs --no-color gitea
51+
52+
- name: Shutdown stack
53+
if: always()
54+
run: |
55+
set -euo pipefail
56+
source deploy/export_env_vars.sh
57+
docker compose -f deploy/services.yml down -v
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: smoke-postgres-services
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: ['**']
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
smoke:
14+
name: Smoke-test samples Postgres service
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 30
17+
steps:
18+
- uses: actions/checkout@v6
19+
20+
- name: Start samples database
21+
run: |
22+
set -euo pipefail
23+
make -C deploy start-samples
24+
25+
- name: Smoke tests
26+
env:
27+
POSTGRES_SMOKE_START_SERVICES: "0"
28+
run: |
29+
set -euo pipefail
30+
./scripts/tests/smoke_postgres_services.sh
31+
32+
- name: Dump container logs
33+
if: failure()
34+
run: |
35+
set -euo pipefail
36+
source deploy/export_env_vars.sh
37+
docker compose -f deploy/services.yml ps
38+
docker compose -f deploy/services.yml logs --no-color samples-db
39+
40+
- name: Shutdown stack
41+
if: always()
42+
run: |
43+
set -euo pipefail
44+
source deploy/export_env_vars.sh
45+
docker compose -f deploy/services.yml down -v

scripts/maintenance/audit_pip_dependency.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ PY_REQS=(
1212

1313
PY_REQS_NIFI=(
1414
"nifi/requirements.txt"
15+
"nifi/requirements-dev.txt"
1516
)
1617

1718
INCLUDE_NIFI=false
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
# Smoke checks for the Gitea service.
3+
4+
set -euo pipefail
5+
6+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
7+
ENV_LOADER="${ROOT_DIR}/deploy/export_env_vars.sh"
8+
SMOKE_HELPERS="${ROOT_DIR}/scripts/tests/smoke_http_checks.sh"
9+
10+
if [[ -f "$ENV_LOADER" ]]; then
11+
# shellcheck disable=SC1090
12+
source "$ENV_LOADER"
13+
fi
14+
15+
if [[ ! -f "$SMOKE_HELPERS" ]]; then
16+
echo "Missing smoke helper script: $SMOKE_HELPERS" >&2
17+
exit 1
18+
fi
19+
20+
# shellcheck disable=SC1090
21+
source "$SMOKE_HELPERS"
22+
23+
HOST="${GITEA_SMOKE_HOST:-localhost}"
24+
PORT="${GITEA_SMOKE_PORT:-3000}"
25+
26+
START_SERVICES="${GITEA_SMOKE_START_SERVICES:-1}"
27+
RETRIES="${GITEA_SMOKE_RETRIES:-30}"
28+
DELAY_SECONDS="${GITEA_SMOKE_DELAY_SECONDS:-10}"
29+
30+
SMOKE_CHECKS=(
31+
"gitea-root|https://${HOST}:${PORT}/"
32+
"gitea-login|https://${HOST}:${PORT}/user/login"
33+
)
34+
35+
if [[ "$START_SERVICES" != "0" ]]; then
36+
if ! command -v make >/dev/null 2>&1; then
37+
echo "make is required to start Gitea services via the Makefile." >&2
38+
exit 1
39+
fi
40+
41+
echo "Starting Gitea service using 'make -C deploy start-git-ea'."
42+
make -C "${ROOT_DIR}/deploy" start-git-ea
43+
fi
44+
45+
echo "Running smoke checks against Gitea."
46+
wait_for_checks "Gitea" "$RETRIES" "$DELAY_SECONDS" "${SMOKE_CHECKS[@]}"
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/usr/bin/env bash
2+
# Smoke checks for the samples Postgres service.
3+
4+
set -euo pipefail
5+
6+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
7+
ENV_LOADER="${ROOT_DIR}/deploy/export_env_vars.sh"
8+
9+
if [[ -f "$ENV_LOADER" ]]; then
10+
# shellcheck disable=SC1090
11+
source "$ENV_LOADER"
12+
fi
13+
14+
if ! command -v docker >/dev/null 2>&1; then
15+
echo "docker is required for Postgres smoke checks." >&2
16+
exit 1
17+
fi
18+
19+
CONTAINER_NAME="${POSTGRES_SMOKE_CONTAINER_NAME:-cogstack-samples-db}"
20+
DB_USER="${POSTGRES_USER_SAMPLES:-test}"
21+
DB_PASSWORD="${POSTGRES_PASSWORD_SAMPLES:-test}"
22+
DB_NAME="${POSTGRES_SAMPLES_DB_NAME:-db_samples}"
23+
24+
START_SERVICES="${POSTGRES_SMOKE_START_SERVICES:-1}"
25+
RETRIES="${POSTGRES_SMOKE_RETRIES:-30}"
26+
DELAY_SECONDS="${POSTGRES_SMOKE_DELAY_SECONDS:-10}"
27+
28+
check_container_running() {
29+
local status
30+
31+
status="$(docker inspect --format '{{.State.Status}}' "$CONTAINER_NAME" 2>/dev/null || true)"
32+
if [[ "$status" == "running" ]]; then
33+
echo "OK: container ${CONTAINER_NAME} is running"
34+
return 0
35+
fi
36+
37+
echo "FAIL: container ${CONTAINER_NAME} is not running"
38+
return 1
39+
}
40+
41+
check_pg_isready() {
42+
if docker exec \
43+
-e PGPASSWORD="$DB_PASSWORD" \
44+
"$CONTAINER_NAME" \
45+
pg_isready -U "$DB_USER" -d "$DB_NAME" >/dev/null 2>&1; then
46+
echo "OK: pg_isready for database ${DB_NAME}"
47+
return 0
48+
fi
49+
50+
echo "FAIL: pg_isready failed for database ${DB_NAME}"
51+
return 1
52+
}
53+
54+
check_basic_query() {
55+
local result
56+
57+
if ! result="$(
58+
docker exec \
59+
-e PGPASSWORD="$DB_PASSWORD" \
60+
"$CONTAINER_NAME" \
61+
psql -U "$DB_USER" -d "$DB_NAME" -tAc 'SELECT 1'
62+
)"; then
63+
echo "FAIL: query check failed for database ${DB_NAME}"
64+
return 1
65+
fi
66+
67+
result="$(echo "$result" | tr -d '[:space:]')"
68+
if [[ "$result" == "1" ]]; then
69+
echo "OK: query check returned 1"
70+
return 0
71+
fi
72+
73+
echo "FAIL: query check returned unexpected value: ${result}"
74+
return 1
75+
}
76+
77+
run_checks() {
78+
check_container_running &&
79+
check_pg_isready &&
80+
check_basic_query
81+
}
82+
83+
if [[ "$START_SERVICES" != "0" ]]; then
84+
if ! command -v make >/dev/null 2>&1; then
85+
echo "make is required to start Postgres services via the Makefile." >&2
86+
exit 1
87+
fi
88+
89+
echo "Starting samples Postgres service using 'make -C deploy start-samples'."
90+
make -C "${ROOT_DIR}/deploy" start-samples
91+
fi
92+
93+
echo "Running samples Postgres smoke checks."
94+
for attempt in $(seq 1 "$RETRIES"); do
95+
if run_checks; then
96+
exit 0
97+
fi
98+
if [[ "$attempt" -lt "$RETRIES" ]]; then
99+
echo "Attempt ${attempt}/${RETRIES} failed. Sleeping ${DELAY_SECONDS}s..."
100+
sleep "$DELAY_SECONDS"
101+
fi
102+
done
103+
104+
echo "Smoke checks failed after ${RETRIES} attempts."
105+
exit 1

0 commit comments

Comments
 (0)