Skip to content

Added a minimal job to check that tests pass when existing config/cache folders are present - #19740

Merged
pllim merged 7 commits into
astropy:mainfrom
astrofrog:ci-empty-cache-config-test
May 14, 2026
Merged

pllim merged 7 commits into
astropy:mainfrom
astrofrog:ci-empty-cache-config-test

Conversation

@astrofrog

@astrofrog astrofrog commented May 14, 2026 •

Copy link
Copy Markdown
Member

This fails in CI and does pick up the issues discussed offline - I think we should include this in the CI for now at least during all the config/cache refactoring.

  • By checking this box, the PR author has requested that maintainers do NOT use the "Squash and Merge" button. Maintainers should respect this when possible; however, the final decision is at the discretion of the maintainer that merges the PR.

…ache and .astropy/config folders are present
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see instructions for rebase and squash.
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the bot.
  • Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  • Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) before merge.

@astrofrog astrofrog changed the title EXP: Added a minimal job to check that tests pass when existing config/cache folders are present Added a minimal job to check that tests pass when existing config/cache folders are present May 14, 2026
@astrofrog
astrofrog marked this pull request as ready for review May 14, 2026 10:12
@astrofrog
astrofrog requested a review from neutrinoceros as a code owner May 14, 2026 10:12
Comment thread .github/workflows/ci_workflows.yml Outdated
Comment on lines +146 to +147
- ubuntu-latest
- macos-latest

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't expect any difference to show up within UNIX-based systems, but I guess it doesn't hurt to check 2 of them, especially if the job is only temporary.

Comment thread .github/workflows/ci_workflows.yml Outdated
- name: Install astropy with minimal test dependencies
run: python -m pip install -e ".[test]"
- name: Create empty .astropy cache and config directories
run: python -c "from pathlib import Path; [(Path.home() / '.astropy' / d).mkdir(parents=True, exist_ok=True) for d in ('cache', 'config')]"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this written in Python for portability (windows...) ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes exactly

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

cool. Maybe add a comment if you feel like it. Otherwise, LGTM

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

Comment thread .github/workflows/ci_workflows.yml Outdated
with:
python-version: "3.12"
- name: Install astropy with minimal test dependencies
run: python -m pip install -e ".[test]"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

editable mode shouldn't be needed ?

Suggested change
run: python -m pip install -e ".[test]"
run: python -m pip install ".[test]"

Comment thread .github/workflows/ci_workflows.yml Outdated
- name: Create empty .astropy cache and config directories
run: python -c "from pathlib import Path; [(Path.home() / '.astropy' / d).mkdir(parents=True, exist_ok=True) for d in ('cache', 'config')]"
- name: Run tests
run: pytest --pyargs astropy

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

instead of using editable mode, set this env var so the current directory isn't included in sys.path

Suggested change
run: pytest --pyargs astropy
run: pytest --pyargs astropy
env:
PYTHONSAFEPATH: 1

@neutrinoceros

Copy link
Copy Markdown
Contributor

I only took a quick glance at the failures and I think some (maybe most) of them should simply be fixed by enforcing isolation with @pytest.mark.usefixtures("ignore_config_paths_global_state")

@neutrinoceros

Copy link
Copy Markdown
Contributor

(nothing blocking, just nits)

astrofrog added 3 commits May 14, 2026 11:38
The legacy backward-compat fallback in _DirectoryFinder ran
unconditionally, so a leftover ~/.astropy/cache or ~/.astropy/config
directory would override an explicit set_temp_cache/set_temp_config
target or an ASTROPY_CACHE_DIR/ASTROPY_CONFIG_DIR environment variable.
Move the fallback into the default resolution branch so it only applies
when no override or environment variable is in effect.
With a non-editable install, running pytest --pyargs astropy from the
repo root makes pytest collect the source astropy/conftest.py under a
module name that resolves to the installed copy, raising
ImportPathMismatchError. Run from an empty directory instead, mirroring
the tox changedir convention, so only the installed package is used.
@pllim pllim added this to the v8.0.0 milestone May 14, 2026
@astrofrog

Copy link
Copy Markdown
Member Author

@neutrinoceros - this actually implements a proper fix for the issue rather than using the fixtures, as I think there was a real bug. Do you want to review again?

@pllim pllim added no-changelog-entry-needed Affects-dev PRs and issues that do not impact an existing Astropy release backport-v8.0.x on-merge: backport to v8.0.x labels May 14, 2026
@pllim

pllim commented May 14, 2026

Copy link
Copy Markdown
Member

Yay and thank you so much for the fix and tests!

However, I dunno how I feel about a whole new matrix (3 extra jobs) just for this part. Is there no way we can piggy back this config into existing test matrix? We have so many jobs as it is.

@astrofrog

Copy link
Copy Markdown
Member Author

@pllim - I'll double check

Fold the empty .astropy/cache and .astropy/config check into the
existing direct-pytest job in the weekly cron, which avoids adding a
separate multi-platform CI job.
@astrofrog

Copy link
Copy Markdown
Member Author

@pllim - added to weekly cron, I'll let you decide whether it's worth running Extra CI here

@pllim pllim added the Extra CI Run cron CI as part of PR label May 14, 2026
@pllim

This comment was marked as outdated.

@pllim

pllim commented May 14, 2026

Copy link
Copy Markdown
Member

devinfra still failed on rerun, so I am running it off main for comparison: https://github.com/astropy/astropy/actions/runs/25875214616

@pllim pllim left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! devinfra failure is unrelated (#19742). Merging.

@pllim
pllim merged commit cf7e12d into astropy:main May 14, 2026
59 of 61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Affects-dev PRs and issues that do not impact an existing Astropy release backport-v8.0.x on-merge: backport to v8.0.x Extra CI Run cron CI as part of PR no-changelog-entry-needed testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants