Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure tracker files never remain after tests or during prod builds #506

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion MCprep_addon/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# If we see any of these IDs in local json files, still treat as a re-install
# but replace the ID with the new one received.
# See example: https://github.com/Moo-Ack-Productions/MCprep/issues/491
INVALID_IDS = ["-Nb8TgbvAoxHrnEe1WFy"]
INVALID_IDS = ["-Nb8TgbvAoxHrnEe1WFy", "-Ng7l5P8EuGMBycEwWPQ"]


# remaining, wrap in safe-importing
Expand Down
4 changes: 4 additions & 0 deletions push_latest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ echo ""
echo "Current status (should be empty!)"
git status


echo "Running tests"
python run_tests.py -a
if [ $? -eq 0 ]; then
Expand Down Expand Up @@ -68,6 +69,9 @@ fi
# Validate and build the release.
# -----------------------------------------------------------------------------

echo "Force remove trcaker files, in case they are left over"
rm MCprep_addon/mcprep_addon_tracker.json
rm mcprep_addon_trackerid.json

echo "Building prod addon..."
bpy-addon-build # No --during-build dev to make it prod.
Expand Down
22 changes: 22 additions & 0 deletions run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ def main():

t1 = time.time()

# Especially ensure tracker files are removed after tests complete.
remove_tracker_files()

output_results()
round_s = round(t1 - t0)
exit_code = 1 if any_failures else 0
Expand Down Expand Up @@ -183,5 +186,24 @@ def output_results():
print(SPACER)


def remove_tracker_files():
"""Ensure local tracker files are NEVER left around after tests."""
git_dir = os.path.dirname(__file__)
jfile = "mcprep_addon_tracker.json"
jpath = os.path.join(git_dir, "MCprep_addon", jfile)
par_jfile = "mcprep_addon_trackerid.json"
par_jpath = os.path.join(git_dir, par_jfile)

has_jpath = os.path.isfile(jpath)
has_par_jpath = os.path.isfile(par_jpath)

if has_jpath:
print("Removing: ", jpath)
os.remove(jpath)
if has_par_jpath:
print("Removing: ", par_jpath)
os.remove(par_jpath)


if __name__ == "__main__":
main()
13 changes: 0 additions & 13 deletions test_files/tracker_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,6 @@ def setUp(self):
def tearDown(self):
tracking.Tracker = self._backup_tracker

def test_no_local_idfile(self):
"""Safety check to ensure we never ship with an id file (again)."""
git_dir = os.path.dirname(os.path.dirname(__file__))
jfile = "mcprep_addon_tracker.json"
jpath = os.path.join(git_dir, jfile)
par_jfile = "mcprep_addon_trackerid.json"
par_jpath = os.path.join(git_dir, par_jfile)

self.assertFalse(
os.path.isfile(jpath), f"Should not have local {jfile}")
self.assertFalse(
os.path.isfile(par_jpath), f"Should not have local {par_jfile}")

def test_track_install_integration(self):
"""Ensure there are no exceptions during install."""
tracking.trackInstalled(background=False)
Expand Down