Skip to content

Commit 32af31e

Browse files
Ajit Pratap SinghAjit Pratap Singh
authored andcommitted
fix: use GITHUB_WORKSPACE and $HOME for proper path resolution
Critical fixes to enable source builds in CI: - Change detection from GITHUB_ACTION_PATH to GITHUB_WORKSPACE - GITHUB_WORKSPACE contains the repo when using 'uses: ./' - Replace all ~/go/bin/gosqlx with $HOME/go/bin/gosqlx for proper shell expansion - Add mkdir -p $HOME/go/bin to ensure directory exists - Update validation, format, and analyze commands to use $HOME This ensures the action builds from source when testing in the repository instead of installing the published v1.4.0 binary without semicolon support.
1 parent 3b8531b commit 32af31e

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

action.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,12 @@ runs:
9999
shell: bash
100100
run: |
101101
# Check if we're in the GoSQLX repository (for testing)
102-
if [ -f "$GITHUB_ACTION_PATH/../go.mod" ] && grep -q "module github.com/ajitpratap0/GoSQLX" "$GITHUB_ACTION_PATH/../go.mod" 2>/dev/null; then
102+
# When using "uses: ./", GITHUB_WORKSPACE contains the repo
103+
if [ -f "$GITHUB_WORKSPACE/go.mod" ] && grep -q "module github.com/ajitpratap0/GoSQLX" "$GITHUB_WORKSPACE/go.mod" 2>/dev/null; then
103104
echo "Building GoSQLX from source (local repository)..."
104-
cd "$GITHUB_ACTION_PATH/.."
105-
go build -o ~/go/bin/gosqlx ./cmd/gosqlx
105+
cd "$GITHUB_WORKSPACE"
106+
mkdir -p "$HOME/go/bin"
107+
go build -o "$HOME/go/bin/gosqlx" ./cmd/gosqlx
106108
echo "GoSQLX built from source successfully"
107109
else
108110
# Validate gosqlx-version input (semver or 'latest')
@@ -123,17 +125,17 @@ runs:
123125
fi
124126
echo "GoSQLX installed successfully"
125127
fi
126-
~/go/bin/gosqlx --version
128+
"$HOME/go/bin/gosqlx" --version
127129
128130
- name: Verify GoSQLX installation
129131
shell: bash
130132
run: |
131-
if ! command -v ~/go/bin/gosqlx &> /dev/null; then
133+
if ! command -v "$HOME/go/bin/gosqlx" &> /dev/null; then
132134
echo "ERROR: GoSQLX installation failed"
133135
exit 1
134136
fi
135137
echo "GoSQLX version:"
136-
~/go/bin/gosqlx --version
138+
"$HOME/go/bin/gosqlx" --version
137139
138140
- name: Find SQL files
139141
id: find-files
@@ -208,7 +210,7 @@ runs:
208210
echo "::group::SQL Validation"
209211
210212
# Build validation command
211-
CMD="~/go/bin/gosqlx validate"
213+
CMD="$HOME/go/bin/gosqlx validate"
212214
213215
# Add config if provided
214216
if [ -n "${{ inputs.config }}" ]; then
@@ -307,7 +309,7 @@ runs:
307309
while IFS= read -r file; do
308310
echo "Checking format: $file"
309311
310-
if ! ~/go/bin/gosqlx format --check "$file" 2>&1; then
312+
if ! "$HOME/go/bin/gosqlx" format --check "$file" 2>&1; then
311313
echo "✗ Needs formatting: $file"
312314
echo "::warning file=$file::File needs formatting"
313315
NEEDS_FORMATTING=$((NEEDS_FORMATTING + 1))
@@ -348,7 +350,7 @@ runs:
348350
echo "Analyzing: $file"
349351
350352
# Use analyze command for basic linting
351-
if ~/go/bin/gosqlx analyze --all "$file" 2>&1; then
353+
if "$HOME/go/bin/gosqlx" analyze --all "$file" 2>&1; then
352354
echo "✓ No issues: $file"
353355
else
354356
echo "⚠ Issues found: $file"

0 commit comments

Comments
 (0)