Skip to content

Commit 0fa07ed

Browse files
committed
update snapshots in workflow
1 parent 24f6348 commit 0fa07ed

1 file changed

Lines changed: 52 additions & 1 deletion

File tree

.github/workflows/integration-test.yml

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ name: Integration Tests
33
on:
44
pull_request:
55
workflow_dispatch:
6+
inputs:
7+
update_snapshots:
8+
description: 'Update snapshots?'
9+
required: false
10+
type: boolean
11+
default: false
612

713
jobs:
814
integration-test:
@@ -40,4 +46,49 @@ jobs:
4046
ls -la tpch_sf1.db
4147
4248
- name: Run integration tests
43-
run: cargo run -p federation-integration-tests -- --nocapture
49+
env:
50+
INSTA_UPDATE: ${{ github.event.inputs.update_snapshots == 'true' && 'always' || '' }}
51+
run: cargo run -p federation-integration-tests -- --nocapture
52+
53+
- name: Install GH CLI
54+
if: github.event.inputs.update_snapshots == 'true'
55+
run: |
56+
(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \
57+
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
58+
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
59+
&& cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
60+
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
61+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
62+
&& sudo apt update \
63+
&& sudo apt install gh -y
64+
65+
- name: Upload benchmark snapshots to branch
66+
if: github.event.inputs.update_snapshots == 'true'
67+
run: |
68+
BRANCH_ID=${{ github.run_id }}
69+
70+
BRANCH_NAME="integration-test-snapshot-update/${BRANCH_ID}"
71+
72+
git config --global user.name 'Datafusion Federation Snapshot Update Bot'
73+
git config --global user.email 'integration-test@datafusion.federation'
74+
git checkout -b ${BRANCH_NAME}
75+
git add '*.snap'
76+
if git diff --cached --quiet; then
77+
echo "No changes to commit"
78+
else
79+
git commit -m "fix: Update datafusion federation integration tests snapshots"
80+
if git ls-remote --exit-code --heads origin ${BRANCH_NAME}; then
81+
git pull --rebase origin ${BRANCH_NAME}
82+
fi
83+
git push origin ${BRANCH_NAME}
84+
85+
PR_URL="$(gh pr list --head "${BRANCH_NAME}" --state open --json url --jq .[].url)"
86+
if [[ -n "${PR_URL}" ]]; then
87+
echo "PR already exists -> ${PR_URL}"
88+
exit 0
89+
else
90+
gh pr create --title "fix: Update integration tests snapshots" --body "Updates some integration tests snapshots" --base trunk --head ${BRANCH_NAME}
91+
fi
92+
fi
93+
env:
94+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)