Skip to content

Comments

Add Airflow 3 ruff checks to upgrade-test command#1821

Merged
jeremybeard merged 3 commits intomainfrom
ruff-upgrade-test
Mar 31, 2025
Merged

Add Airflow 3 ruff checks to upgrade-test command#1821
jeremybeard merged 3 commits intomainfrom
ruff-upgrade-test

Conversation

@jeremybeard
Copy link
Contributor

Description

This change adds support to the astro dev upgrade-test command so that when upgrading to Airflow 3 (including within Airflow 3 releases) the command will run ruff checks to validate the DAGs in the dags directory of the project.

The ruff checks are run as a container using the ghcr.io/astral-sh/ruff:latest image. The Airflow 3 rules are available as part of ruff itself. As new rules are added to ruff they will be automatically available to the CLI via the latest tag reference.

🧪 Functional Testing

  • Unit tests added/updated

📸 Screenshots

ruff check failures:
Screenshot 2025-03-28 at 2 28 47 PM

ruff check pass:
Screenshot 2025-03-28 at 2 29 27 PM

Not run for Airflow 2:
Screenshot 2025-03-28 at 2 30 06 PM

📋 Checklist

  • Rebased from the main (or release if patching) branch (before testing)
  • Ran make test before taking out of draft
  • Ran make lint before taking out of draft
  • Added/updated applicable tests
  • Tested against Astro-API (if necessary).
  • Tested against Houston-API and Astronomer (if necessary).
  • Communicated to/tagged owners of respective clients potentially impacted by these changes.
  • Updated any related documentation

Copy link
Contributor

@neel-astro neel-astro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some minor questions, but looking good otherwise

}

imageHandler := DockerImageInit(ImageName(imageName, "latest"))
ruffImageHandler := DockerImageInit("ghcr.io/astral-sh/ruff:latest")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should this be configurable, to have a backdoor when astral-sh makes any changes, it would sort of make us changes all of our active CLI releases? not a big deal; it's just a thought.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes good idea, added the ruff.image config for this.

}

if ruffTest {
ruffTestPassed, err := d.ruffTest(testHomeDirectory)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Should we add a section header, like
============= Running ruff tests on the dags folder =============
or something along those lines?

As of now, it is slightly confusing with the previous line stating that "No errors detected in your DAGs" and then if there are errors in the ruff test we start with the stacktrace.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another good call. I added some header lines to make it clearer what is going on.

@jeremybeard jeremybeard merged commit 4294119 into main Mar 31, 2025
5 checks passed
@jeremybeard jeremybeard deleted the ruff-upgrade-test branch March 31, 2025 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants