Skip to content

Commit 900ed79

Browse files
committed
fix: enhance integration tests and build-fixtures script to support dynamic framework selection
1 parent 3655d55 commit 900ed79

File tree

2 files changed

+52
-33
lines changed

2 files changed

+52
-33
lines changed

.github/workflows/integration-tests.yml

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
paths:
77
- 'booster/**'
88
- 'tools/internal-test/**'
9+
- 'tools/build-fixtures.sh'
910
- '.github/workflows/integration-tests.yml'
1011
pull_request:
1112
branches: [main, develop]
@@ -99,9 +100,10 @@ jobs:
99100
uses: actions/cache@v4
100101
with:
101102
path: tests/.fixtures-cache
102-
key: ${{ runner.os }}-test-fixtures-v1-${{ hashFiles('tests/.fixtures-cache/**/FIXTURE_VERSION') }}
103+
key: ${{ runner.os }}-test-fixtures-v2-${{ matrix.project_type }}-${{ hashFiles('tools/build-fixtures.sh') }}
103104
restore-keys: |
104-
${{ runner.os }}-test-fixtures-v1-
105+
${{ runner.os }}-test-fixtures-v2-${{ matrix.project_type }}-
106+
${{ runner.os }}-test-fixtures-v2-
105107
106108
- name: Install DDEV
107109
uses: ddev/github-action-setup-ddev@v1
@@ -120,22 +122,23 @@ jobs:
120122
121123
- name: Build test fixtures if not cached
122124
run: |
123-
if [ ! -d "tests/.fixtures-cache/laravel" ] || [ ! -d "tests/.fixtures-cache/symfony" ]; then
124-
echo "📦 Building test fixtures (first run or cache miss)..."
125+
TARGET_PROJECT="${{ matrix.project_type }}"
126+
127+
if [ ! -d "tests/.fixtures-cache/$TARGET_PROJECT" ]; then
128+
echo "📦 Building $TARGET_PROJECT fixture (first run or cache miss)..."
125129
chmod +x tools/build-fixtures.sh
126130
mkdir -p tests/.fixtures-cache
127-
bash tools/build-fixtures.sh tests/.fixtures-cache
131+
bash tools/build-fixtures.sh tests/.fixtures-cache "$TARGET_PROJECT"
128132
129-
# Extract tarballs to cache directory
133+
# Extract tarball to cache directory
130134
cd tests/.fixtures-cache
131-
tar xzf laravel-fixture.tar.gz
132-
tar xzf symfony-fixture.tar.gz
135+
tar xzf "$TARGET_PROJECT-fixture.tar.gz"
133136
134-
echo "✅ Fixtures built and ready"
137+
echo "✅ $TARGET_PROJECT fixture built and ready"
135138
ls -lh
136139
else
137-
echo "✅ Using cached fixtures"
138-
ls -lh tests/.fixtures-cache/*/FIXTURE_VERSION
140+
echo "✅ Using cached $TARGET_PROJECT fixture"
141+
ls -lh "tests/.fixtures-cache/$TARGET_PROJECT/FIXTURE_VERSION"
139142
fi
140143
141144
- name: Run integration test
@@ -228,9 +231,10 @@ jobs:
228231
uses: actions/cache@v4
229232
with:
230233
path: tests/.fixtures-cache
231-
key: ${{ runner.os }}-test-fixtures-v1-${{ hashFiles('tests/.fixtures-cache/**/FIXTURE_VERSION') }}
234+
key: ${{ runner.os }}-test-fixtures-v2-${{ github.event.inputs.project_type }}-${{ hashFiles('tools/build-fixtures.sh') }}
232235
restore-keys: |
233-
${{ runner.os }}-test-fixtures-v1-
236+
${{ runner.os }}-test-fixtures-v2-${{ github.event.inputs.project_type }}-
237+
${{ runner.os }}-test-fixtures-v2-
234238
235239
- name: Install DDEV
236240
uses: ddev/github-action-setup-ddev@v1
@@ -249,22 +253,23 @@ jobs:
249253
250254
- name: Build test fixtures if not cached
251255
run: |
252-
if [ ! -d "tests/.fixtures-cache/laravel" ] || [ ! -d "tests/.fixtures-cache/symfony" ]; then
253-
echo "📦 Building test fixtures (first run or cache miss)..."
256+
TARGET_PROJECT="${{ github.event.inputs.project_type }}"
257+
258+
if [ ! -d "tests/.fixtures-cache/$TARGET_PROJECT" ]; then
259+
echo "📦 Building $TARGET_PROJECT fixture (first run or cache miss)..."
254260
chmod +x tools/build-fixtures.sh
255261
mkdir -p tests/.fixtures-cache
256-
bash tools/build-fixtures.sh tests/.fixtures-cache
262+
bash tools/build-fixtures.sh tests/.fixtures-cache "$TARGET_PROJECT"
257263
258-
# Extract tarballs to cache directory
264+
# Extract tarball to cache directory
259265
cd tests/.fixtures-cache
260-
tar xzf laravel-fixture.tar.gz
261-
tar xzf symfony-fixture.tar.gz
266+
tar xzf "$TARGET_PROJECT-fixture.tar.gz"
262267
263-
echo "✅ Fixtures built and ready"
268+
echo "✅ $TARGET_PROJECT fixture built and ready"
264269
ls -lh
265270
else
266-
echo "✅ Using cached fixtures"
267-
ls -lh tests/.fixtures-cache/*/FIXTURE_VERSION
271+
echo "✅ Using cached $TARGET_PROJECT fixture"
272+
ls -lh "tests/.fixtures-cache/$TARGET_PROJECT/FIXTURE_VERSION"
268273
fi
269274
270275
- name: Run manual test

tools/build-fixtures.sh

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
# Build test fixtures for Laravel and Symfony
44
# Creates tarball archives ready for upload as GitHub release assets
5-
# Usage: bash build-fixtures.sh [output_dir]
5+
# Usage: bash build-fixtures.sh [output_dir] [framework]
6+
# framework: laravel | symfony | all (default)
67

78
set -euo pipefail
89

910
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1011
REPO_ROOT="$(dirname "$SCRIPT_DIR")"
1112
OUTPUT_DIR="${1:-$REPO_ROOT}"
13+
TARGET_FRAMEWORK="${2:-all}"
1214
TEMP_DIR=$(mktemp -d)
1315

1416
# Normalize output path to absolute so tar writes correctly after changing directories.
@@ -19,9 +21,15 @@ fi
1921
echo "🏗️ Building test fixtures..."
2022
echo "Repository root: $REPO_ROOT"
2123
echo "Output directory: $OUTPUT_DIR"
24+
echo "Target framework: $TARGET_FRAMEWORK"
2225
echo "Temporary directory: $TEMP_DIR"
2326
echo ""
2427

28+
if [[ "$TARGET_FRAMEWORK" != "all" && "$TARGET_FRAMEWORK" != "laravel" && "$TARGET_FRAMEWORK" != "symfony" ]]; then
29+
echo "❌ Invalid framework '$TARGET_FRAMEWORK'. Use: laravel, symfony, or all"
30+
exit 1
31+
fi
32+
2533
# Ensure output directory exists
2634
mkdir -p "$OUTPUT_DIR"
2735

@@ -30,9 +38,11 @@ build_fixture() {
3038
local framework=$1
3139
local create_cmd=$2
3240
local additional_deps=$3
41+
local framework_label
42+
framework_label=$(printf '%s' "$framework" | awk '{print toupper(substr($0,1,1)) substr($0,2)}')
3343

3444
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
35-
echo "Building ${framework^} fixture..."
45+
echo "Building ${framework_label} fixture..."
3646
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
3747

3848
local fixture_dir="$TEMP_DIR/$framework"
@@ -82,21 +92,25 @@ build_fixture() {
8292
tar czf "$OUTPUT_DIR/${framework}-fixture.tar.gz" "$framework/"
8393

8494
local size=$(du -h "$OUTPUT_DIR/${framework}-fixture.tar.gz" | cut -f1)
85-
echo "${framework^} fixture built: ${framework}-fixture.tar.gz ($size)"
95+
echo "${framework_label} fixture built: ${framework}-fixture.tar.gz ($size)"
8696
echo ""
8797
}
8898

8999
# Build Laravel fixture
90-
build_fixture \
91-
"laravel" \
92-
"composer create-project laravel/laravel:^11 . --no-interaction --prefer-dist" \
93-
""
100+
if [[ "$TARGET_FRAMEWORK" == "all" || "$TARGET_FRAMEWORK" == "laravel" ]]; then
101+
build_fixture \
102+
"laravel" \
103+
"composer create-project laravel/laravel:^11 . --no-interaction --prefer-dist" \
104+
""
105+
fi
94106

95107
# Build Symfony fixture
96-
build_fixture \
97-
"symfony" \
98-
"composer create-project symfony/skeleton:^7.0 . --no-interaction --prefer-dist" \
99-
"composer require webapp --no-interaction"
108+
if [[ "$TARGET_FRAMEWORK" == "all" || "$TARGET_FRAMEWORK" == "symfony" ]]; then
109+
build_fixture \
110+
"symfony" \
111+
"composer create-project symfony/skeleton:^7.0 . --no-interaction --prefer-dist" \
112+
"composer require webapp --no-interaction --ignore-platform-reqs"
113+
fi
100114

101115
# Cleanup
102116
rm -rf "$TEMP_DIR"

0 commit comments

Comments
 (0)