Skip to content

Commit

Permalink
Fix Integration Workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Hydrocharged committed Aug 28, 2024
1 parent 3bf086d commit 85ae492
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 24 deletions.
54 changes: 37 additions & 17 deletions .github/workflows/dependency-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,41 @@ on:
pull_request:
types: [opened, synchronize, reopened]
issue_comment:
types: [created, edited]
types: [created, edited, deleted]

jobs:
test-integration:
if: github.event_name == 'issue_comment' && github.event.issue.pull_request != '' || github.event_name == 'pull_request'
runs-on: ubuntu-latest

steps:
- name: Checkout go-mysql-server
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Merge main into PR
id: merge_main
run: |
git fetch -all
git merge main --no-commit --no-ff
if [ $? -ne 0 ]; then
echo "Skipping the remainder of the workflow due to a merge conflict."
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "Merge performed successfully, continuing workflow."
echo "skip=false" >> $GITHUB_OUTPUT
fi
- name: Check for a Dolt PR link
id: check_dolt_pr
if: steps.merge_main.outputs.skip == 'false'
run: |
COMMENTS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments)
echo "$COMMENTS"
COMMENT_EXISTS=$(echo "$COMMENTS" | jq -r '.[] | select(.body | contains("github.com/dolthub/dolt/pull/"))')
echo "$COMMENT_EXISTS"
if [ -n "$COMMENT_EXISTS" ]; then
echo "comment_exists=true" >> $GITHUB_OUTPUT
else
Expand All @@ -26,54 +47,53 @@ jobs:
- name: Check for a DoltgreSQL PR link
id: check_doltgresql_pr
if: steps.merge_main.outputs.skip == 'false'
run: |
COMMENTS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments)
echo "$COMMENTS"
COMMENT_EXISTS=$(echo "$COMMENTS" | jq -r '.[] | select(.body | contains("github.com/dolthub/doltgresql/pull/"))')
echo "$COMMENT_EXISTS"
if [ -n "$COMMENT_EXISTS" ]; then
echo "comment_exists=true" >> $GITHUB_OUTPUT
else
echo "comment_exists=false" >> $GITHUB_OUTPUT
fi
- name: Checkout go-mysql-server
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Install Go
uses: actions/setup-go@v5
if: steps.merge_main.outputs.skip == 'false'
with:
go-version-file: go.mod

- name: Clone Dolt
if: steps.check_dolt_pr.outputs.comment_exists == 'false'
if: steps.merge_main.outputs.skip == 'false' && steps.check_dolt_pr.outputs.comment_exists == 'false'
run: git clone https://github.com/dolthub/dolt.git

- name: Clone DoltgreSQL repository
if: steps.check_doltgresql_pr.outputs.comment_exists == 'false'
if: steps.merge_main.outputs.skip == 'false' && steps.check_doltgresql_pr.outputs.comment_exists == 'false'
run: git clone https://github.com/dolthub/doltgresql.git

