@@ -16,24 +16,39 @@ jobs:
1616 steps :
1717 - uses : actions/checkout@v4
1818
19+ - name : Setup PHP
20+ uses : shivammathur/setup-php@v2
21+ with :
22+ php-version : ' 8.1'
23+ extensions : mbstring, xml, ctype, json, fileinfo, tokenizer
24+ coverage : none
25+
26+ - name : Cache Composer packages
27+ uses : actions/cache@v3
28+ with :
29+ path : vendor
30+ key : ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
31+ restore-keys : |
32+ ${{ runner.os }}-php-
33+
1934 - name : Install dependencies
20- run : composer install
35+ run : composer install --prefer-dist --no-progress --no-suggest
2136
2237 - name : Configure environment
2338 run : |
2439 echo "HYDE_RC_RUNNER_PATH=/tmp/hyde-rc-runner" >> $GITHUB_ENV
25- if [ ${{ github.event_name }} == 'push' ]; then
40+ if [ " ${{ github.event_name }}" == 'push' ]; then
2641 echo "HYDE_RC_RUNNER_BRANCH=master" >> $GITHUB_ENV
2742 else
28- echo "HYDE_RC_BRANCH=$GITHUB_SHA " >> $GITHUB_ENV
43+ echo "HYDE_RC_BRANCH=${{ github.sha }} " >> $GITHUB_ENV
2944 fi
3045
3146 - name : Set up test runner
3247 run : |
3348 echo -e "\033[33mSetting up test runner...\033[0m This may take a while."
3449
3550 TARGET_DIR="/tmp/hyde-rc-runner"
36- # TODO Use master instead of develop when merged
51+ # TODO: Use master instead of develop when merged
3752 ARCHIVE="https://github.com/hydephp/hyde/archive/refs/heads/develop.zip"
3853 TEMP_ZIP=$(mktemp)
3954 TEMP_EXTRACT_DIR="${TARGET_DIR}_temp"
@@ -44,26 +59,74 @@ jobs:
4459 fi
4560
4661 echo -e "\033[33mDownloading test runner scaffolding...\033[0m"
47- wget -q "$ARCHIVE" -O "$TEMP_ZIP"
62+ if ! wget -q "$ARCHIVE" -O "$TEMP_ZIP"; then
63+ echo "Failed to download archive from $ARCHIVE"
64+ exit 1
65+ fi
4866
4967 echo -e "\033[33mExtracting archive...\033[0m"
5068 mkdir -p "$TEMP_EXTRACT_DIR"
51- unzip -q "$TEMP_ZIP" -d "$TEMP_EXTRACT_DIR"
69+ if ! unzip -q "$TEMP_ZIP" -d "$TEMP_EXTRACT_DIR"; then
70+ echo "Failed to extract archive"
71+ exit 1
72+ fi
5273
5374 # Get the name of the root directory in the zip file
5475 ROOT_DIR=$(ls "$TEMP_EXTRACT_DIR" | head -n 1)
5576
77+ if [ -z "$ROOT_DIR" ]; then
78+ echo "No root directory found in extracted archive"
79+ exit 1
80+ fi
81+
5682 # Move the contents to the target directory
5783 mv "$TEMP_EXTRACT_DIR/$ROOT_DIR" "$TARGET_DIR"
5884
5985 # Clean up
6086 rm -rf "$TEMP_EXTRACT_DIR"
6187 rm "$TEMP_ZIP"
88+
89+ echo -e "\033[32mTest runner setup complete\033[0m"
90+
91+ - name : Verify test runner setup
92+ run : |
93+ TARGET_DIR="/tmp/hyde-rc-runner"
94+
95+ if [ ! -d "$TARGET_DIR" ]; then
96+ echo "❌ Test runner directory does not exist: $TARGET_DIR"
97+ exit 1
98+ fi
99+
100+ echo "✅ Test runner directory exists"
101+ echo "Contents of test runner directory:"
102+ ls -la "$TARGET_DIR"
103+
104+ if [ ! -f "$TARGET_DIR/composer.json" ]; then
105+ echo "❌ composer.json not found in test runner"
106+ exit 1
107+ fi
108+
109+ echo "✅ composer.json found"
62110
63111 - name : Debug configuration
64112 run : |
65- # Fix the Author configuration in hyde.php to prevent the error
66113 CONFIG_FILE="/tmp/hyde-rc-runner/config/hyde.php"
114+
115+ if [ ! -f "$CONFIG_FILE" ]; then
116+ echo "❌ Configuration file not found: $CONFIG_FILE"
117+ echo "Available files in config directory:"
118+ if [ -d "/tmp/hyde-rc-runner/config" ]; then
119+ ls -la "/tmp/hyde-rc-runner/config/"
120+ else
121+ echo "Config directory does not exist"
122+ fi
123+ echo "Root directory contents:"
124+ ls -la "/tmp/hyde-rc-runner/"
125+ exit 1
126+ fi
127+
128+ echo "✅ Configuration file found"
129+ echo "Configuration file contents:"
67130 cat "$CONFIG_FILE"
68131
69132 - name : Install test package
@@ -73,8 +136,54 @@ jobs:
73136 echo -e "\033[33mInstalling hyde/realtime-compiler:dev-$BRANCH...\033[0m"
74137
75138 cd "/tmp/hyde-rc-runner"
76- composer config repositories.realtime-compiler path $(realpath $GITHUB_WORKSPACE)
77- composer require --dev hyde/realtime-compiler:dev-$BRANCH --no-progress
139+
140+ # Install composer dependencies first
141+ if [ -f "composer.json" ]; then
142+ echo "Installing test runner dependencies..."
143+ composer install --no-dev --prefer-dist --no-progress
144+ fi
145+
146+ # Add the local package repository
147+ composer config repositories.realtime-compiler path "$(realpath "$GITHUB_WORKSPACE")"
148+
149+ # Require the package
150+ if ! composer require --dev "hyde/realtime-compiler:dev-$BRANCH" --no-progress; then
151+ echo "❌ Failed to install hyde/realtime-compiler package"
152+ echo "Available branches/tags:"
153+ git ls-remote --heads --tags origin
154+ exit 1
155+ fi
156+
157+ echo "✅ Package installed successfully"
158+
159+ - name : Verify package installation
160+ run : |
161+ cd "/tmp/hyde-rc-runner"
162+ echo "Installed packages:"
163+ composer show --dev | grep realtime-compiler || echo "Package not found in composer show"
164+
165+ echo "Vendor directory contents:"
166+ ls -la vendor/hyde/ || echo "Hyde vendor directory not found"
78167
79168 - name : Run tests with PHPUnit
80- run : vendor/bin/phpunit --colors=always
169+ run : |
170+ cd "/tmp/hyde-rc-runner"
171+
172+ # Check if PHPUnit is available
173+ if [ ! -f "vendor/bin/phpunit" ]; then
174+ echo "❌ PHPUnit not found. Installing..."
175+ composer require --dev phpunit/phpunit --no-progress
176+ fi
177+
178+ echo "Running PHPUnit tests..."
179+ vendor/bin/phpunit --colors=always --verbose
180+
181+ - name : Cleanup on failure
182+ if : failure()
183+ run : |
184+ echo "🧹 Cleaning up on failure..."
185+ echo "Current working directory: $(pwd)"
186+ echo "Environment variables:"
187+ env | sort
188+ echo "Disk usage:"
189+ df -h
0 commit comments