agents/docs/git-and-ci.md
#NNNN to reference GitHub issuesFix loader cache invalidation on module reload
When modules are reloaded, the loader cache was not properly
invalidated, causing stale references. Clear the cache dict
on reload to ensure fresh module imports.
Fixes #12345
Fixed some bugs
Co-Authored-By: Claude <[email protected]>
Why this is bad:
# Find PR by branch name
gh pr list --repo saltstack/salt --head <BRANCH-NAME> --limit 5
# Check PR status
gh pr view <PR-NUMBER> --repo saltstack/salt
gh pr checks <PR-NUMBER> --repo saltstack/salt
# Watch CI run
gh run watch <RUN-ID> --repo saltstack/salt
master (not main)3006.x, 3007.x, etc.merge/3007.x/master-YY-MM-DDWhen CI tests fail, you can reproduce the exact failure locally using containers.
ptscripts installed (pip install python-tools-scripts)First, get the CI artifacts from the failed run:
./venv310/bin/python -m ptscripts ci download-artifacts --run-id <RUN-ID>
The run ID can be found in the GitHub Actions URL or via gh run list.
Create a container using the same image as CI:
./venv310/bin/python -m ptscripts container create <IMAGE> --name <NAME>
docker start <NAME>
Example container images:
ghcr.io/saltstack/salt-ci-containers/testing:debian-11ghcr.io/saltstack/salt-ci-containers/testing:ubuntu-22.04ghcr.io/saltstack/salt-ci-containers/testing:ubuntu-24.04ghcr.io/saltstack/salt-ci-containers/testing:rockylinux-8ghcr.io/saltstack/salt-ci-containers/testing:rockylinux-9ghcr.io/saltstack/salt-ci-containers/testing:fedora-40ghcr.io/saltstack/salt-ci-containers/testing:amazonlinux-2ghcr.io/saltstack/salt-ci-containers/testing:amazonlinux-2023ghcr.io/saltstack/salt-ci-containers/testing:photonos-3ghcr.io/saltstack/salt-ci-containers/testing:photonos-4ghcr.io/saltstack/salt-ci-containers/testing:photonos-5# Decompress dependencies
docker exec <NAME> python3 -m nox -e decompress-dependencies -- linux x86_64
# Create relenv toolchain symlink (Python 3.11+ only)
docker exec <NAME> bash -c "mkdir -p /root/.local/relenv && ln -sf /root/.cache/relenv/toolchains /root/.local/relenv/toolchain"
docker exec <NAME> python3 -m nox -e ci-test-onedir -- <TEST-PATH> --run-slow -x -v
Examples:
# Run specific test file
docker exec mycontainer python3 -m nox -e ci-test-onedir -- tests/pytests/unit/modules/test_pkg.py --run-slow -x -v
# Run specific test function
docker exec mycontainer python3 -m nox -e ci-test-onedir -- tests/pytests/unit/modules/test_pkg.py::test_install --run-slow -x -v
# Run with pattern matching
docker exec mycontainer python3 -m nox -e ci-test-onedir -- tests/pytests/unit/ -k test_systemd --run-slow -x -v
If you need to debug interactively:
# Shell into container
docker exec -it <NAME> bash
# Inside container, activate environment and run tests
cd /salt
python3 -m nox -e ci-test-onedir -- tests/pytests/unit/test_foo.py -x -v
# Stop and remove container
docker stop <NAME>
docker rm <NAME>
# Clean artifacts
rm -rf artifacts/ nox-*.zip nox.*.tar.*
When testing in containers, be aware:
salt/ source are visible immediately (mounted volume)docker exec <NAME> cp /salt/salt/modules/foo.py \
/salt/artifacts/salt/lib/python3.11/site-packages/salt/modules/
Always clean before downloading new CI artifacts:
rm -rf artifacts/ nox-*.zip nox.*.tar.*
Old artifacts can cause confusing test failures.
Possible causes:
If dependency decompression fails:
For Python 3.11+ containers, you must create the symlink:
docker exec <NAME> bash -c "mkdir -p /root/.local/relenv && ln -sf /root/.cache/relenv/toolchains /root/.local/relenv/toolchain"
This is a known path mismatch between relenv versions.
The agents/mcp/salt_test MCP server provides tools for discovering CI failures:
ci_pr_failures - Get all failing tests from a PRci_run_failures - Get failures from specific CI runci_failure_summary - Get summary of recent failuresSee agents/mcp/salt_test/README.md for details.