File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -45,30 +45,36 @@ jobs:
4545 if : github.event_name == 'pull_request'
4646 id : main-coverage
4747 run : |
48+ # Store current working directory
49+ CURRENT_DIR=$(pwd)
50+
4851 # Fetch main branch
4952 git fetch origin main:main
5053
5154 # Checkout main branch in a temporary directory
52- git worktree add .. /main-branch main
55+ git worktree add /tmp /main-branch main
5356
5457 # Run tests on main branch to get coverage
55- cd .. /main-branch
58+ cd /tmp /main-branch
5659 go test -coverprofile=main-coverage.out -covermode=atomic ./... > /dev/null 2>&1 || echo "Main branch tests failed"
5760
5861 if [ -f main-coverage.out ]; then
5962 MAIN_COVERAGE=$(go tool cover -func=main-coverage.out | grep total | awk '{print $3}' || echo "0.0%")
6063 echo "main-coverage=$MAIN_COVERAGE" >> $GITHUB_OUTPUT
6164 echo "Main branch coverage: $MAIN_COVERAGE"
6265
63- # Copy main coverage file back to workspace
64- cp main-coverage.out ../workspace/ main-coverage.out
66+ # Copy main coverage file back to current directory
67+ cp main-coverage.out "$CURRENT_DIR/ main-coverage.out"
6568 else
6669 echo "main-coverage=0.0%" >> $GITHUB_OUTPUT
6770 echo "Could not get main branch coverage"
6871 fi
6972
7073 # Return to original directory
71- cd ../workspace
74+ cd "$CURRENT_DIR"
75+
76+ # Clean up worktree
77+ git worktree remove /tmp/main-branch
7278
7379 - name : Generate coverage summary
7480 id : coverage-summary
You can’t perform that action at this time.
0 commit comments