From 38b06bf3a718d9dfd53cecbcd370c71d034c0cf5 Mon Sep 17 00:00:00 2001 From: centdix <40307056+centdix@users.noreply.github.com> Date: Wed, 18 Jun 2025 13:08:59 +0200 Subject: [PATCH] internal: add /updatesqlx as git command (#5969) * add flow to update sqlx * archive aider * fix * add comments --- ....yaml => aider-after-review.yaml.archived} | 0 ...r-common.yml => aider-common.yml.archived} | 0 ...rnal.yaml => aider-external.yaml.archived} | 0 .../{aider.yaml => aider.yaml.archived} | 0 .github/workflows/update-sqlx.yaml | 98 +++++++++++++++++++ backend/update_sqlx.sh | 18 +++- 6 files changed, 114 insertions(+), 2 deletions(-) rename .github/workflows/{aider-after-review.yaml => aider-after-review.yaml.archived} (100%) rename .github/workflows/{aider-common.yml => aider-common.yml.archived} (100%) rename .github/workflows/{aider-external.yaml => aider-external.yaml.archived} (100%) rename .github/workflows/{aider.yaml => aider.yaml.archived} (100%) create mode 100644 .github/workflows/update-sqlx.yaml diff --git a/.github/workflows/aider-after-review.yaml b/.github/workflows/aider-after-review.yaml.archived similarity index 100% rename from .github/workflows/aider-after-review.yaml rename to .github/workflows/aider-after-review.yaml.archived diff --git a/.github/workflows/aider-common.yml b/.github/workflows/aider-common.yml.archived similarity index 100% rename from .github/workflows/aider-common.yml rename to .github/workflows/aider-common.yml.archived diff --git a/.github/workflows/aider-external.yaml b/.github/workflows/aider-external.yaml.archived similarity index 100% rename from .github/workflows/aider-external.yaml rename to .github/workflows/aider-external.yaml.archived diff --git a/.github/workflows/aider.yaml b/.github/workflows/aider.yaml.archived similarity index 100% rename from .github/workflows/aider.yaml rename to .github/workflows/aider.yaml.archived diff --git a/.github/workflows/update-sqlx.yaml b/.github/workflows/update-sqlx.yaml new file mode 100644 index 0000000000..ddb9bb9e67 --- /dev/null +++ b/.github/workflows/update-sqlx.yaml @@ -0,0 +1,98 @@ +name: Update SQLx + +on: + issue_comment: + types: [created] + +jobs: + update-sqlx: + if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/update-sqlx') + runs-on: ubicloud-standard-8 + permissions: + contents: write + pull-requests: write + issues: write + + services: + postgres: + image: postgres:14 + env: + POSTGRES_PASSWORD: postgres + POSTGRES_USER: postgres + POSTGRES_DB: windmill + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - name: Comment on PR - Starting + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'Starting sqlx update...' + }) + + - name: Checkout repository + uses: actions/checkout@v3 + with: + ref: ${{ github.event.issue.pull_request.head.ref }} + fetch-depth: 0 + + - name: Checkout windmill-ee-private + uses: actions/checkout@v3 + with: + repository: windmill-labs/windmill-ee-private + path: windmill-ee-private + token: ${{ secrets.EE_PRIVATE_TOKEN }} + + - name: Install xmlsec build-time deps + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends \ + pkg-config libxml2-dev libssl-dev \ + xmlsec1 libxmlsec1-dev libxmlsec1-openssl + + - name: Run update-sqlx script + env: + DATABASE_URL: postgres://postgres:postgres@localhost:5432/windmill + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + PR_NUMBER=${{ github.event.issue.number }} + BRANCH_NAME=$(gh pr view $PR_NUMBER --json headRefName --jq .headRefName) + echo "Checking out PR branch: $BRANCH_NAME" + git checkout $BRANCH_NAME + cd backend + cargo install sqlx-cli + sqlx migrate run + ./update_sqlx.sh --dir ./windmill-ee-private + # Pass the branch name to the next step + echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV + + - name: Commit changes if any + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add backend/.sqlx + git commit -m "Update SQLx metadata" + git push origin ${{ env.BRANCH_NAME }} + + - name: Comment on PR - Completed + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'Successfully ran sqlx update' + }) diff --git a/backend/update_sqlx.sh b/backend/update_sqlx.sh index 09824d9e24..6e64115ce0 100755 --- a/backend/update_sqlx.sh +++ b/backend/update_sqlx.sh @@ -1,4 +1,18 @@ -./substitute_ee_code.sh --dir ../windmill-ee-private +#!/bin/bash + +# Default directory +EE_DIR="../windmill-ee-private" + +# Parse arguments +while [[ "$#" -gt 0 ]]; do + case $1 in + --dir) EE_DIR="$2"; shift ;; + *) echo "Unknown parameter: $1"; exit 1 ;; + esac + shift +done + +./substitute_ee_code.sh --dir "$EE_DIR" # Check if running on macOS if [[ "$(uname)" == "Darwin" ]]; then @@ -18,4 +32,4 @@ if [[ "$(uname)" == "Darwin" ]]; then sed -i '' 's/^#samael = { version="0.0.14", features = \["xmlsec"\] }/samael = { version="0.0.14", features = ["xmlsec"] }/' Cargo.toml # Comment out the git-based samael dependency sed -i '' 's/^\(samael = { git="https:\/\/github.com\/njaremko\/samael", rev="464d015e3ae393e4b5dd00b4d6baa1b617de0dd6", features = \["xmlsec"\] }\)/# \1/' Cargo.toml -fi +fi \ No newline at end of file