From 3d042ba127a736f1b74f96e2b2eba66986553e2c Mon Sep 17 00:00:00 2001 From: avivkeller Date: Wed, 30 Jul 2025 13:16:51 -0400 Subject: [PATCH] chore(ci): harden and organize --- .github/workflows/ci.yaml | 28 ------------------------ .github/workflows/dune-sync.yaml | 27 +++++++++++++++++++++++ .github/workflows/pull-request.yaml | 34 ++++++++++++++++------------- 3 files changed, 46 insertions(+), 43 deletions(-) delete mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/dune-sync.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index 89dc27f7..00000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: Sync to Dune -on: - push: - branches: [main] - -jobs: - update-queries: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Necessary to get a complete history for diff - - - name: Get list of changed files in a specific directory - id: get-changed-files - run: | - CHANGED_FILES=$(git diff \ - --name-only --diff-filter=d ${{ github.event.before }} ${{ github.sha }} \ - -- *.sql | paste -sd "," -) - echo "CHANGED_FILES=$CHANGED_FILES" >> $GITHUB_ENV - echo "changed_files=$CHANGED_FILES" >> $GITHUB_OUTPUT - - - name: Update Queries - uses: bh2smith/dune-update@v0.1.0 - with: - changedQueries: ${{ steps.get-changed-files.outputs.changed_files }} - duneApiKey: ${{ secrets.DUNE_API_KEY }} diff --git a/.github/workflows/dune-sync.yaml b/.github/workflows/dune-sync.yaml new file mode 100644 index 00000000..6c49cd0b --- /dev/null +++ b/.github/workflows/dune-sync.yaml @@ -0,0 +1,27 @@ +name: Sync to Dune +on: + push: + branches: [main] + +jobs: + update-queries: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Get changed SQL files + id: changed-files + uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5 + with: + files: | + **/*.sql + + - name: Update Queries + uses: bh2smith/dune-update@f22f6e55197fc8bd7b03e60b270229b58cca6f15 # v0.1.4 + with: + changedQueries: ${{ steps.changed-files.outputs.changed_files }} + duneApiKey: ${{ secrets.DUNE_API_KEY }} diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index 07d1e2d2..5e56200c 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -8,33 +8,37 @@ jobs: name: SQLFluff runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: - python-version: "3.9" + persist-credentials: false + + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 + with: + python-version: "3.12" + - name: Install SQLFluff run: pip install sqlfluff + - name: Get changed SQL files id: changed-files - uses: tj-actions/changed-files@v44 + uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5 with: files: | **/*.sql + - name: Run SQLFluff on changed files if: steps.changed-files.outputs.any_changed == 'true' run: | - echo "Changed files: ${{ steps.changed-files.outputs.all_changed_files }}" - sqlfluff lint ${{ steps.changed-files.outputs.all_changed_files }} + echo "Changed files: $ALL_CHANGED_FILES" + sqlfluff lint $ALL_CHANGED_FILES + env: + ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} + - name: Skip SQLFluff (no SQL files changed) if: steps.changed-files.outputs.any_changed == 'false' - run: echo "No SQL files changed, skipping SQLFluff" - nitpicker: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.sha }} - - uses: ethanis/nitpicker@v1 + run: echo "No SQL files changed, skipping SQLFluff" + + - uses: ethanis/nitpicker@e891622bbd9a6ec97a473bcfacfca7332caf2862 # v1.7 with: nitpicks: ".github/nitpicks.yml" - token: "${{ secrets.GITHUB_TOKEN }}" + token: "${{ secrets.GITHUB_TOKEN }}"