Update ci-cd.yml to fetch master branch#545
Conversation
Needed for aiosmtpd.qa.test_0packaging.TestVersion.test_ge_master, it runs a "git show" command which will fail if the master branch does not exist locally
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #545 +/- ##
==========================================
- Coverage 97.86% 97.78% -0.08%
==========================================
Files 23 23
Lines 5707 5697 -10
Branches 764 764
==========================================
- Hits 5585 5571 -14
- Misses 76 80 +4
Partials 46 46 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
A little more background on this. The # noinspection PyUnboundLocalVariable
def test_ge_master(
self, aiosmtpd_version: version.Version, capsys: pytest.CaptureFixture
):
"""Ensure version is monotonically increasing"""
reference = "master:aiosmtpd/__init__.py"
cmd = f"git show {reference}".split()
try:
with capsys.disabled():
master_smtp = subprocess.check_output(cmd).decode() # nosec
except subprocess.CalledProcessError:
pytest.skip("Skipping due to git error")
try:
m = next(m for ln in master_smtp.splitlines() if (m := RE_DUNDERVER.match(ln)))
except StopIteration:
pytest.fail(f"Cannot find __version__ in {reference}!")
master_ver = version.parse(m.group("ver"))
assert aiosmtpd_version >= master_ver, "Version number cannot be < master's"As I understand it, it grabs When GHA runs tests on a pull request, only the pull request's branch is available. So when I'm not sure if it makes sense to check if the version increases monotonically in PRs. If it does, this PR fixes the problem: it adds an extra command in ci-cd.yml to fetch the master branch. If it does not, then this PR can be discarded. The reason I looked into this in the first place: I was looking into why test coverage was decreasing in a pull request I was working on. The coverage report showed regressions in a few places. One of them was this test. If the try:
m = next(m for ln in master_smtp.splitlines() if (m := RE_DUNDERVER.match(ln)))
except StopIteration:
pytest.fail(f"Cannot find __version__ in {reference}!")
master_ver = version.parse(m.group("ver"))
assert aiosmtpd_version >= master_ver, "Version number cannot be < master's" |
What do these changes do?
This change hopefully fixes test
aiosmtpd.qa.test_0packaging.TestVersion.test_ge_master.The test runs
git show master:aiosmtpd/__init__.pycommand, and the commandfails if the master branch does not exist locally.
Are there changes in behavior for the user?
No, they just fixes CI to not skip a test.