Skip to content

Commit c28325a

Browse files
committed
Fix GitHub Actions CI test execution - Fixed SCRIPT_DIR path resolution in test script - Added main/master branch compatibility - Enhanced GitHub Actions workflow with debugging output - Tests now pass both locally and in CI environment
1 parent c896463 commit c28325a

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

.github/workflows/test.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,24 @@ jobs:
1414
- name: Checkout code
1515
uses: actions/checkout@v4
1616

17+
- name: Verify repository structure
18+
run: |
19+
echo "Current directory: $(pwd)"
20+
echo "Repository contents:"
21+
ls -la
22+
echo "Bin directory contents:"
23+
ls -la bin/
24+
1725
- name: Make test script executable
1826
run: chmod +x bin/gitstack_test.sh
1927

2028
- name: Run gitstack tests
29+
working-directory: .
2130
run: |
2231
echo "🧪 Running gitstack tests..."
23-
if bin/gitstack_test.sh; then
32+
echo "Working directory: $(pwd)"
33+
echo "Running from: $(realpath bin/gitstack_test.sh)"
34+
if ./bin/gitstack_test.sh; then
2435
echo "✅ All tests passed!"
2536
else
2637
echo "❌ Tests failed!"

bin/gitstack_test.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020

2121
set -e # Exit immediately if a command exits with a nonzero status
2222

23+
# Get the absolute path of the script directory BEFORE changing directories
24+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
25+
2326
function current_branch() {
2427
git rev-parse --abbrev-ref HEAD
2528
}
@@ -32,7 +35,6 @@ function fail() {
3235
# Test helper function to source gitstack.sh and make functions available for testing
3336
function source_gitstack() {
3437
# Source the main script to get access to internal functions
35-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
3638
echo "Sourcing from: $SCRIPT_DIR/gitstack.sh"
3739
source "$SCRIPT_DIR/gitstack.sh"
3840
}
@@ -450,9 +452,6 @@ function run_all_tests() {
450452
test_convert_to_stack
451453
}
452454

453-
# Get the absolute path of the script directory
454-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
455-
456455
# Create a temporary test directory
457456
TEST_DIR=$(mktemp -d)
458457
echo "Creating test repository in $TEST_DIR"
@@ -468,6 +467,11 @@ touch README.md
468467
git add README.md
469468
git commit -m "Initial commit"
470469

470+
# Rename master to main if needed (for consistency)
471+
if git rev-parse --verify master &>/dev/null && ! git rev-parse --verify main &>/dev/null; then
472+
git branch -m master main
473+
fi
474+
471475
echo "Starting git stack tests..."
472476

473477
# Run all tests

0 commit comments

Comments
 (0)