- name: Build DoltgreSQL's parser
if: steps.check_doltgresql_pr.outputs.comment_exists == 'false'
if: steps.merge_main.outputs.skip == 'false' && steps.check_doltgresql_pr.outputs.comment_exists == 'false'
run: |
cd doltgresql
./postgres/parser/build.sh
- name: Test Dolt against main
id: test_dolt_main
if: steps.check_dolt_pr.outputs.comment_exists == 'false'
if: steps.merge_main.outputs.skip == 'false' && steps.check_dolt_pr.outputs.comment_exists == 'false'
continue-on-error: true
run: |
cd dolt/go
go get github.com/dolthub/go-mysql-server@main
go mod tidy
cd libraries/doltcore/sqle/enginetest
go test ./... --count=1
go test ./... --count=1 -skip TestDoltServerRunningUnixSocket
- name: Test DoltgreSQL against main
id: test_doltgresql_main
if: steps.check_doltgresql_pr.outputs.comment_exists == 'false'
if: steps.merge_main.outputs.skip == 'false' && steps.check_doltgresql_pr.outputs.comment_exists == 'false'
continue-on-error: true
run: |
cd doltgresql
Expand All @@ -83,21 +103,21 @@ jobs:
go test ./... --count=1 -skip Replication
- name: Test Dolt against PR
if: steps.check_dolt_pr.outputs.comment_exists == 'false' && steps.test_dolt_main.outcome == 'success'
if: steps.merge_main.outputs.skip == 'false' && steps.check_dolt_pr.outputs.comment_exists == 'false' && steps.test_dolt_main.outcome == 'success'
run: |
cd dolt/go
git reset --hard
go get github.com/${{ github.event.pull_request.head.repo.full_name }}@${{ github.event.pull_request.head.sha }}
go mod edit -replace github.com/dolthub/go-mysql-server=../..
go mod tidy
cd libraries/doltcore/sqle/enginetest
go test ./... --count=1
go test ./... --count=1 -skip TestDoltServerRunningUnixSocket
- name: Test DoltgreSQL against PR
if: steps.check_doltgresql_pr.outputs.comment_exists == 'false' && steps.test_doltgresql_main.outcome == 'success'
if: steps.merge_main.outputs.skip == 'false' && steps.check_doltgresql_pr.outputs.comment_exists == 'false' && steps.test_doltgresql_main.outcome == 'success'
run: |
cd doltgresql
git reset --hard
go get github.com/${{ github.event.pull_request.head.repo.full_name }}@${{ github.event.pull_request.head.sha }}
go mod edit -replace github.com/dolthub/go-mysql-server=..
go mod tidy
cd testing/go
go test ./... --count=1 -skip Replication
4 changes: 2 additions & 2 deletions sql/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ type Builder struct {
// NewBuilder creates a new Builder from a specific catalog.
// This builder allow us add custom Rules and modify some internal properties.
func NewBuilder(pro sql.DatabaseProvider) *Builder {
allBeforeDefault := make([]Rule, len(OnceBeforeDefault)+len(AlwaysBeforeDefault))
allBeforeDefault := make([]Rule, len(OnceBeforeDefault)+len(AlwaysBeforeDefault2))
copy(allBeforeDefault, OnceBeforeDefault)
copy(allBeforeDefault[len(OnceBeforeDefault):], AlwaysBeforeDefault)
copy(allBeforeDefault[len(OnceBeforeDefault):], AlwaysBeforeDefault2)
return &Builder{
provider: pro,
onceBeforeRules: allBeforeDefault,
Expand Down
6 changes: 3 additions & 3 deletions sql/analyzer/node_batches.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func getBatchesForNode(n sql.Node, orig []*Batch) ([]*Batch, bool) {
{
Desc: "alwaysBeforeDefault",
Iterations: 1,
Rules: AlwaysBeforeDefault,
Rules: AlwaysBeforeDefault2,
},
{
Desc: "simpleInsert",
Expand Down Expand Up @@ -56,7 +56,7 @@ func getBatchesForNode(n sql.Node, orig []*Batch) ([]*Batch, bool) {
{
Desc: "alwaysBeforeDefault",
Iterations: 1,
Rules: AlwaysBeforeDefault,
Rules: AlwaysBeforeDefault2,
},
{
Desc: "simpleUpdate",
Expand Down Expand Up @@ -101,7 +101,7 @@ func getBatchesForNode(n sql.Node, orig []*Batch) ([]*Batch, bool) {
{
Desc: "alwaysBeforeDefault",
Iterations: 1,
Rules: AlwaysBeforeDefault,
Rules: AlwaysBeforeDefault2,
},
{
Desc: "simpleDelete",
Expand Down
4 changes: 2 additions & 2 deletions sql/analyzer/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ var OnceBeforeDefault = []Rule{
{hoistOutOfScopeFiltersId, hoistOutOfScopeFilters},
}

// AlwaysBeforeDefault contains the rules to be applied just once before the
// AlwaysBeforeDefault2 contains the rules to be applied just once before the
// DefaultRules. These are an extension of the OnceBeforeDefault rules that
// will always apply to nodes, unlike the OnceBeforeDefault rules that may
// be excluded depending on the node. This is only used by integrators.
var AlwaysBeforeDefault []Rule
var AlwaysBeforeDefault2 []Rule

// DefaultRules to apply when analyzing nodes.
var DefaultRules = []Rule{
Expand Down

0 comments on commit 85ae492

Please sign in to comment.