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

Fix local testing workflow #162

Merged
merged 5 commits into from
Dec 14, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions Getting-Started.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,32 @@ Step 3: Ensuring your RWS meets the technical requirements
Step 4: Testing your RWS locally
--------------------------------

Once you've made your changes to your local branch, you can open a terminal and run the command `python3 check_sites.py`. Currently, this will produce a number of check failures due to older submissions in the set failing recent changes to checks. If no members of your set are mentioned in the list of failed checks, then your submission should be fine. If you would like a cleaner way of looking for problems in your set, follow these steps:
Once you've made your changes to your local branch, you can open a terminal and run the command

1. Run `cp related_website_sets.JSON my_rws.JSON` in your shell
`python3 check_sites.py --primaries=https://yourprimary.example`

2. Make your changes to `my_rws.JSON` and make sure `related_website_sets.JSON` is identical to the version in main.
or, equivalently, run

3. To test your local changes, run `python3 check_sites.py -i my_rws.JSON --with_diff`. When this command finishes running, you will either see "success" (meaning your submission passed all of the checks) or you will see a list of failed checks.
`python3 check_sites.py -p https://yourprimary.example`

4. When you are ready to submit, copy your changes from `my_rws.JSON` into `related_website_sets.JSON` and delete `my_rws.JSON`
You will get the results of any failed tests in the terminal. Otherwise, you will see "success" if your changes are passing all of the checks. Make sure that the text of the primary site you're passing into the command line is identical to the primary site you have listed in the related_website_sets.JSON file, or the tests will fail. If you would like to test multiple Related Website Sets at once, you can run the command above with multiple primaries in a comma separated list.

For example, to get the results of the checks for a set with `https://foo.example` as its primary, you would run

`python3 check_sites.py --primaries=https://foo.example`

sjledoux marked this conversation as resolved.
Show resolved Hide resolved
or equivalently

`python3 check_sites.py -p https://foo.example`


To get the results for both the set with `https://foo.example` as its primary, and for the set with `https://bar.example` as its primary, you would run

`python3 check_sites.py --primaries=https://foo.example,https://bar.example`

sjledoux marked this conversation as resolved.
Show resolved Hide resolved
or

`python3 check_sites.py -p https://foo.example -p https://bar.example`

Step 5: Submitting your RWS
---------------------------
Expand Down
14 changes: 11 additions & 3 deletions check_sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,20 @@ def find_diff_sets(old_sets, new_sets):
def main():
args = sys.argv[1:]
input_file = 'related_website_sets.JSON'
cli_primaries = []
input_prefix = ''
with_diff = False
opts, _ = getopt.getopt(args, "i:", ["data_directory=", "with_diff"])
opts, _ = getopt.getopt(args, "i:p:", ["data_directory=", "with_diff",
"primaries="])
for opt, arg in opts:
if opt == '-i':
input_file = arg
if opt == '--data_directory':
input_prefix = arg
if opt == '--with_diff':
with_diff = True
if opt == '--primaries' or opt == '-p':
cli_primaries.extend(arg.split(','))

# Open and load the json of the new list
with open(input_file) as f:
Expand Down Expand Up @@ -111,10 +115,14 @@ def main():
return
old_checker = RwsCheck(old_sites, etlds, icanns)
check_sets, subtracted_sets = find_diff_sets(old_checker.load_sets(), rws_checker.load_sets())
# TODO: add variable and check for subtracted_sets in case of user
# removing old set from the list
else:
check_sets = rws_checker.load_sets()
if cli_primaries:
absent_primaries = [p for p in cli_primaries if p not in check_sets]
for p in absent_primaries:
error_texts.append("There was an error loading the set:\n" +
f"could not find set with primary site \"{p}\"")
check_sets = {p: check_sets[p] for p in cli_primaries if p in check_sets}

# Run check on subtracted sets
rws_checker.find_invalid_removal(subtracted_sets)
Expand Down
Loading