Skip to content

Commit

Permalink
Ensure tracker files never remain after tests or during prod builds (#…
Browse files Browse the repository at this point in the history
…506)

Two levels of trying to make sure we never ship with tracker code again.
Also removed now-redundant test for checking if tracker id present in git dir
  • Loading branch information
TheDuckCow authored Nov 17, 2023
1 parent 971c3ab commit bd3e1bb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
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

0 comments on commit bd3e1bb

Please sign in to comment.