feat(postgresql): add bare_label_keyword support for column aliases w… #115
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Tests | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| detect-changes: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| any_changed: ${{ steps.set-matrix.outputs.any_changed }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get changed files | |
| id: changed-files | |
| run: | | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| echo "changed_files<<EOF" >> $GITHUB_OUTPUT | |
| git diff --name-only origin/${{ github.base_ref }}..HEAD >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| else | |
| echo "changed_files<<EOF" >> $GITHUB_OUTPUT | |
| git diff --name-only HEAD~1..HEAD >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Set matrix for changed parsers | |
| id: set-matrix | |
| run: | | |
| # List of all available parsers | |
| ALL_PARSERS="redshift postgresql cql snowflake tsql doris starrocks trino plsql googlesql mysql partiql tidb mariadb cosmosdb" | |
| # Add more parsers here as they are added to the repository | |
| # ALL_PARSERS="redshift mysql postgresql" | |
| CHANGED_FILES="${{ steps.changed-files.outputs.changed_files }}" | |
| CHANGED_PARSERS="" | |
| for parser in $ALL_PARSERS; do | |
| if echo "$CHANGED_FILES" | grep -q "^$parser/"; then | |
| if [ -z "$CHANGED_PARSERS" ]; then | |
| CHANGED_PARSERS="\"$parser\"" | |
| else | |
| CHANGED_PARSERS="$CHANGED_PARSERS,\"$parser\"" | |
| fi | |
| fi | |
| done | |
| if [ -n "$CHANGED_PARSERS" ]; then | |
| echo "matrix={\"parser\":[$CHANGED_PARSERS]}" >> $GITHUB_OUTPUT | |
| echo "any_changed=true" >> $GITHUB_OUTPUT | |
| echo "Changed parsers: $CHANGED_PARSERS" | |
| else | |
| echo "matrix={\"parser\":[]}" >> $GITHUB_OUTPUT | |
| echo "any_changed=false" >> $GITHUB_OUTPUT | |
| echo "No parser changes detected" | |
| fi | |
| go-mod-tidy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| cache-dependency-path: go.sum | |
| - name: Verify go mod tidy | |
| run: | | |
| go mod tidy | |
| git diff --exit-code -- go.mod go.sum | |
| go-tests: | |
| needs: detect-changes | |
| if: needs.detect-changes.outputs.any_changed == 'true' | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: ${{ fromJSON(needs.detect-changes.outputs.matrix) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| cache-dependency-path: go.sum | |
| - name: Run all tests | |
| working-directory: ${{ matrix.parser }} | |
| run: go test -p=8 -timeout 30m -ldflags "-w -s" -v ./... | tee test.log; exit ${PIPESTATUS[0]} | |
| - name: Pretty print tests running time | |
| working-directory: ${{ matrix.parser }} | |
| # grep: filter out lines like "--- PASS: Test (15.04s)" | |
| # sed: remove unnecessary characters | |
| # awk: re-format lines to "PASS: Test (15.04s)" | |
| # sort: cut into columns by delimiter ' ' (single space) and sort by column 3 (test time in seconds) as numeric type in reverse order (largest comes first) | |
| # awk: accumulate sum by test time in seconds | |
| run: grep --color=never -e '--- PASS:' -e '--- FAIL:' test.log | sed 's/[:()]//g' | awk '{print $2,$3,$4}' | sort -t' ' -nk3 -r | awk '{sum += $3; print $1,$2,$3,sum"s"}' | |
| antlr-grammar-tests: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check for grammar file changes | |
| id: check-grammar-changes | |
| run: | | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}..HEAD) | |
| else | |
| CHANGED_FILES=$(git diff --name-only HEAD~1..HEAD) | |
| fi | |
| # Check if any .g4 files or tools/grammar/ files changed (Go target only) | |
| if echo "$CHANGED_FILES" | grep -E '\.(g4)$|^tools/grammar/'; then | |
| echo "grammar_changed=true" >> $GITHUB_OUTPUT | |
| echo "Grammar files or tools/grammar/ changed, running Go ANTLR tests" | |
| else | |
| echo "grammar_changed=false" >> $GITHUB_OUTPUT | |
| echo "No grammar file changes detected, skipping ANTLR tests" | |
| fi | |
| - uses: actions/setup-go@v5 | |
| if: steps.check-grammar-changes.outputs.grammar_changed == 'true' | |
| with: | |
| go-version-file: go.mod | |
| cache-dependency-path: go.sum | |
| - name: Run Go ANTLR grammar tests | |
| if: steps.check-grammar-changes.outputs.grammar_changed == 'true' | |
| working-directory: tools/grammar | |
| run: go test -p=8 -timeout 30m -ldflags "-w -s" -v ./... | tee test.log; exit ${PIPESTATUS[0]} | |
| - name: Pretty print grammar tests running time | |
| if: steps.check-grammar-changes.outputs.grammar_changed == 'true' | |
| working-directory: tools/grammar | |
| # grep: filter out lines like "--- PASS: Test (15.04s)" | |
| # sed: remove unnecessary characters | |
| # awk: re-format lines to "PASS: Test (15.04s)" | |
| # sort: cut into columns by delimiter ' ' (single space) and sort by column 3 (test time in seconds) as numeric type in reverse order (largest comes first) | |
| # awk: accumulate sum by test time in seconds | |
| run: grep --color=never -e '--- PASS:' -e '--- FAIL:' test.log | sed 's/[:()]//g' | awk '{print $2,$3,$4}' | sort -t' ' -nk3 -r | awk '{sum += $3; print $1,$2,$3,sum"s"}' | |
| all-tests-passed: | |
| runs-on: ubuntu-latest | |
| # This job needs detect-changes, go-tests, and antlr-grammar-tests | |
| needs: [detect-changes, go-tests, antlr-grammar-tests] | |
| # This condition is key: | |
| # - Run if no files were changed (the 'go-tests' job was skipped). | |
| # - Or run if the 'go-tests' job (the whole matrix) succeeded. | |
| # - And run if antlr-grammar-tests succeeded or was skipped. | |
| if: success() || needs.detect-changes.outputs.any_changed == 'false' | |
| steps: | |
| - name: Report overall status | |
| run: echo "All required tests passed or no changes were detected." |