diff --git a/.github/actions/install-pre-commit/action.yml b/.github/actions/install-pre-commit/action.yml new file mode 100644 index 0000000000000..c0806bf83ea50 --- /dev/null +++ b/.github/actions/install-pre-commit/action.yml @@ -0,0 +1,88 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +--- +name: 'Install pre-commit' +description: 'Installs pre-commit and related packages' +inputs: + python-version: + description: 'Python version to use' + default: "3.9" + uv-version: + description: 'uv version to use' + default: "0.7.3" # Keep this comment to allow automatic replacement of uv version + pre-commit-version: + description: 'pre-commit version to use' + default: "4.2.0" # Keep this comment to allow automatic replacement of pre-commit version + pre-commit-uv-version: + description: 'pre-commit-uv version to use' + default: "4.1.4" # Keep this comment to allow automatic replacement of pre-commit-uv version +runs: + using: "composite" + steps: + - name: Install pre-commit, uv, and pre-commit-uv + shell: bash + env: + UV_VERSION: ${{inputs.uv-version}} + PRE_COMMIT_VERSION: ${{inputs.pre-commit-version}} + PRE_COMMIT_UV_VERSION: ${{inputs.pre-commit-uv-version}} + run: | + pip install uv==${UV_VERSION} || true + uv tool install pre-commit==${PRE_COMMIT_VERSION} --with uv==${UV_VERSION} \ + --with pre-commit-uv==${PRE_COMMIT_UV_VERSION} + working-directory: ${{ github.workspace }} + # We need to use tar file with archive to restore all the permissions and symlinks + - name: "Delete ~.cache" + run: | + du ~/ --max-depth=2 + echo + echo Deleting ~/.cache + echo + rm -rf ~/.cache + echo + shell: bash + - name: "Restore pre-commit cache" + uses: apache/infrastructure-actions/stash/restore@1c35b5ccf8fba5d4c3fdf25a045ca91aa0cbc468 + with: + key: cache-pre-commit-v4-${{ inputs.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }} + path: /tmp/ + id: restore-pre-commit-cache + - name: "Check if pre-commit cache tarball exists" + shell: bash + run: | + if [ -f /tmp/cache-pre-commit.tar.gz ]; then + echo "✅ Cache tarball found: /tmp/cache-pre-commit.tar.gz" + else + echo "❌ Cache tarball missing. Expected /tmp/cache-pre-commit.tar.gz" + exit 1 + fi + if: steps.restore-pre-commit-cache.outputs.stash-hit == 'true' + - name: "Restore .cache from the tar file" + run: tar -C ~ -xzf /tmp/cache-pre-commit.tar.gz + shell: bash + if: steps.restore-pre-commit-cache.outputs.stash-hit == 'true' + - name: "Show restored files" + run: | + echo "Restored files" + du ~/ --max-depth=2 + echo + shell: bash + if: steps.restore-pre-commit-cache.outputs.stash-hit == 'true' + - name: Install pre-commit hooks + shell: bash + run: pre-commit install-hooks || (cat ~/.cache/pre-commit/pre-commit.log && exit 1) + working-directory: ${{ github.workspace }} diff --git a/.github/workflows/basic-tests.yml b/.github/workflows/basic-tests.yml index 548b9ce5b0fae..42acd83418685 100644 --- a/.github/workflows/basic-tests.yml +++ b/.github/workflows/basic-tests.yml @@ -394,3 +394,54 @@ jobs: run: | breeze release-management generate-issue-content-core \ --limit-pr-count 2 --previous-release 3.0.1 --current-release 3.0.2 --verbose + + test-airflow-standalone: + timeout-minutes: 30 + name: "Test Airflow standalone commands" + runs-on: ${{ fromJSON(inputs.runners) }} + env: + UV_VERSION: ${{inputs.uv-version}} + AIRFLOW_HOME: ~/airflow + FORCE_COLOR: 1 + steps: + - name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )" + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false + - name: "Install uv" + run: curl -LsSf https://astral.sh/uv/${UV_VERSION}/install.sh | sh + - name: "Set up Airflow home directory" + run: | + echo "Setting AIRFLOW_HOME to $AIRFLOW_HOME" + mkdir -p $AIRFLOW_HOME + - name: "Install Airflow from current repo (simulating user installation)" + run: | + uv venv + set -x + uv pip install -e ./airflow-core + - name: "Test airflow standalone command" + run: | + uv run --no-sync airflow standalone 2>&1 | tee airflow_startup.log & + AIRFLOW_PID=$! + + # Wait for ready message till timeout (10 minutes) + for i in {1..600}; do + if ! kill -0 $AIRFLOW_PID 2>/dev/null; then + wait $AIRFLOW_PID + EXIT_CODE=$? + echo "FAILED: Airflow standalone exited with code $EXIT_CODE" + exit $EXIT_CODE + fi + + if grep -q "Airflow is ready" airflow_startup.log; then + echo "SUCCESS: Airflow standalone is ready!" + kill $AIRFLOW_PID + exit 0 + fi + + sleep 1 + done + + echo "FAILED: Airflow standalone did not become ready in time" + kill $AIRFLOW_PID 2>/dev/null || true + exit 1