-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest_ci_workflows.sh
More file actions
executable file
·62 lines (51 loc) · 1.81 KB
/
Copy pathtest_ci_workflows.sh
File metadata and controls
executable file
·62 lines (51 loc) · 1.81 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
#!/bin/bash
set -euo pipefail
# shellcheck source=_test_env.sh
source "$(dirname "${BASH_SOURCE[0]}")/_test_env.sh"
# Unit tests for GitHub Actions workflow shape.
PASS=0
FAIL=0
TESTS_DIR="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$(cd "$TESTS_DIR/.." && pwd)"
CI_YML="$REPO_ROOT/.github/workflows/ci.yml"
INTEGRATION_YML="$REPO_ROOT/.github/workflows/integration.yml"
assert_eq() {
local label="$1" expected="$2" actual="$3"
if [ "$expected" = "$actual" ]; then
echo " PASS: ${label}"
PASS=$((PASS + 1))
else
echo " FAIL: ${label}"
echo " expected: ${expected}"
echo " actual: ${actual}"
FAIL=$((FAIL + 1))
fi
}
echo "=== 1. Integration workflow jobs ==="
assert_eq "workflow keeps manual dispatch" "1" \
"$(grep -cE '^ workflow_dispatch:' "$INTEGRATION_YML")"
assert_eq "workflow keeps smoke job" "1" \
"$(grep -cE '^ smoke-test:' "$INTEGRATION_YML")"
assert_eq "workflow has no full-matrix job" "0" \
"$(grep -cE '^ full-matrix:' "$INTEGRATION_YML" || true)"
assert_eq "workflow does not run --all" "0" \
"$(grep -cF './tests/test.sh --all' "$INTEGRATION_YML" || true)"
echo ""
echo "=== 2. Shared test environment ==="
missing_env=""
for test_file in "$TESTS_DIR"/*.sh; do
[ "$test_file" = "$TESTS_DIR/_test_env.sh" ] && continue
if ! grep -qF \
'source "$(dirname "${BASH_SOURCE[0]}")/_test_env.sh"' \
"$test_file"; then
missing_env="${missing_env} $(basename "$test_file")"
fi
done
assert_eq "all test scripts source the shared environment" "" "$missing_env"
assert_eq "CI checks every test script" "1" \
"$(grep -cF 'tests/*.sh' "$CI_YML")"
echo ""
echo "==============================="
echo " ${PASS} passed, ${FAIL} failed"
echo "==============================="
[ "$FAIL" -eq 0 ]