Skip to content

Commit

Permalink
Use uv in CI (#1013)
Browse files Browse the repository at this point in the history
The CI takes a really long time to run sometimes:

<img width="1390" alt="image"
src="https://github.com/astronomer/astronomer-cosmos/assets/31971762/87d33704-6033-49ff-a7b0-aa91af1737cc">

Seems to run a a little bit faster (shaves about 30 seconds off each run), but Hatch (not uv) is still getting stuck on resolving the Airflow 2.7 dependencies.
  • Loading branch information
dwreeves authored Jun 10, 2024
1 parent c0c033d commit fbe6ff1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ jobs:

- name: Install packages and dependencies
run: |
python -m pip install hatch
python -m pip install uv
uv pip install --system hatch
hatch -e tests.py${{ matrix.python-version }}-${{ matrix.airflow-version }} run pip freeze
- name: Test Cosmos against Airflow ${{ matrix.airflow-version }} and Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -129,7 +130,8 @@ jobs:

- name: Install packages and dependencies
run: |
python -m pip install hatch
python -m pip install uv
uv pip install --system hatch
hatch -e tests.py${{ matrix.python-version }}-${{ matrix.airflow-version }} run pip freeze
- name: Test Cosmos against Airflow ${{ matrix.airflow-version }} and Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -198,7 +200,8 @@ jobs:

- name: Install packages and dependencies
run: |
python -m pip install hatch
python -m pip install uv
uv pip install --system hatch
hatch -e tests.py${{ matrix.python-version }}-${{ matrix.airflow-version }} run pip freeze
- name: Test Cosmos against Airflow ${{ matrix.airflow-version }} and Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -259,7 +262,8 @@ jobs:

- name: Install packages and dependencies
run: |
python -m pip install hatch
python -m pip install uv
uv pip install --system hatch
hatch -e tests.py${{ matrix.python-version }}-${{ matrix.airflow-version }} run pip freeze
- name: Test Cosmos against Airflow ${{ matrix.airflow-version }} and Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -332,7 +336,8 @@ jobs:

- name: Install packages and dependencies
run: |
python -m pip install hatch
python -m pip install uv
uv pip install --system hatch
hatch -e tests.py${{ matrix.python-version }}-${{ matrix.airflow-version }} run pip freeze
- name: Test Cosmos against Airflow ${{ matrix.airflow-version }}, Python ${{ matrix.python-version }} and dbt 1.5.4
Expand Down Expand Up @@ -404,7 +409,8 @@ jobs:

- name: Install packages and dependencies
run: |
python -m pip install hatch
python -m pip install uv
uv pip install --system hatch
hatch -e tests.py${{ matrix.python-version }}-${{ matrix.airflow-version }} run pip freeze
- name: Run performance tests against against Airflow ${{ matrix.airflow-version }} and Python ${{ matrix.python-version }}
Expand Down
15 changes: 13 additions & 2 deletions scripts/test/pre-install-airflow.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,23 @@
AIRFLOW_VERSION="$1"
PYTHON_VERSION="$2"

# Use this to set the appropriate Python environment in Github Actions,
# while also not assuming --system when running locally.
if [ "$GITHUB_ACTIONS" = "true" ] && [ -z "${VIRTUAL_ENV}" ]; then
py_path=$(which python)
virtual_env_dir=$(dirname "$(dirname "$py_path")")
export VIRTUAL_ENV="$virtual_env_dir"
fi

echo "${VIRTUAL_ENV}"

CONSTRAINT_URL="https://raw.githubusercontent.com/apache/airflow/constraints-$AIRFLOW_VERSION.0/constraints-$PYTHON_VERSION.txt"
curl -sSL $CONSTRAINT_URL -o /tmp/constraint.txt
# Workaround to remove PyYAML constraint that will work on both Linux and MacOS
sed '/PyYAML==/d' /tmp/constraint.txt > /tmp/constraint.txt.tmp
mv /tmp/constraint.txt.tmp /tmp/constraint.txt
# Install Airflow with constraints
pip install apache-airflow==$AIRFLOW_VERSION --constraint /tmp/constraint.txt
pip install pydantic --constraint /tmp/constraint.txt
pip install uv
uv pip install "apache-airflow==$AIRFLOW_VERSION" --constraint /tmp/constraint.txt
uv pip install pydantic --constraint /tmp/constraint.txt
rm /tmp/constraint.txt

0 comments on commit fbe6ff1

Please sign in to comment.