From f4f79b4ac191ea87f3f7d0a2e16da5691ee2dd47 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 5 Jul 2024 23:07:57 +0000 Subject: [PATCH 001/126] build out structure for initial smoke test --- Testing/Functional/SmokeTests/smoke_test.py | 45 +++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Testing/Functional/SmokeTests/smoke_test.py diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py new file mode 100644 index 00000000..73f36e2b --- /dev/null +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -0,0 +1,45 @@ +""" +run_smoke_test.py is a test script to verify `scubagoggles gws` +outputs (i.e., files) are generated. +""" + +import pytest +import subprocess + +""" + Test virtualenv setup, activation + + Test installing dependencies for running scuba.py script + + Test installing dependencies for running scubagoggles directly + +""" + +class TestScuba: + #def test_venv_setup(self): + # command = f"scubagoggles gws " + # result = subprocess.run(command, shell=True) + # print(result.stdout) + # print(result.stderr) + + + def test_cli(self): + command = f"scubagoggles gws --subjectemail mbaker@scubagws.org --quiet" + result = subprocess.run(command) + print(result) + print(result.stderr) + + if result.returncode != 0: + raise AssertionError(f"Expected 0, but got {result.returncode}") + + +#def create_venv(env): +# result = subprocess.run(["python", "-m", "venv", env]) +# if result.returncode == 0: +# raise RuntimeError(f"Failed to create virtual environment, {result.stderr}") +# +#def activate_venv(env): +# command = f"{env}\\Scripts\\activate" +# result = subprocess.run(command) +# if result.returncode == 0: +# raise RuntimeError(f"Failed to activate virtual environment, {result.stderr}") From 6e29205d07510b1131213701cd4a99ed18b5e384 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 5 Jul 2024 23:48:34 +0000 Subject: [PATCH 002/126] get latest created GWSBaselineConformance dir --- Testing/Functional/SmokeTests/smoke_test.py | 16 ++++++++++++---- Testing/Functional/conftest.py | 8 ++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 Testing/Functional/conftest.py diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index 73f36e2b..7d9abaaa 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -5,6 +5,7 @@ import pytest import subprocess +import os """ Test virtualenv setup, activation @@ -23,14 +24,21 @@ class TestScuba: # print(result.stderr) - def test_cli(self): - command = f"scubagoggles gws --subjectemail mbaker@scubagws.org --quiet" + def test_cli(self, subjectemail): + command = f"scubagoggles gws --subjectemail {subjectemail} --quiet -b commoncontrols" result = subprocess.run(command) - print(result) - print(result.stderr) if result.returncode != 0: raise AssertionError(f"Expected 0, but got {result.returncode}") + + cwd = os.getcwd() + print(cwd) + prefix = "GWSBaselineConformance" + + directories = [d for d in os.listdir() if os.path.isdir(d) and d.startswith(prefix)] + directories.sort(key=lambda d: os.path.getctime(d), reverse=True) + print(directories) + print(directories[0]) #def create_venv(env): diff --git a/Testing/Functional/conftest.py b/Testing/Functional/conftest.py new file mode 100644 index 00000000..01326934 --- /dev/null +++ b/Testing/Functional/conftest.py @@ -0,0 +1,8 @@ +import pytest + +def pytest_addoption(parser): + parser.addoption("--subjectemail", action="store") + +@pytest.fixture +def subjectemail(pytestconfig): + return pytestconfig.getoption("subjectemail") \ No newline at end of file From d0ab9065733c2dd37a605e287586e2243e6cf9e6 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Sat, 6 Jul 2024 00:56:00 +0000 Subject: [PATCH 003/126] add capability to recursively check if paths are file/directory --- Testing/Functional/SmokeTests/smoke_test.py | 53 ++++++++++++++++++++- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index 7d9abaaa..0474b141 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -37,8 +37,57 @@ def test_cli(self, subjectemail): directories = [d for d in os.listdir() if os.path.isdir(d) and d.startswith(prefix)] directories.sort(key=lambda d: os.path.getctime(d), reverse=True) - print(directories) - print(directories[0]) + + output_path = os.path.join(cwd, directories[0]) + individual_reports_path = f"{output_path}/IndividualReports" + print(individual_reports_path) + + def check_output_contents(output_path): + try: + entries = os.listdir(output_path) + print(entries) + for entry in entries: + child_path = os.path.join(output_path, entry) + + # Directory case + if os.path.isdir(child_path): + assert os.path.isdir(child_path) + check_output_contents(child_path) + + # File case + elif os.path.isfile(child_path): + assert os.path.isfile(child_path) + + # Neither a directory or file (symlink, etc.) + else: + assert False + except FileNotFoundError: + assert False, f"The directory {output_path} does not exist" + except Exception as e: + assert False, f"An error occurred, {e}" + + check_output_contents(output_path) + + #assert "BaselineReports.html" in entries and os.path.isfile(f"{output_path}/BaselineReports.html") + #assert "IndividualReports" in entries and os.path.isdir(individual_reports_path) + #assert "ProviderSettingsExport.json" in entries and os.path.isfile(f"{output_path}/ProviderSettingsExport.json") + #assert "TestResults.json" in entries and os.path.isfile(f"{output_path}/TestResults.json") +# + #assert "CalendarReport.html" in os.listdir(individual_reports_path) + #assert "ChatReport.html" in os.listdir(individual_reports_path) + #assert "ClassroomReport.html" in os.listdir(individual_reports_path) + #assert "CommoncontrolsReport.html" in os.listdir(individual_reports_path) + #assert "DriveReport.html" in os.listdir(individual_reports_path) + #assert "GmailReport.html" in os.listdir(individual_reports_path) + #assert "GroupsReport.html" in os.listdir(individual_reports_path) + #assert "MeetReport.html" in os.listdir(individual_reports_path) + #assert "RulesReport.html" in os.listdir(individual_reports_path) + #assert "SitesReport.html" in os.listdir(individual_reports_path) + + + + + #def create_venv(env): From ddc4bfb5da33ba58476a1af10dfcc90d49eb0ffc Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Tue, 9 Jul 2024 22:51:21 +0000 Subject: [PATCH 004/126] add helper function to determine if all outputs exist --- Testing/Functional/SmokeTests/smoke_test.py | 82 +++++++++++++++------ 1 file changed, 58 insertions(+), 24 deletions(-) diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index 0474b141..03a15875 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -16,6 +16,62 @@ """ +def verify_output_type(output_path, contents): + try: + entries = os.listdir(output_path) + print(entries) + for entry in entries: + contents.append(entry) + + # Check if entry is a valid directory or file + child_path = os.path.join(output_path, entry) + if os.path.isdir(child_path): + assert True + verify_output_type(child_path, contents) + elif os.path.isfile(child_path): + assert True + else: + assert False, f"Entry is not a directory or file (symlink, etc.)" + + return contents + except FileNotFoundError: + assert False, f"The directory {output_path} does not exist" + except Exception as e: + assert False, f"An error occurred, {e}" + +required_contents = [ + "BaselineReports.html", + "IndividualReports", + "ProviderSettingsExport.json", + "TestResults.json", + "images", + "CalendarReport.html", + "ChatReport.html", + "ClassroomReport.html", + "CommoncontrolsReport.html", + "DriveReport.html", + "GmailReport.html", + "GroupsReport.html", + "MeetReport.html", + "RulesReport.html", + "SitesReport.html", + "cisa_logo.png", + "triangle-exclamation-solid.svg" +] + +def verify_all_outputs_exist(contents): + + try: + print(contents) + for required_content in required_contents: + if required_content in contents: + assert True + else: + assert False, f"{required_content} was not found in the generated report" + except Exception as e: + assert False, f"An error occurred, {e}" + + class TestScuba: #def test_venv_setup(self): # command = f"scubagoggles gws " @@ -42,31 +98,9 @@ def test_cli(self, subjectemail): individual_reports_path = f"{output_path}/IndividualReports" print(individual_reports_path) - def check_output_contents(output_path): - try: - entries = os.listdir(output_path) - print(entries) - for entry in entries: - child_path = os.path.join(output_path, entry) - - # Directory case - if os.path.isdir(child_path): - assert os.path.isdir(child_path) - check_output_contents(child_path) - - # File case - elif os.path.isfile(child_path): - assert os.path.isfile(child_path) - - # Neither a directory or file (symlink, etc.) - else: - assert False - except FileNotFoundError: - assert False, f"The directory {output_path} does not exist" - except Exception as e: - assert False, f"An error occurred, {e}" - check_output_contents(output_path) + contents = verify_output_type(output_path, []) + verify_all_outputs_exist(contents) #assert "BaselineReports.html" in entries and os.path.isfile(f"{output_path}/BaselineReports.html") #assert "IndividualReports" in entries and os.path.isdir(individual_reports_path) From 7fd0ee26b8a43796dcd9510fff831d845a8edbb1 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 10 Jul 2024 00:23:34 +0000 Subject: [PATCH 005/126] refactor into smoke_test_utils --- Testing/Functional/SmokeTests/smoke_test.py | 109 +++--------------- .../Functional/SmokeTests/smoke_test_utils.py | 53 +++++++++ Testing/Functional/pytest.ini | 2 + 3 files changed, 70 insertions(+), 94 deletions(-) create mode 100644 Testing/Functional/SmokeTests/smoke_test_utils.py create mode 100644 Testing/Functional/pytest.ini diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index 03a15875..8e49ded3 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -7,6 +7,8 @@ import subprocess import os +from smoke_test_utils import verify_all_outputs_exist, verify_output_type + """ Test virtualenv setup, activation @@ -14,110 +16,29 @@ Test installing dependencies for running scubagoggles directly -""" +""" + +class SmokeTest: + def test_venv_creation(self): + result = subprocess.run(["dir", ".venv"], shell=True, capture_output=True, text=True) + if "Scripts" in result.stdout: + assert True + else: + assert False, f"Scripts was not found in the virtual environment" -def verify_output_type(output_path, contents): - try: - entries = os.listdir(output_path) - print(entries) - for entry in entries: - contents.append(entry) - - # Check if entry is a valid directory or file - child_path = os.path.join(output_path, entry) - if os.path.isdir(child_path): - assert True - verify_output_type(child_path, contents) - elif os.path.isfile(child_path): - assert True - else: - assert False, f"Entry is not a directory or file (symlink, etc.)" - - return contents - except FileNotFoundError: - assert False, f"The directory {output_path} does not exist" - except Exception as e: - assert False, f"An error occurred, {e}" - -required_contents = [ - "BaselineReports.html", - "IndividualReports", - "ProviderSettingsExport.json", - "TestResults.json", - "images", - "CalendarReport.html", - "ChatReport.html", - "ClassroomReport.html", - "CommoncontrolsReport.html", - "DriveReport.html", - "GmailReport.html", - "GroupsReport.html", - "MeetReport.html", - "RulesReport.html", - "SitesReport.html", - "cisa_logo.png", - "triangle-exclamation-solid.svg" -] - -def verify_all_outputs_exist(contents): - - try: - print(contents) - for required_content in required_contents: - if required_content in contents: - assert True - else: - assert False, f"{required_content} was not found in the generated report" - except Exception as e: - assert False, f"An error occurred, {e}" - - -class TestScuba: - #def test_venv_setup(self): - # command = f"scubagoggles gws " - # result = subprocess.run(command, shell=True) - # print(result.stdout) - # print(result.stderr) - - - def test_cli(self, subjectemail): - command = f"scubagoggles gws --subjectemail {subjectemail} --quiet -b commoncontrols" - result = subprocess.run(command) - - if result.returncode != 0: - raise AssertionError(f"Expected 0, but got {result.returncode}") + def test_scubagoggles(self, subjectemail): + command = f"scubagoggles gws --subjectemail {subjectemail} --quiet" + subprocess.run(command) - cwd = os.getcwd() - print(cwd) prefix = "GWSBaselineConformance" - directories = [d for d in os.listdir() if os.path.isdir(d) and d.startswith(prefix)] directories.sort(key=lambda d: os.path.getctime(d), reverse=True) + cwd = os.getcwd() output_path = os.path.join(cwd, directories[0]) - individual_reports_path = f"{output_path}/IndividualReports" - print(individual_reports_path) - - contents = verify_output_type(output_path, []) verify_all_outputs_exist(contents) - #assert "BaselineReports.html" in entries and os.path.isfile(f"{output_path}/BaselineReports.html") - #assert "IndividualReports" in entries and os.path.isdir(individual_reports_path) - #assert "ProviderSettingsExport.json" in entries and os.path.isfile(f"{output_path}/ProviderSettingsExport.json") - #assert "TestResults.json" in entries and os.path.isfile(f"{output_path}/TestResults.json") -# - #assert "CalendarReport.html" in os.listdir(individual_reports_path) - #assert "ChatReport.html" in os.listdir(individual_reports_path) - #assert "ClassroomReport.html" in os.listdir(individual_reports_path) - #assert "CommoncontrolsReport.html" in os.listdir(individual_reports_path) - #assert "DriveReport.html" in os.listdir(individual_reports_path) - #assert "GmailReport.html" in os.listdir(individual_reports_path) - #assert "GroupsReport.html" in os.listdir(individual_reports_path) - #assert "MeetReport.html" in os.listdir(individual_reports_path) - #assert "RulesReport.html" in os.listdir(individual_reports_path) - #assert "SitesReport.html" in os.listdir(individual_reports_path) - diff --git a/Testing/Functional/SmokeTests/smoke_test_utils.py b/Testing/Functional/SmokeTests/smoke_test_utils.py new file mode 100644 index 00000000..b80f8f79 --- /dev/null +++ b/Testing/Functional/SmokeTests/smoke_test_utils.py @@ -0,0 +1,53 @@ +import os + +required_contents = [ + "BaselineReports.html", + "IndividualReports", + "ProviderSettingsExport.json", + "TestResults.json", + "images", + "CalendarReport.html", + "ChatReport.html", + "ClassroomReport.html", + "CommoncontrolsReport.html", + "DriveReport.html", + "GmailReport.html", + "GroupsReport.html", + "MeetReport.html", + "RulesReport.html", + "SitesReport.html", + "cisa_logo.png", + "triangle-exclamation-solid.svg" +] + +def verify_all_outputs_exist(contents): + try: + for required_content in required_contents: + if required_content in contents: + assert True + else: + assert False, f"{required_content} was not found in the generated report" + except Exception as e: + assert False, f"An error occurred, {e}" + +def verify_output_type(output_path, contents): + try: + entries = os.listdir(output_path) + for entry in entries: + contents.append(entry) + + # Check if entry is a valid directory or file + child_path = os.path.join(output_path, entry) + if os.path.isdir(child_path): + assert True + verify_output_type(child_path, contents) + elif os.path.isfile(child_path): + assert True + else: + assert False, f"Entry is not a directory or file (symlink, etc.)" + + return contents + except FileNotFoundError: + assert False, f"The directory {output_path} does not exist" + except Exception as e: + assert False, f"An error occurred, {e}" \ No newline at end of file diff --git a/Testing/Functional/pytest.ini b/Testing/Functional/pytest.ini new file mode 100644 index 00000000..bbd61f63 --- /dev/null +++ b/Testing/Functional/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +python_classes = *Test \ No newline at end of file From 24bac6fe5b0490aedf49851dc02d6cf6710c6eae Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 10 Jul 2024 01:03:07 +0000 Subject: [PATCH 006/126] cleanup, add run_smoke_test workflow --- .github/workflows/run_smoke_test.yml | 25 +++++++++++++++++++++ Testing/Functional/SmokeTests/smoke_test.py | 12 ++-------- 2 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/run_smoke_test.yml diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml new file mode 100644 index 00000000..6485fa54 --- /dev/null +++ b/.github/workflows/run_smoke_test.yml @@ -0,0 +1,25 @@ +name: Smoke Test +on: + pull_request: + types: [opened, reopened] + branches: + - "main" + pull_request_review: + types: [submitted] + push: + branches: + - "main" + - "*smoke*" +jobs: + smoke-test-windows: + name: Smoke Test for Windows OS + runs-on: windows-latest + env: + SCUBA_GITHUB_AUTOMATION_CREDS: ${{ secrets.SCUBA_GITHUB_AUTOMATION_CREDS }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Execute ScubaGoggles and check for correct output + run: | + echo "In step to execute ScubaGoggles" \ No newline at end of file diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index 8e49ded3..3a5554f5 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -9,23 +9,15 @@ from smoke_test_utils import verify_all_outputs_exist, verify_output_type -""" - Test virtualenv setup, activation - - Test installing dependencies for running scuba.py script - - Test installing dependencies for running scubagoggles directly - -""" - class SmokeTest: def test_venv_creation(self): - result = subprocess.run(["dir", ".venv"], shell=True, capture_output=True, text=True) + result = subprocess.run(["ls", ".venv"], shell=True, capture_output=True, text=True) if "Scripts" in result.stdout: assert True else: assert False, f"Scripts was not found in the virtual environment" + def test_scubagoggles(self, subjectemail): command = f"scubagoggles gws --subjectemail {subjectemail} --quiet" subprocess.run(command) From ec090e83bb24a574f7b644d350589b35369d06b2 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Thu, 11 Jul 2024 00:18:07 +0000 Subject: [PATCH 007/126] build out initial workflow for smoke testing scubagoggles from a windows os --- .github/workflows/run_smoke_test.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 6485fa54..c74e0295 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -20,6 +20,22 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - name: Setup virtualenv + run: | + pip3 install virtualenv + python -m venv .venv + .venv\Scripts\activate + python -c "import sys; print(sys.prefix != sys.base_prefix)" + + - name: Install dependencies + run: | + pip3 install -r requirements.txt + + - name: Download OPA executable + run: | + python download_opa.py -v 0.60.0 -os windows + - name: Execute ScubaGoggles and check for correct output run: | - echo "In step to execute ScubaGoggles" \ No newline at end of file + echo "In step to execute ScubaGoggles smoke test" + pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="${$env:SCUBA_GITHUB_AUTOMATION_CREDS.subjectemail}" \ No newline at end of file From eeafdda07c9307be2e3a96fe81d15ce682be1768 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Thu, 25 Jul 2024 22:23:11 +0000 Subject: [PATCH 008/126] add workflow_dispatch --- .github/workflows/run_smoke_test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index c74e0295..b4be3f45 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -10,6 +10,8 @@ on: branches: - "main" - "*smoke*" + workflow_dispatch: + jobs: smoke-test-windows: name: Smoke Test for Windows OS From f14076c7d1bc011100595709da482620aac85d0b Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Thu, 25 Jul 2024 22:27:33 +0000 Subject: [PATCH 009/126] add pytest install --- .github/workflows/run_smoke_test.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index b4be3f45..3785def8 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -1,5 +1,7 @@ name: Smoke Test on: + workflow_call: + workflow_dispatch: pull_request: types: [opened, reopened] branches: @@ -7,10 +9,11 @@ on: pull_request_review: types: [submitted] push: + paths: + - ".github/workflows/run_smoke_test.yml" branches: - "main" - "*smoke*" - workflow_dispatch: jobs: smoke-test-windows: @@ -32,6 +35,7 @@ jobs: - name: Install dependencies run: | pip3 install -r requirements.txt + pip3 install -U pytest - name: Download OPA executable run: | From 153ab14b091f395bb7f9df0d20ed6cc515a5a6a1 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Thu, 25 Jul 2024 22:45:19 +0000 Subject: [PATCH 010/126] run test --- .github/workflows/run_smoke_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 3785def8..08554bff 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -30,7 +30,6 @@ jobs: pip3 install virtualenv python -m venv .venv .venv\Scripts\activate - python -c "import sys; print(sys.prefix != sys.base_prefix)" - name: Install dependencies run: | @@ -44,4 +43,5 @@ jobs: - name: Execute ScubaGoggles and check for correct output run: | echo "In step to execute ScubaGoggles smoke test" + echo ${$env:SCUBA_GITHUB_AUTOMATION_CREDS.subjectemail} pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="${$env:SCUBA_GITHUB_AUTOMATION_CREDS.subjectemail}" \ No newline at end of file From 60a6469d683bf483db5443b9d5a79792c25e722b Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Thu, 25 Jul 2024 22:59:25 +0000 Subject: [PATCH 011/126] change secret creds --- .github/workflows/run_smoke_test.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 08554bff..2db5dfbc 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -21,9 +21,18 @@ jobs: runs-on: windows-latest env: SCUBA_GITHUB_AUTOMATION_CREDS: ${{ secrets.SCUBA_GITHUB_AUTOMATION_CREDS }} + GWS_SERVICE_ACCOUNT: ${{ secrets.GWS_SERVICE_ACCOUNT }} steps: - name: Checkout repository uses: actions/checkout@v4 + + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles("**/requirements.txt") }} + restore-keys: | + ${{ runner.os }}-pip- - name: Setup virtualenv run: | @@ -43,5 +52,7 @@ jobs: - name: Execute ScubaGoggles and check for correct output run: | echo "In step to execute ScubaGoggles smoke test" - echo ${$env:SCUBA_GITHUB_AUTOMATION_CREDS.subjectemail} - pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="${$env:SCUBA_GITHUB_AUTOMATION_CREDS.subjectemail}" \ No newline at end of file + echo $env:SCUBA_GITHUB_AUTOMATION_CREDS.subjectemail + echo $env:SCUBA_GITHUB_AUTOMATION_CREDS.subjectemail | ConvertFrom-Json + echo $env:GWS_SERVICE_ACCOUNT + pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SERVICE_ACCOUNT" \ No newline at end of file From 504baf3d2162bbb909a55c10757e2d9e61f88653 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Thu, 25 Jul 2024 23:01:36 +0000 Subject: [PATCH 012/126] change secret creds --- .github/workflows/run_smoke_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 2db5dfbc..75cb71a5 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -30,7 +30,7 @@ jobs: uses: actions/cache@v3 with: path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles("**/requirements.txt") }} + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} restore-keys: | ${{ runner.os }}-pip- From b2ae8de0ba7655d66be561a18afff1b7d6f8edfd Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Thu, 25 Jul 2024 23:03:48 +0000 Subject: [PATCH 013/126] change secret creds --- .github/workflows/run_smoke_test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 75cb71a5..d88844a8 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -52,7 +52,5 @@ jobs: - name: Execute ScubaGoggles and check for correct output run: | echo "In step to execute ScubaGoggles smoke test" - echo $env:SCUBA_GITHUB_AUTOMATION_CREDS.subjectemail - echo $env:SCUBA_GITHUB_AUTOMATION_CREDS.subjectemail | ConvertFrom-Json echo $env:GWS_SERVICE_ACCOUNT pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SERVICE_ACCOUNT" \ No newline at end of file From 969df21f06e00f8d4d2ca33a4f8c1842608bccca Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Thu, 25 Jul 2024 23:13:47 +0000 Subject: [PATCH 014/126] move location of cache step; add shell=True to test --- .github/workflows/run_smoke_test.yml | 16 +++++++--------- Testing/Functional/SmokeTests/smoke_test.py | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index d88844a8..20d2b79c 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -25,14 +25,6 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 - - - name: Cache dependencies - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - name: Setup virtualenv run: | @@ -53,4 +45,10 @@ jobs: run: | echo "In step to execute ScubaGoggles smoke test" echo $env:GWS_SERVICE_ACCOUNT - pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SERVICE_ACCOUNT" \ No newline at end of file + pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SERVICE_ACCOUNT" + + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} \ No newline at end of file diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index 3a5554f5..dac9c502 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -20,7 +20,7 @@ def test_venv_creation(self): def test_scubagoggles(self, subjectemail): command = f"scubagoggles gws --subjectemail {subjectemail} --quiet" - subprocess.run(command) + subprocess.run(command, shell=True) prefix = "GWSBaselineConformance" directories = [d for d in os.listdir() if os.path.isdir(d) and d.startswith(prefix)] From 3c50a346eab7d6da67c91b7a514f29639f3f9c17 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Thu, 25 Jul 2024 23:17:45 +0000 Subject: [PATCH 015/126] debug smoke_test.py --- .github/workflows/run_smoke_test.yml | 1 - Testing/Functional/SmokeTests/smoke_test.py | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 20d2b79c..14604f88 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -44,7 +44,6 @@ jobs: - name: Execute ScubaGoggles and check for correct output run: | echo "In step to execute ScubaGoggles smoke test" - echo $env:GWS_SERVICE_ACCOUNT pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SERVICE_ACCOUNT" - name: Cache dependencies diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index dac9c502..1446cd20 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -25,9 +25,11 @@ def test_scubagoggles(self, subjectemail): prefix = "GWSBaselineConformance" directories = [d for d in os.listdir() if os.path.isdir(d) and d.startswith(prefix)] directories.sort(key=lambda d: os.path.getctime(d), reverse=True) + print(directories) cwd = os.getcwd() output_path = os.path.join(cwd, directories[0]) + print(cwd, directories[0]) contents = verify_output_type(output_path, []) verify_all_outputs_exist(contents) From 8078e4442d1b42248b5e06a07fb4ab301ff67883 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Thu, 25 Jul 2024 23:27:55 +0000 Subject: [PATCH 016/126] adjust smoke_test workflow --- .github/workflows/run_smoke_test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 14604f88..8d206e85 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -31,11 +31,12 @@ jobs: pip3 install virtualenv python -m venv .venv .venv\Scripts\activate + pytest ./Testing/Functional/SmokeTests/ -k "SmokeTest and test_venv_creation" - name: Install dependencies run: | pip3 install -r requirements.txt - pip3 install -U pytest + pip3 install pytest - name: Download OPA executable run: | From e8d5a084c20da2b2cfcc69866bdff5b0418836b5 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Thu, 25 Jul 2024 23:31:08 +0000 Subject: [PATCH 017/126] smoke_test workflow updates --- .github/workflows/run_smoke_test.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 8d206e85..77032094 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -31,7 +31,6 @@ jobs: pip3 install virtualenv python -m venv .venv .venv\Scripts\activate - pytest ./Testing/Functional/SmokeTests/ -k "SmokeTest and test_venv_creation" - name: Install dependencies run: | @@ -39,8 +38,10 @@ jobs: pip3 install pytest - name: Download OPA executable - run: | - python download_opa.py -v 0.60.0 -os windows + run: python download_opa.py -v 0.60.0 -os windows + + - name: Check virtualenv creation + run: pytest ./Testing/Functional/SmokeTests/ -k "SmokeTest and test_venv_creation" - name: Execute ScubaGoggles and check for correct output run: | From ff2e12495776a08f8d96cf77a441c46d59b8a7f1 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Thu, 25 Jul 2024 23:33:51 +0000 Subject: [PATCH 018/126] smoke_test workflow updates --- .github/workflows/run_smoke_test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 77032094..5e8f1bda 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -46,6 +46,7 @@ jobs: - name: Execute ScubaGoggles and check for correct output run: | echo "In step to execute ScubaGoggles smoke test" + .venv\Scripts\activate pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SERVICE_ACCOUNT" - name: Cache dependencies From 7291b9dd47a8c4da746211c55cb41deee8014475 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 00:02:34 +0000 Subject: [PATCH 019/126] adjust smoke_test workflow --- .github/workflows/run_smoke_test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 5e8f1bda..28f9ba80 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -34,6 +34,7 @@ jobs: - name: Install dependencies run: | + python -m pip3 install . pip3 install -r requirements.txt pip3 install pytest From 765e44a817d6063796982ab1e6b3e3921d3d134f Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 00:10:44 +0000 Subject: [PATCH 020/126] smoke_test workflow updates --- .github/workflows/run_smoke_test.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 28f9ba80..507f961f 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -32,6 +32,12 @@ jobs: python -m venv .venv .venv\Scripts\activate + python -m pip3 install . + pip3 install -r requirements.txt + pip3 install pytest + python download_opa.py -v 0.60.0 -os windows + pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SERVICE_ACCOUNT" + - name: Install dependencies run: | python -m pip3 install . From 80ac820ca65c91a104863efdf042a94168702e12 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 00:20:29 +0000 Subject: [PATCH 021/126] smoke_test workflow updates --- .github/workflows/run_smoke_test.yml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 507f961f..4c5c010f 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -26,34 +26,31 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - name: Install pytest + run: pip3 install pytest + - name: Setup virtualenv run: | pip3 install virtualenv python -m venv .venv .venv\Scripts\activate - python -m pip3 install . - pip3 install -r requirements.txt - pip3 install pytest - python download_opa.py -v 0.60.0 -os windows - pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SERVICE_ACCOUNT" + - name: Check virtualenv creation + run: pytest ./Testing/Functional/SmokeTests/ -k "SmokeTest and test_venv_creation" - name: Install dependencies run: | python -m pip3 install . pip3 install -r requirements.txt - pip3 install pytest - name: Download OPA executable run: python download_opa.py -v 0.60.0 -os windows - - name: Check virtualenv creation - run: pytest ./Testing/Functional/SmokeTests/ -k "SmokeTest and test_venv_creation" - - name: Execute ScubaGoggles and check for correct output run: | echo "In step to execute ScubaGoggles smoke test" .venv\Scripts\activate + scubagoggles gws pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SERVICE_ACCOUNT" - name: Cache dependencies From b75045fb87b75ffe462ae1fa11ff63490a912e66 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 00:26:33 +0000 Subject: [PATCH 022/126] smoke_test workflow updates --- .github/workflows/run_smoke_test.yml | 46 ++++++++++++++++++---------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 4c5c010f..b91b583a 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -19,6 +19,9 @@ jobs: smoke-test-windows: name: Smoke Test for Windows OS runs-on: windows-latest + defaults: + run: + shell: powershell env: SCUBA_GITHUB_AUTOMATION_CREDS: ${{ secrets.SCUBA_GITHUB_AUTOMATION_CREDS }} GWS_SERVICE_ACCOUNT: ${{ secrets.GWS_SERVICE_ACCOUNT }} @@ -26,32 +29,43 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Install pytest - run: pip3 install pytest - - - name: Setup virtualenv + - name: Run run: | pip3 install virtualenv python -m venv .venv .venv\Scripts\activate - - name: Check virtualenv creation - run: pytest ./Testing/Functional/SmokeTests/ -k "SmokeTest and test_venv_creation" - - - name: Install dependencies - run: | python -m pip3 install . pip3 install -r requirements.txt + pip3 install pytest - - name: Download OPA executable - run: python download_opa.py -v 0.60.0 -os windows + python download_opa.py -v 0.60.0 -os windows - - name: Execute ScubaGoggles and check for correct output - run: | - echo "In step to execute ScubaGoggles smoke test" - .venv\Scripts\activate - scubagoggles gws pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SERVICE_ACCOUNT" + + #- name: Setup virtualenv + # run: | + # pip3 install virtualenv + # python -m venv .venv + # .venv\Scripts\activate +# + #- name: Check virtualenv creation + # run: pytest ./Testing/Functional/SmokeTests/ -k "SmokeTest and test_venv_creation" +# + #- name: Install dependencies + # run: | + # python -m pip3 install . + # pip3 install -r requirements.txt +# + #- name: Download OPA executable + # run: python download_opa.py -v 0.60.0 -os windows +# + #- name: Execute ScubaGoggles and check for correct output + # run: | + # echo "In step to execute ScubaGoggles smoke test" + # .venv\Scripts\activate + # scubagoggles gws + # pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SERVICE_ACCOUNT" - name: Cache dependencies uses: actions/cache@v3 From 7eafdbdd954b7f6f6bae028fe4132b6444f44474 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 00:32:49 +0000 Subject: [PATCH 023/126] adjust smoke_test workflow --- .github/workflows/run_smoke_test.yml | 47 +++++++++++----------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index b91b583a..c22fd01d 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -26,46 +26,37 @@ jobs: SCUBA_GITHUB_AUTOMATION_CREDS: ${{ secrets.SCUBA_GITHUB_AUTOMATION_CREDS }} GWS_SERVICE_ACCOUNT: ${{ secrets.GWS_SERVICE_ACCOUNT }} steps: - - name: Checkout repository uses: actions/checkout@v4 + uses: actions/setup-python@v5 + with: + python-version: "3.12" - - name: Run + - name: Install pytest + run: pip3 install pytest + + - name: Setup virtualenv run: | pip3 install virtualenv python -m venv .venv .venv\Scripts\activate + - name: Check virtualenv creation + run: pytest ./Testing/Functional/SmokeTests/ -k "SmokeTest and test_venv_creation" + + - name: Install dependencies + run: | python -m pip3 install . pip3 install -r requirements.txt - pip3 install pytest - python download_opa.py -v 0.60.0 -os windows + - name: Download OPA executable + run: python download_opa.py -v 0.60.0 -os windows + - name: Execute ScubaGoggles and check for correct output + run: | + echo "In step to execute ScubaGoggles smoke test" + .venv\Scripts\activate + scubagoggles gws pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SERVICE_ACCOUNT" - - #- name: Setup virtualenv - # run: | - # pip3 install virtualenv - # python -m venv .venv - # .venv\Scripts\activate -# - #- name: Check virtualenv creation - # run: pytest ./Testing/Functional/SmokeTests/ -k "SmokeTest and test_venv_creation" -# - #- name: Install dependencies - # run: | - # python -m pip3 install . - # pip3 install -r requirements.txt -# - #- name: Download OPA executable - # run: python download_opa.py -v 0.60.0 -os windows -# - #- name: Execute ScubaGoggles and check for correct output - # run: | - # echo "In step to execute ScubaGoggles smoke test" - # .venv\Scripts\activate - # scubagoggles gws - # pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SERVICE_ACCOUNT" - name: Cache dependencies uses: actions/cache@v3 From a46ccdf87026eac760d889abae0cc34cfe972720 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 00:34:04 +0000 Subject: [PATCH 024/126] adjust smoke_test workflow --- .github/workflows/run_smoke_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index c22fd01d..2b78eb23 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -29,7 +29,7 @@ jobs: uses: actions/checkout@v4 uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: '3.12' - name: Install pytest run: pip3 install pytest From fa157340dde7f15b6514b70168aaa13f280904a6 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 00:35:19 +0000 Subject: [PATCH 025/126] adjust smoke_test workflow --- .github/workflows/run_smoke_test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 2b78eb23..9debfcb4 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -28,8 +28,8 @@ jobs: steps: uses: actions/checkout@v4 uses: actions/setup-python@v5 - with: - python-version: '3.12' + with: + python-version: '3.12' - name: Install pytest run: pip3 install pytest From ca3c9efc6ba0eb04200120c8e996499f71ed1d95 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 00:38:06 +0000 Subject: [PATCH 026/126] adjust smoke_test workflow --- .github/workflows/run_smoke_test.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 9debfcb4..34330243 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -26,10 +26,14 @@ jobs: SCUBA_GITHUB_AUTOMATION_CREDS: ${{ secrets.SCUBA_GITHUB_AUTOMATION_CREDS }} GWS_SERVICE_ACCOUNT: ${{ secrets.GWS_SERVICE_ACCOUNT }} steps: + - name: Checkout Repository uses: actions/checkout@v4 + + - name: Setup Python uses: actions/setup-python@v5 with: - python-version: '3.12' + python-version: "3.12" + cache: "pip" - name: Install pytest run: pip3 install pytest @@ -56,10 +60,4 @@ jobs: echo "In step to execute ScubaGoggles smoke test" .venv\Scripts\activate scubagoggles gws - pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SERVICE_ACCOUNT" - - - name: Cache dependencies - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} \ No newline at end of file + pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SERVICE_ACCOUNT" \ No newline at end of file From 891851af31e8d48bac28633abeb9a69fb7bc7ee0 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 00:45:01 +0000 Subject: [PATCH 027/126] adjust smoke_test workflow --- .github/workflows/run_smoke_test.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 34330243..59324c64 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -35,22 +35,17 @@ jobs: python-version: "3.12" cache: "pip" - - name: Install pytest - run: pip3 install pytest - - name: Setup virtualenv run: | pip3 install virtualenv python -m venv .venv .venv\Scripts\activate - - name: Check virtualenv creation - run: pytest ./Testing/Functional/SmokeTests/ -k "SmokeTest and test_venv_creation" - - name: Install dependencies run: | python -m pip3 install . pip3 install -r requirements.txt + pip3 install pytest - name: Download OPA executable run: python download_opa.py -v 0.60.0 -os windows @@ -58,6 +53,4 @@ jobs: - name: Execute ScubaGoggles and check for correct output run: | echo "In step to execute ScubaGoggles smoke test" - .venv\Scripts\activate - scubagoggles gws pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SERVICE_ACCOUNT" \ No newline at end of file From f33327a937d67143f0e84d45a794862e966414c0 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 01:14:41 +0000 Subject: [PATCH 028/126] adjust smoke_test workflow --- .github/workflows/run_smoke_test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 59324c64..4e9144f3 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -33,7 +33,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: "3.12" - cache: "pip" + cache: "pip3" - name: Setup virtualenv run: | @@ -53,4 +53,5 @@ jobs: - name: Execute ScubaGoggles and check for correct output run: | echo "In step to execute ScubaGoggles smoke test" + pip3 show scubagoggles pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SERVICE_ACCOUNT" \ No newline at end of file From e684b108575d0f7ce25b0e62e24975dd973d9342 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 01:17:44 +0000 Subject: [PATCH 029/126] adjust smoke_test workflow --- .github/workflows/run_smoke_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 4e9144f3..4e42a132 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -33,7 +33,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: "3.12" - cache: "pip3" + cache: "pip" - name: Setup virtualenv run: | From 9b47f9da5cf4869dc2c28fa449a4c5a56123ae12 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 01:29:01 +0000 Subject: [PATCH 030/126] adjust pip3 -> pip --- .github/workflows/run_smoke_test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 4e42a132..28dba9ff 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -37,15 +37,15 @@ jobs: - name: Setup virtualenv run: | - pip3 install virtualenv + pip install virtualenv python -m venv .venv .venv\Scripts\activate - name: Install dependencies run: | - python -m pip3 install . - pip3 install -r requirements.txt - pip3 install pytest + python -m pip install . + pip install -r requirements.txt + pip install pytest - name: Download OPA executable run: python download_opa.py -v 0.60.0 -os windows @@ -53,5 +53,5 @@ jobs: - name: Execute ScubaGoggles and check for correct output run: | echo "In step to execute ScubaGoggles smoke test" - pip3 show scubagoggles + pip show scubagoggles pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SERVICE_ACCOUNT" \ No newline at end of file From b234dd61f1cc56ff23ea471df1614fd46db3c35e Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 01:46:54 +0000 Subject: [PATCH 031/126] update numpy --- .github/workflows/run_smoke_test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 28dba9ff..ed495260 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -46,6 +46,8 @@ jobs: python -m pip install . pip install -r requirements.txt pip install pytest + pip uninstall numpy + pip install numpy==1.26.4 - name: Download OPA executable run: python download_opa.py -v 0.60.0 -os windows From 5891e9ca869093b5f0c6dea3778f3b25a8771b12 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 17:50:36 +0000 Subject: [PATCH 032/126] update secrets, create credentials.json for service account --- .github/workflows/run_smoke_test.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index ed495260..33076a21 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -23,8 +23,8 @@ jobs: run: shell: powershell env: - SCUBA_GITHUB_AUTOMATION_CREDS: ${{ secrets.SCUBA_GITHUB_AUTOMATION_CREDS }} - GWS_SERVICE_ACCOUNT: ${{ secrets.GWS_SERVICE_ACCOUNT }} + GWS_SUBJECT_EMAIL: ${{ secrets.GWS_SUBJECT_EMAIL }} + GWS_GITHUB_AUTOMATION_CREDS: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }} steps: - name: Checkout Repository uses: actions/checkout@v4 @@ -46,8 +46,9 @@ jobs: python -m pip install . pip install -r requirements.txt pip install pytest - pip uninstall numpy - pip install numpy==1.26.4 + + - name: Create credentials.json for service account + run: Set-Content -Path credentials.json -Value $env:GWS_GITHUB_AUTOMATION_CREDS -Encoding utf8 - name: Download OPA executable run: python download_opa.py -v 0.60.0 -os windows @@ -56,4 +57,4 @@ jobs: run: | echo "In step to execute ScubaGoggles smoke test" pip show scubagoggles - pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SERVICE_ACCOUNT" \ No newline at end of file + pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" \ No newline at end of file From 06c6bb38fb45e3102566a8683abf7971b830a30a Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 18:05:58 +0000 Subject: [PATCH 033/126] add cache dependency path, not working yet; readd numpy line to prevent error --- .github/workflows/run_smoke_test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 33076a21..03a2df82 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -34,6 +34,7 @@ jobs: with: python-version: "3.12" cache: "pip" + cache-dependency-path: "requirements.txt" - name: Setup virtualenv run: | @@ -46,6 +47,8 @@ jobs: python -m pip install . pip install -r requirements.txt pip install pytest + pip uninstall numpy + pip install numpy==1.26.4 - name: Create credentials.json for service account run: Set-Content -Path credentials.json -Value $env:GWS_GITHUB_AUTOMATION_CREDS -Encoding utf8 From 930066bc958624ccbf6d5cf9b7d872c528eaecbf Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 18:29:32 +0000 Subject: [PATCH 034/126] remove utf-8 encoding --- .github/workflows/run_smoke_test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 03a2df82..319fea95 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -1,4 +1,4 @@ -name: Smoke Test +name: Run Smoke Test on: workflow_call: workflow_dispatch: @@ -51,7 +51,7 @@ jobs: pip install numpy==1.26.4 - name: Create credentials.json for service account - run: Set-Content -Path credentials.json -Value $env:GWS_GITHUB_AUTOMATION_CREDS -Encoding utf8 + run: Set-Content -Path credentials.json -Value $env:GWS_GITHUB_AUTOMATION_CREDS - name: Download OPA executable run: python download_opa.py -v 0.60.0 -os windows From a14efa79218e6501b24dcd5e663afa8b140ae008 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 19:23:48 +0000 Subject: [PATCH 035/126] refactor try/catch handlers into smoke test methods; remove ProviderSettingsExport and switch to ScubaResults.json --- .github/workflows/run_smoke_test.yml | 12 ++--- Testing/Functional/SmokeTests/smoke_test.py | 45 ++++++++++-------- .../Functional/SmokeTests/smoke_test_utils.py | 47 ++++++++----------- 3 files changed, 49 insertions(+), 55 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 319fea95..b5cb3995 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -42,22 +42,18 @@ jobs: python -m venv .venv .venv\Scripts\activate - - name: Install dependencies + - name: Install project dependencies and OPA run: | python -m pip install . pip install -r requirements.txt pip install pytest pip uninstall numpy pip install numpy==1.26.4 - - - name: Create credentials.json for service account - run: Set-Content -Path credentials.json -Value $env:GWS_GITHUB_AUTOMATION_CREDS - - - name: Download OPA executable - run: python download_opa.py -v 0.60.0 -os windows + python download_opa.py -v 0.60.0 -os windows - name: Execute ScubaGoggles and check for correct output run: | - echo "In step to execute ScubaGoggles smoke test" pip show scubagoggles + # Setup credentials for service account + Set-Content -Path credentials.json -Value $env:GWS_GITHUB_AUTOMATION_CREDS pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" \ No newline at end of file diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index 1446cd20..99354261 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -1,6 +1,6 @@ """ -run_smoke_test.py is a test script to verify `scubagoggles gws` -outputs (i.e., files) are generated. +smoke_test.py is a test script to verify `scubagoggles gws` +generates the correct outputs (i.e., directories, files). """ import pytest @@ -11,27 +11,32 @@ class SmokeTest: def test_venv_creation(self): - result = subprocess.run(["ls", ".venv"], shell=True, capture_output=True, text=True) - if "Scripts" in result.stdout: - assert True - else: - assert False, f"Scripts was not found in the virtual environment" + try: + result = subprocess.run(["ls", ".venv"], shell=True, capture_output=True, text=True) + if "Scripts" in result.stdout: + assert True + else: + assert False, f"Scripts was not found in the virtual environment" + except Exception as e: + pytest.fail(f"An error occurred, {e}") def test_scubagoggles(self, subjectemail): - command = f"scubagoggles gws --subjectemail {subjectemail} --quiet" - subprocess.run(command, shell=True) - - prefix = "GWSBaselineConformance" - directories = [d for d in os.listdir() if os.path.isdir(d) and d.startswith(prefix)] - directories.sort(key=lambda d: os.path.getctime(d), reverse=True) - print(directories) - - cwd = os.getcwd() - output_path = os.path.join(cwd, directories[0]) - print(cwd, directories[0]) - contents = verify_output_type(output_path, []) - verify_all_outputs_exist(contents) + try: + command = f"scubagoggles gws --subjectemail {subjectemail} --quiet" + subprocess.run(command, shell=True) + + prefix = "GWSBaselineConformance" + directories = [d for d in os.listdir() if os.path.isdir(d) and d.startswith(prefix)] + directories.sort(key=lambda d: os.path.getctime(d), reverse=True) + + cwd = os.getcwd() + output_path = os.path.join(cwd, directories[0]) + contents = verify_output_type(output_path, []) + print(contents) + verify_all_outputs_exist(contents) + except Exception as e: + pytest.fail(f"An error occurred, {e}") diff --git a/Testing/Functional/SmokeTests/smoke_test_utils.py b/Testing/Functional/SmokeTests/smoke_test_utils.py index b80f8f79..2bea85d0 100644 --- a/Testing/Functional/SmokeTests/smoke_test_utils.py +++ b/Testing/Functional/SmokeTests/smoke_test_utils.py @@ -3,7 +3,7 @@ required_contents = [ "BaselineReports.html", "IndividualReports", - "ProviderSettingsExport.json", + "ScubaResults.json", "TestResults.json", "images", "CalendarReport.html", @@ -21,33 +21,26 @@ ] def verify_all_outputs_exist(contents): - try: - for required_content in required_contents: - if required_content in contents: - assert True - else: - assert False, f"{required_content} was not found in the generated report" - except Exception as e: - assert False, f"An error occurred, {e}" + for required_content in required_contents: + if required_content in contents: + assert True + else: + assert False, f"{required_content} was not found in the generated report" def verify_output_type(output_path, contents): - try: - entries = os.listdir(output_path) - for entry in entries: - contents.append(entry) + entries = os.listdir(output_path) - # Check if entry is a valid directory or file - child_path = os.path.join(output_path, entry) - if os.path.isdir(child_path): - assert True - verify_output_type(child_path, contents) - elif os.path.isfile(child_path): - assert True - else: - assert False, f"Entry is not a directory or file (symlink, etc.)" + for entry in entries: + contents.append(entry) - return contents - except FileNotFoundError: - assert False, f"The directory {output_path} does not exist" - except Exception as e: - assert False, f"An error occurred, {e}" \ No newline at end of file + # Check if entry is a valid directory or file + child_path = os.path.join(output_path, entry) + if os.path.isdir(child_path): + assert True + verify_output_type(child_path, contents) + elif os.path.isfile(child_path): + assert True + else: + assert False, f"Entry is not a directory or file (symlink, etc.)" + + return contents \ No newline at end of file From a2f92cfb5b3af6c3e4b4dd5c2f5fcc9fbb0158c3 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 20:08:54 +0000 Subject: [PATCH 036/126] workflow updates --- .github/workflows/run_smoke_test.yml | 6 ++++-- Testing/Functional/SmokeTests/smoke_test.py | 16 +++----------- .../Functional/SmokeTests/smoke_test_utils.py | 21 ++++++++++--------- 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index b5cb3995..21ddc50c 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -42,14 +42,16 @@ jobs: python -m venv .venv .venv\Scripts\activate - - name: Install project dependencies and OPA + - name: Install dependencies run: | python -m pip install . pip install -r requirements.txt pip install pytest pip uninstall numpy pip install numpy==1.26.4 - python download_opa.py -v 0.60.0 -os windows + + - name: Download OPA executable + run: python download_opa.py -v 0.60.0 -os windows - name: Execute ScubaGoggles and check for correct output run: | diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index 99354261..d117e110 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -12,15 +12,12 @@ class SmokeTest: def test_venv_creation(self): try: - result = subprocess.run(["ls", ".venv"], shell=True, capture_output=True, text=True) + result = subprocess.run(["ls", ".venv"], shell=True, capture_output=True, text=True, check=True) if "Scripts" in result.stdout: assert True - else: - assert False, f"Scripts was not found in the virtual environment" - except Exception as e: + except subprocess.CalledProcessError as e: pytest.fail(f"An error occurred, {e}") - def test_scubagoggles(self, subjectemail): try: command = f"scubagoggles gws --subjectemail {subjectemail} --quiet" @@ -33,17 +30,10 @@ def test_scubagoggles(self, subjectemail): cwd = os.getcwd() output_path = os.path.join(cwd, directories[0]) contents = verify_output_type(output_path, []) - print(contents) verify_all_outputs_exist(contents) - except Exception as e: + except (OSError, ValueError, Exception) as e: pytest.fail(f"An error occurred, {e}") - - - - - - #def create_venv(env): # result = subprocess.run(["python", "-m", "venv", env]) # if result.returncode == 0: diff --git a/Testing/Functional/SmokeTests/smoke_test_utils.py b/Testing/Functional/SmokeTests/smoke_test_utils.py index 2bea85d0..ed738900 100644 --- a/Testing/Functional/SmokeTests/smoke_test_utils.py +++ b/Testing/Functional/SmokeTests/smoke_test_utils.py @@ -1,9 +1,10 @@ +import pytest import os required_contents = [ "BaselineReports.html", "IndividualReports", - "ScubaResults.json", + "ProviderExport.json", "TestResults.json", "images", "CalendarReport.html", @@ -20,13 +21,6 @@ "triangle-exclamation-solid.svg" ] -def verify_all_outputs_exist(contents): - for required_content in required_contents: - if required_content in contents: - assert True - else: - assert False, f"{required_content} was not found in the generated report" - def verify_output_type(output_path, contents): entries = os.listdir(output_path) @@ -41,6 +35,13 @@ def verify_output_type(output_path, contents): elif os.path.isfile(child_path): assert True else: - assert False, f"Entry is not a directory or file (symlink, etc.)" + raise OSError(f"Entry is not a directory or file (symlink, etc.)") - return contents \ No newline at end of file + return contents + +def verify_all_outputs_exist(contents): + for required_content in required_contents: + if required_content in contents: + assert True + else: + raise ValueError(f"{required_content} was not found in the generated report") \ No newline at end of file From 3adb447dc1088a3c74dd6ea550bd11bb252458a8 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 20:31:12 +0000 Subject: [PATCH 037/126] create custom action for setting up repo and python version/cache --- .github/actions/initialize_smoke_test.yml | 21 +++++++++++ .github/workflows/run_smoke_test.yml | 35 ++++++++++++------- .../Functional/SmokeTests/smoke_test_utils.py | 2 +- 3 files changed, 45 insertions(+), 13 deletions(-) create mode 100644 .github/actions/initialize_smoke_test.yml diff --git a/.github/actions/initialize_smoke_test.yml b/.github/actions/initialize_smoke_test.yml new file mode 100644 index 00000000..51004f80 --- /dev/null +++ b/.github/actions/initialize_smoke_test.yml @@ -0,0 +1,21 @@ +name: Setup Repository and Python Environment +inputs: + python-version: + required: true + default: "3.12" + cache-dependency-path: + required: true + default: "requirements.txt" + +runs: + using: "composite" + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: ${{ inputs.python-version }} + cache: "pip" + cache-dependency-path: ${{ inputs.cache-dependency-path }} \ No newline at end of file diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 21ddc50c..f1f07ed3 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -15,25 +15,22 @@ on: - "main" - "*smoke*" +env: + GWS_SUBJECT_EMAIL: ${{ secrets.GWS_SUBJECT_EMAIL }} + GWS_GITHUB_AUTOMATION_CREDS: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }} + jobs: smoke-test-windows: - name: Smoke Test for Windows OS + name: Smoke Test for Windows runs-on: windows-latest defaults: run: shell: powershell - env: - GWS_SUBJECT_EMAIL: ${{ secrets.GWS_SUBJECT_EMAIL }} - GWS_GITHUB_AUTOMATION_CREDS: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }} steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Setup Python - uses: actions/setup-python@v5 - with: + - name: Initialize smoke test + uses: cisagov/ScubaGoggles/.github/actions/initialize_smoke_test@v1 + with: python-version: "3.12" - cache: "pip" cache-dependency-path: "requirements.txt" - name: Setup virtualenv @@ -58,4 +55,18 @@ jobs: pip show scubagoggles # Setup credentials for service account Set-Content -Path credentials.json -Value $env:GWS_GITHUB_AUTOMATION_CREDS - pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" \ No newline at end of file + pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" + + smoke-test-macos: + name: Smoke Test for Mac OS + runs-on: macos-latest + steps: + - name: Initialize smoke test + uses: cisagov/ScubaGoggles/.github/actions/initialize_smoke_test@v1 + with: + python-version: "3.12" + cache-dependency-path: "requirements.txt" + + - name: Execute ScubaGoggles and check for correct output + run: | + echo "in second step" \ No newline at end of file diff --git a/Testing/Functional/SmokeTests/smoke_test_utils.py b/Testing/Functional/SmokeTests/smoke_test_utils.py index ed738900..de30c8b2 100644 --- a/Testing/Functional/SmokeTests/smoke_test_utils.py +++ b/Testing/Functional/SmokeTests/smoke_test_utils.py @@ -4,7 +4,7 @@ required_contents = [ "BaselineReports.html", "IndividualReports", - "ProviderExport.json", + "ScubaResults.json", "TestResults.json", "images", "CalendarReport.html", From 7cb00346d33d9cec1fc055cc6fb550d89e48bc3d Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 20:45:43 +0000 Subject: [PATCH 038/126] make macos smoke test depend on windows job --- .github/workflows/run_smoke_test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index f1f07ed3..4b377c35 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -60,6 +60,7 @@ jobs: smoke-test-macos: name: Smoke Test for Mac OS runs-on: macos-latest + needs: smoke-test-windows steps: - name: Initialize smoke test uses: cisagov/ScubaGoggles/.github/actions/initialize_smoke_test@v1 From ce180dd25e56f693db24bd6e43083723e0f91ff4 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 20:50:10 +0000 Subject: [PATCH 039/126] adjust local composite action --- .github/workflows/run_smoke_test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 4b377c35..fed4471f 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -28,7 +28,7 @@ jobs: shell: powershell steps: - name: Initialize smoke test - uses: cisagov/ScubaGoggles/.github/actions/initialize_smoke_test@v1 + uses: ./.github/actions/initialize_smoke_test with: python-version: "3.12" cache-dependency-path: "requirements.txt" @@ -63,7 +63,7 @@ jobs: needs: smoke-test-windows steps: - name: Initialize smoke test - uses: cisagov/ScubaGoggles/.github/actions/initialize_smoke_test@v1 + uses: ./.github/actions/initialize_smoke_test with: python-version: "3.12" cache-dependency-path: "requirements.txt" From 18fb0891e0185b336fa615b97752ea33ecf7c983 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 21:28:34 +0000 Subject: [PATCH 040/126] adjust workflow --- .github/workflows/run_smoke_test.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index fed4471f..0b26901f 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -27,6 +27,9 @@ jobs: run: shell: powershell steps: + - name: Checkout Repository + uses: actions/checkout@v4 + - name: Initialize smoke test uses: ./.github/actions/initialize_smoke_test with: @@ -62,6 +65,9 @@ jobs: runs-on: macos-latest needs: smoke-test-windows steps: + - name: Checkout Repository + uses: actions/checkout@v4 + - name: Initialize smoke test uses: ./.github/actions/initialize_smoke_test with: From 023f66126920ec2de1bbcda2df760c44224269ce Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 21:29:10 +0000 Subject: [PATCH 041/126] adjust workflow --- .github/workflows/run_smoke_test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 0b26901f..0fe8e0a7 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -66,8 +66,8 @@ jobs: needs: smoke-test-windows steps: - name: Checkout Repository - uses: actions/checkout@v4 - + uses: actions/checkout@v4 + - name: Initialize smoke test uses: ./.github/actions/initialize_smoke_test with: From e0acf5344a001563f45fca09b0bee90f277d5a0c Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 21:35:52 +0000 Subject: [PATCH 042/126] modify path structure for initialize-smoke-test action --- .../action.yml} | 0 .github/workflows/run_smoke_test.yml | 6 ------ 2 files changed, 6 deletions(-) rename .github/actions/{initialize_smoke_test.yml => initialize-smoke-test/action.yml} (100%) diff --git a/.github/actions/initialize_smoke_test.yml b/.github/actions/initialize-smoke-test/action.yml similarity index 100% rename from .github/actions/initialize_smoke_test.yml rename to .github/actions/initialize-smoke-test/action.yml diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 0fe8e0a7..fed4471f 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -27,9 +27,6 @@ jobs: run: shell: powershell steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - name: Initialize smoke test uses: ./.github/actions/initialize_smoke_test with: @@ -65,9 +62,6 @@ jobs: runs-on: macos-latest needs: smoke-test-windows steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - name: Initialize smoke test uses: ./.github/actions/initialize_smoke_test with: From df161b6c84af58b9980c566bb2c9d9b6af34dfaf Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 21:41:09 +0000 Subject: [PATCH 043/126] modify path structure for initialize-smoke-test action --- .github/workflows/run_smoke_test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index fed4471f..32417a60 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -28,7 +28,7 @@ jobs: shell: powershell steps: - name: Initialize smoke test - uses: ./.github/actions/initialize_smoke_test + uses: ./.github/actions/initialize-smoke-test with: python-version: "3.12" cache-dependency-path: "requirements.txt" @@ -63,7 +63,7 @@ jobs: needs: smoke-test-windows steps: - name: Initialize smoke test - uses: ./.github/actions/initialize_smoke_test + uses: ./.github/actions/initialize-smoke-test with: python-version: "3.12" cache-dependency-path: "requirements.txt" From d37ce10ebe45c8b11dae1e31ed7c50137df13eb3 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 21:45:46 +0000 Subject: [PATCH 044/126] modify path structure for initialize-smoke-test action --- .github/actions/initialize-smoke-test/action.yml | 3 --- .github/workflows/run_smoke_test.yml | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/actions/initialize-smoke-test/action.yml b/.github/actions/initialize-smoke-test/action.yml index 51004f80..02a69f4b 100644 --- a/.github/actions/initialize-smoke-test/action.yml +++ b/.github/actions/initialize-smoke-test/action.yml @@ -10,9 +10,6 @@ inputs: runs: using: "composite" steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - name: Setup Python uses: actions/setup-python@v5 with: diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 32417a60..e066e3e6 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -27,6 +27,9 @@ jobs: run: shell: powershell steps: + - name: Checkout Repository + uses: actions/checkout@v4 + - name: Initialize smoke test uses: ./.github/actions/initialize-smoke-test with: @@ -62,6 +65,9 @@ jobs: runs-on: macos-latest needs: smoke-test-windows steps: + - name: Checkout Repository + uses: actions/checkout@v4 + - name: Initialize smoke test uses: ./.github/actions/initialize-smoke-test with: From ec7d0afbf41ce697fda82cb8ef07b209e25ed3eb Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 22:17:36 +0000 Subject: [PATCH 045/126] rename action to initialize-scubagoggles; move majority of steps out of workflow into action for reuse --- .../initialize-scubagoggles/action.yml | 51 +++++++++++++++++++ .../actions/initialize-smoke-test/action.yml | 18 ------- .github/workflows/run_smoke_test.yml | 32 ++++-------- 3 files changed, 60 insertions(+), 41 deletions(-) create mode 100644 .github/actions/initialize-scubagoggles/action.yml delete mode 100644 .github/actions/initialize-smoke-test/action.yml diff --git a/.github/actions/initialize-scubagoggles/action.yml b/.github/actions/initialize-scubagoggles/action.yml new file mode 100644 index 00000000..a869e6ba --- /dev/null +++ b/.github/actions/initialize-scubagoggles/action.yml @@ -0,0 +1,51 @@ +name: Initialize ScubaGoggles +inputs: + python-version: + required: true + default: "3.12" + cache-dependency-path: + required: true + default: "requirements.txt" + operating-system: + required: true + default: "windows" + opa-version: + required: true + default: "0.60.0" + +runs: + using: "composite" + steps: + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: ${{ inputs.python-version }} + cache: "pip" + cache-dependency-path: ${{ inputs.cache-dependency-path }} + + - name: Setup virtualenv for Windows + if: ${{ inputs.operating-system == "windows" }} + shell: powershell + run: | + pip install virtualenv + python -m venv .venv + .venv\Scripts\activate + + - name: Setup virtualenv for MacOS + if: ${{ inputs.operating-system == "macos" }} + shell: bash + run: | + pip install virtualenv + virtualenv -p python .venv + source .venv/bin/activate + + - name: Install dependencies + run: | + python -m pip install . + pip install -r requirements.txt + pip install pytest + pip uninstall numpy + pip install -y numpy==1.26.4 + + - name: Download OPA executable + run: python download_opa.py -v ${{ inputs.opa-version }} -os ${{ inputs.operating-system }} diff --git a/.github/actions/initialize-smoke-test/action.yml b/.github/actions/initialize-smoke-test/action.yml deleted file mode 100644 index 02a69f4b..00000000 --- a/.github/actions/initialize-smoke-test/action.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Setup Repository and Python Environment -inputs: - python-version: - required: true - default: "3.12" - cache-dependency-path: - required: true - default: "requirements.txt" - -runs: - using: "composite" - steps: - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: ${{ inputs.python-version }} - cache: "pip" - cache-dependency-path: ${{ inputs.cache-dependency-path }} \ No newline at end of file diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index e066e3e6..32818881 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -29,33 +29,17 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v4 - - - name: Initialize smoke test - uses: ./.github/actions/initialize-smoke-test + + - name: Initialize ScubaGoggles + uses: ./.github/actions/initialize-scubagoggles with: python-version: "3.12" cache-dependency-path: "requirements.txt" - - - name: Setup virtualenv - run: | - pip install virtualenv - python -m venv .venv - .venv\Scripts\activate - - - name: Install dependencies - run: | - python -m pip install . - pip install -r requirements.txt - pip install pytest - pip uninstall numpy - pip install numpy==1.26.4 - - - name: Download OPA executable - run: python download_opa.py -v 0.60.0 -os windows + operating-system: "windows" + opa-version: "0.60.0" - name: Execute ScubaGoggles and check for correct output run: | - pip show scubagoggles # Setup credentials for service account Set-Content -Path credentials.json -Value $env:GWS_GITHUB_AUTOMATION_CREDS pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" @@ -68,11 +52,13 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - - name: Initialize smoke test - uses: ./.github/actions/initialize-smoke-test + - name: Initialize ScubaGoggles + uses: ./.github/actions/initialize-scubagoggles with: python-version: "3.12" cache-dependency-path: "requirements.txt" + operating-system: "macos" + opa-version: "0.60.0" - name: Execute ScubaGoggles and check for correct output run: | From 047dd37ef8394ccc38796db87b23e3906b4704d8 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 22:27:14 +0000 Subject: [PATCH 046/126] action modifications --- .github/actions/initialize-scubagoggles/action.yml | 7 ++++--- .github/workflows/run_smoke_test.yml | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/actions/initialize-scubagoggles/action.yml b/.github/actions/initialize-scubagoggles/action.yml index a869e6ba..9768b837 100644 --- a/.github/actions/initialize-scubagoggles/action.yml +++ b/.github/actions/initialize-scubagoggles/action.yml @@ -24,7 +24,7 @@ runs: cache-dependency-path: ${{ inputs.cache-dependency-path }} - name: Setup virtualenv for Windows - if: ${{ inputs.operating-system == "windows" }} + if: ${{ inputs.operating-system }} == "windows" shell: powershell run: | pip install virtualenv @@ -32,7 +32,7 @@ runs: .venv\Scripts\activate - name: Setup virtualenv for MacOS - if: ${{ inputs.operating-system == "macos" }} + if: ${{ inputs.operating-system }} == "macos" shell: bash run: | pip install virtualenv @@ -40,6 +40,7 @@ runs: source .venv/bin/activate - name: Install dependencies + shell: powershell run: | python -m pip install . pip install -r requirements.txt @@ -48,4 +49,4 @@ runs: pip install -y numpy==1.26.4 - name: Download OPA executable - run: python download_opa.py -v ${{ inputs.opa-version }} -os ${{ inputs.operating-system }} + run: python download_opa.py -v ${{ inputs.opa-version }} -os ${{ inputs.operating-system }} diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 32818881..00391b52 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -62,4 +62,7 @@ jobs: - name: Execute ScubaGoggles and check for correct output run: | - echo "in second step" \ No newline at end of file + echo "in second step" + + # Give OPA executable execute permissions + chmod +x opa_darwin_amd64 \ No newline at end of file From 43f7f7729eab76b0169b3da686a519739f7db829 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 22:29:03 +0000 Subject: [PATCH 047/126] action modifications --- .github/actions/initialize-scubagoggles/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/initialize-scubagoggles/action.yml b/.github/actions/initialize-scubagoggles/action.yml index 9768b837..34abd6af 100644 --- a/.github/actions/initialize-scubagoggles/action.yml +++ b/.github/actions/initialize-scubagoggles/action.yml @@ -49,4 +49,5 @@ runs: pip install -y numpy==1.26.4 - name: Download OPA executable + shell: powershell run: python download_opa.py -v ${{ inputs.opa-version }} -os ${{ inputs.operating-system }} From 1bb3869c0ef34583cdd1c688f8b32e877a9caeda Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 22:34:02 +0000 Subject: [PATCH 048/126] action changes --- .github/workflows/run_smoke_test.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 00391b52..6327ddf7 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -65,4 +65,8 @@ jobs: echo "in second step" # Give OPA executable execute permissions - chmod +x opa_darwin_amd64 \ No newline at end of file + chmod +x opa_darwin_amd64 + + # Setup credentials for service account + echo "$env:GWS_GITHUB_AUTOMATION_CREDS" > credentials.json + pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" From f58f40ef3e2c40446608f548f32f0659e88efe33 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 22:48:53 +0000 Subject: [PATCH 049/126] create separate subactions for windows/mac setup --- .../initialize-scubagoggles/action.yml | 35 ------------------- .../setup-macos-dependencies/action.yml | 29 +++++++++++++++ .../setup-windows-dependencies/action.yml | 29 +++++++++++++++ .github/workflows/run_smoke_test.yml | 8 +++++ 4 files changed, 66 insertions(+), 35 deletions(-) create mode 100644 .github/actions/setup-macos-dependencies/action.yml create mode 100644 .github/actions/setup-windows-dependencies/action.yml diff --git a/.github/actions/initialize-scubagoggles/action.yml b/.github/actions/initialize-scubagoggles/action.yml index 34abd6af..c6021a94 100644 --- a/.github/actions/initialize-scubagoggles/action.yml +++ b/.github/actions/initialize-scubagoggles/action.yml @@ -6,12 +6,6 @@ inputs: cache-dependency-path: required: true default: "requirements.txt" - operating-system: - required: true - default: "windows" - opa-version: - required: true - default: "0.60.0" runs: using: "composite" @@ -22,32 +16,3 @@ runs: python-version: ${{ inputs.python-version }} cache: "pip" cache-dependency-path: ${{ inputs.cache-dependency-path }} - - - name: Setup virtualenv for Windows - if: ${{ inputs.operating-system }} == "windows" - shell: powershell - run: | - pip install virtualenv - python -m venv .venv - .venv\Scripts\activate - - - name: Setup virtualenv for MacOS - if: ${{ inputs.operating-system }} == "macos" - shell: bash - run: | - pip install virtualenv - virtualenv -p python .venv - source .venv/bin/activate - - - name: Install dependencies - shell: powershell - run: | - python -m pip install . - pip install -r requirements.txt - pip install pytest - pip uninstall numpy - pip install -y numpy==1.26.4 - - - name: Download OPA executable - shell: powershell - run: python download_opa.py -v ${{ inputs.opa-version }} -os ${{ inputs.operating-system }} diff --git a/.github/actions/setup-macos-dependencies/action.yml b/.github/actions/setup-macos-dependencies/action.yml new file mode 100644 index 00000000..99aba67d --- /dev/null +++ b/.github/actions/setup-macos-dependencies/action.yml @@ -0,0 +1,29 @@ +name: Setup MacOS Dependencies +inputs: + operating-system: + required: true + default: "macos" + opa-version: + required: true + default: "0.60.0" + +runs: + using: "composite" + shell: bash + steps: + - name: Setup virtualenv + run: | + pip install virtualenv + virtualenv -p python .venv + source .venv/bin/activate + + - name: Install dependencies + run: | + python -m pip install . + pip install -r requirements.txt + pip install pytest + pip uninstall numpy + pip install -y numpy==1.26.4 + + - name: Download OPA executable + run: python download_opa.py -v ${{ inputs.opa-version }} -os ${{ inputs.operating-system }} \ No newline at end of file diff --git a/.github/actions/setup-windows-dependencies/action.yml b/.github/actions/setup-windows-dependencies/action.yml new file mode 100644 index 00000000..3aeff045 --- /dev/null +++ b/.github/actions/setup-windows-dependencies/action.yml @@ -0,0 +1,29 @@ +name: Setup Windows Dependencies +inputs: + operating-system: + required: true + default: "windows" + opa-version: + required: true + default: "0.60.0" + +runs: + using: "composite" + shell: powershell + steps: + - name: Setup virtualenv + run: | + pip install virtualenv + python -m venv .venv + .venv\Scripts\activate + + - name: Install dependencies + run: | + python -m pip install . + pip install -r requirements.txt + pip install pytest + pip uninstall numpy + pip install -y numpy==1.26.4 + + - name: Download OPA executable + run: python download_opa.py -v ${{ inputs.opa-version }} -os ${{ inputs.operating-system }} \ No newline at end of file diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 6327ddf7..923de698 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -35,6 +35,10 @@ jobs: with: python-version: "3.12" cache-dependency-path: "requirements.txt" + + - name: Setup Windows dependencies + uses: ./.github/actions/setup-windows-dependencies + with: operating-system: "windows" opa-version: "0.60.0" @@ -57,6 +61,10 @@ jobs: with: python-version: "3.12" cache-dependency-path: "requirements.txt" + + - name: Setup MacOS dependencies + uses: ./.github/actions/setup-macos-dependencies + with: operating-system: "macos" opa-version: "0.60.0" From 6e1b2985e1fbf819a946f8dc672af463240abfcd Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 22:51:21 +0000 Subject: [PATCH 050/126] fix location of shell property --- .github/actions/setup-macos-dependencies/action.yml | 4 +++- .github/actions/setup-windows-dependencies/action.yml | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/actions/setup-macos-dependencies/action.yml b/.github/actions/setup-macos-dependencies/action.yml index 99aba67d..f6a0ce34 100644 --- a/.github/actions/setup-macos-dependencies/action.yml +++ b/.github/actions/setup-macos-dependencies/action.yml @@ -9,15 +9,16 @@ inputs: runs: using: "composite" - shell: bash steps: - name: Setup virtualenv + shell: bash run: | pip install virtualenv virtualenv -p python .venv source .venv/bin/activate - name: Install dependencies + shell: bash run: | python -m pip install . pip install -r requirements.txt @@ -26,4 +27,5 @@ runs: pip install -y numpy==1.26.4 - name: Download OPA executable + shell: bash run: python download_opa.py -v ${{ inputs.opa-version }} -os ${{ inputs.operating-system }} \ No newline at end of file diff --git a/.github/actions/setup-windows-dependencies/action.yml b/.github/actions/setup-windows-dependencies/action.yml index 3aeff045..05d25e6d 100644 --- a/.github/actions/setup-windows-dependencies/action.yml +++ b/.github/actions/setup-windows-dependencies/action.yml @@ -9,15 +9,16 @@ inputs: runs: using: "composite" - shell: powershell steps: - name: Setup virtualenv + shell: powershell run: | pip install virtualenv python -m venv .venv .venv\Scripts\activate - name: Install dependencies + shell: powershell run: | python -m pip install . pip install -r requirements.txt @@ -26,4 +27,5 @@ runs: pip install -y numpy==1.26.4 - name: Download OPA executable + shell: powershell run: python download_opa.py -v ${{ inputs.opa-version }} -os ${{ inputs.operating-system }} \ No newline at end of file From 0ca71158d0e81f4d9d6c03c8aca9771b28bcf247 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 22:53:24 +0000 Subject: [PATCH 051/126] workflow adjustment --- .github/workflows/run_smoke_test.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 923de698..4b851bc6 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -36,7 +36,7 @@ jobs: python-version: "3.12" cache-dependency-path: "requirements.txt" - - name: Setup Windows dependencies + - name: Setup dependencies uses: ./.github/actions/setup-windows-dependencies with: operating-system: "windows" @@ -51,6 +51,9 @@ jobs: smoke-test-macos: name: Smoke Test for Mac OS runs-on: macos-latest + defaults: + run: + shell: bash needs: smoke-test-windows steps: - name: Checkout Repository @@ -62,7 +65,7 @@ jobs: python-version: "3.12" cache-dependency-path: "requirements.txt" - - name: Setup MacOS dependencies + - name: Setup dependencies uses: ./.github/actions/setup-macos-dependencies with: operating-system: "macos" From 551361c0eea1dc8ee2d14ddfb602e79f2e471257 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 22:55:23 +0000 Subject: [PATCH 052/126] workflow adjustment --- .github/actions/setup-macos-dependencies/action.yml | 2 +- .github/actions/setup-windows-dependencies/action.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/setup-macos-dependencies/action.yml b/.github/actions/setup-macos-dependencies/action.yml index f6a0ce34..af5084bc 100644 --- a/.github/actions/setup-macos-dependencies/action.yml +++ b/.github/actions/setup-macos-dependencies/action.yml @@ -24,7 +24,7 @@ runs: pip install -r requirements.txt pip install pytest pip uninstall numpy - pip install -y numpy==1.26.4 + pip install numpy==1.26.4 - name: Download OPA executable shell: bash diff --git a/.github/actions/setup-windows-dependencies/action.yml b/.github/actions/setup-windows-dependencies/action.yml index 05d25e6d..9ee62ebc 100644 --- a/.github/actions/setup-windows-dependencies/action.yml +++ b/.github/actions/setup-windows-dependencies/action.yml @@ -24,7 +24,7 @@ runs: pip install -r requirements.txt pip install pytest pip uninstall numpy - pip install -y numpy==1.26.4 + pip install numpy==1.26.4 - name: Download OPA executable shell: powershell From 05d92ec46ebbc035daa3a1f9991d95524ccb6fa4 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 22:59:51 +0000 Subject: [PATCH 053/126] rename to setup python --- .../{initialize-scubagoggles => setup-python}/action.yml | 2 +- .github/workflows/run_smoke_test.yml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) rename .github/actions/{initialize-scubagoggles => setup-python}/action.yml (92%) diff --git a/.github/actions/initialize-scubagoggles/action.yml b/.github/actions/setup-python/action.yml similarity index 92% rename from .github/actions/initialize-scubagoggles/action.yml rename to .github/actions/setup-python/action.yml index c6021a94..587d4596 100644 --- a/.github/actions/initialize-scubagoggles/action.yml +++ b/.github/actions/setup-python/action.yml @@ -1,4 +1,4 @@ -name: Initialize ScubaGoggles +name: Setup Python inputs: python-version: required: true diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 4b851bc6..4a20b078 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -30,8 +30,8 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - - name: Initialize ScubaGoggles - uses: ./.github/actions/initialize-scubagoggles + - name: Setup Python + uses: ./.github/actions/setup-python with: python-version: "3.12" cache-dependency-path: "requirements.txt" @@ -59,8 +59,8 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - - name: Initialize ScubaGoggles - uses: ./.github/actions/initialize-scubagoggles + - name: Setup Python + uses: ./.github/actions/setup-python with: python-version: "3.12" cache-dependency-path: "requirements.txt" From 0ead797c666886c868858201236b01f47ccafa09 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 23:16:33 +0000 Subject: [PATCH 054/126] add -y to bypass confirmation --- .github/actions/setup-macos-dependencies/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-macos-dependencies/action.yml b/.github/actions/setup-macos-dependencies/action.yml index af5084bc..1d46ca2f 100644 --- a/.github/actions/setup-macos-dependencies/action.yml +++ b/.github/actions/setup-macos-dependencies/action.yml @@ -23,7 +23,7 @@ runs: python -m pip install . pip install -r requirements.txt pip install pytest - pip uninstall numpy + pip uninstall -y numpy pip install numpy==1.26.4 - name: Download OPA executable From f6152465ca170b3b6127277c057ff8c6b5675d24 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 23:19:02 +0000 Subject: [PATCH 055/126] try removing shell from actions and keep in workflow --- .github/actions/setup-macos-dependencies/action.yml | 3 --- .github/actions/setup-windows-dependencies/action.yml | 3 --- 2 files changed, 6 deletions(-) diff --git a/.github/actions/setup-macos-dependencies/action.yml b/.github/actions/setup-macos-dependencies/action.yml index 1d46ca2f..5d6209f3 100644 --- a/.github/actions/setup-macos-dependencies/action.yml +++ b/.github/actions/setup-macos-dependencies/action.yml @@ -11,14 +11,12 @@ runs: using: "composite" steps: - name: Setup virtualenv - shell: bash run: | pip install virtualenv virtualenv -p python .venv source .venv/bin/activate - name: Install dependencies - shell: bash run: | python -m pip install . pip install -r requirements.txt @@ -27,5 +25,4 @@ runs: pip install numpy==1.26.4 - name: Download OPA executable - shell: bash run: python download_opa.py -v ${{ inputs.opa-version }} -os ${{ inputs.operating-system }} \ No newline at end of file diff --git a/.github/actions/setup-windows-dependencies/action.yml b/.github/actions/setup-windows-dependencies/action.yml index 9ee62ebc..26cbcf67 100644 --- a/.github/actions/setup-windows-dependencies/action.yml +++ b/.github/actions/setup-windows-dependencies/action.yml @@ -11,14 +11,12 @@ runs: using: "composite" steps: - name: Setup virtualenv - shell: powershell run: | pip install virtualenv python -m venv .venv .venv\Scripts\activate - name: Install dependencies - shell: powershell run: | python -m pip install . pip install -r requirements.txt @@ -27,5 +25,4 @@ runs: pip install numpy==1.26.4 - name: Download OPA executable - shell: powershell run: python download_opa.py -v ${{ inputs.opa-version }} -os ${{ inputs.operating-system }} \ No newline at end of file From 9b56dc991ebde3415d0d37fd8551d82e7a2a72ed Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 23:21:43 +0000 Subject: [PATCH 056/126] trigger workflow --- .github/workflows/run_smoke_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 4a20b078..bdf5ad2c 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -49,7 +49,7 @@ jobs: pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" smoke-test-macos: - name: Smoke Test for Mac OS + name: Smoke Test for MacOS runs-on: macos-latest defaults: run: From fb3443f737554485b2a277187803c143554abc53 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 23:24:24 +0000 Subject: [PATCH 057/126] readd shell param --- .github/actions/setup-macos-dependencies/action.yml | 3 +++ .github/actions/setup-windows-dependencies/action.yml | 3 +++ .github/workflows/run_smoke_test.yml | 6 ------ 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/actions/setup-macos-dependencies/action.yml b/.github/actions/setup-macos-dependencies/action.yml index 5d6209f3..1d46ca2f 100644 --- a/.github/actions/setup-macos-dependencies/action.yml +++ b/.github/actions/setup-macos-dependencies/action.yml @@ -11,12 +11,14 @@ runs: using: "composite" steps: - name: Setup virtualenv + shell: bash run: | pip install virtualenv virtualenv -p python .venv source .venv/bin/activate - name: Install dependencies + shell: bash run: | python -m pip install . pip install -r requirements.txt @@ -25,4 +27,5 @@ runs: pip install numpy==1.26.4 - name: Download OPA executable + shell: bash run: python download_opa.py -v ${{ inputs.opa-version }} -os ${{ inputs.operating-system }} \ No newline at end of file diff --git a/.github/actions/setup-windows-dependencies/action.yml b/.github/actions/setup-windows-dependencies/action.yml index 26cbcf67..9ee62ebc 100644 --- a/.github/actions/setup-windows-dependencies/action.yml +++ b/.github/actions/setup-windows-dependencies/action.yml @@ -11,12 +11,14 @@ runs: using: "composite" steps: - name: Setup virtualenv + shell: powershell run: | pip install virtualenv python -m venv .venv .venv\Scripts\activate - name: Install dependencies + shell: powershell run: | python -m pip install . pip install -r requirements.txt @@ -25,4 +27,5 @@ runs: pip install numpy==1.26.4 - name: Download OPA executable + shell: powershell run: python download_opa.py -v ${{ inputs.opa-version }} -os ${{ inputs.operating-system }} \ No newline at end of file diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index bdf5ad2c..937f1ff2 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -23,9 +23,6 @@ jobs: smoke-test-windows: name: Smoke Test for Windows runs-on: windows-latest - defaults: - run: - shell: powershell steps: - name: Checkout Repository uses: actions/checkout@v4 @@ -51,9 +48,6 @@ jobs: smoke-test-macos: name: Smoke Test for MacOS runs-on: macos-latest - defaults: - run: - shell: bash needs: smoke-test-windows steps: - name: Checkout Repository From 5720e29f20adebc1029d0586633f8c5e60436e56 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 23:38:52 +0000 Subject: [PATCH 058/126] fix credentials.json for macos job --- .github/workflows/run_smoke_test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 937f1ff2..57089f23 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -73,5 +73,6 @@ jobs: chmod +x opa_darwin_amd64 # Setup credentials for service account - echo "$env:GWS_GITHUB_AUTOMATION_CREDS" > credentials.json + echo $env:GWS_GITHUB_AUTOMATION_CREDS > credentials.json + cat credentials.json pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" From 6fe521934e27fa5b17c187940c48bdf92dddc7f9 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 23:54:45 +0000 Subject: [PATCH 059/126] test macos --- .github/workflows/run_smoke_test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 57089f23..32e227e2 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -21,6 +21,7 @@ env: jobs: smoke-test-windows: + if: false name: Smoke Test for Windows runs-on: windows-latest steps: @@ -48,7 +49,7 @@ jobs: smoke-test-macos: name: Smoke Test for MacOS runs-on: macos-latest - needs: smoke-test-windows + #needs: smoke-test-windows steps: - name: Checkout Repository uses: actions/checkout@v4 From 790cc5c1b237e34321102ef73104efac7802f031 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Sat, 27 Jul 2024 00:04:54 +0000 Subject: [PATCH 060/126] comment pytest in mac run so cache completes --- .github/workflows/run_smoke_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 32e227e2..218d3c87 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -76,4 +76,4 @@ jobs: # Setup credentials for service account echo $env:GWS_GITHUB_AUTOMATION_CREDS > credentials.json cat credentials.json - pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" + #pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" From a646b0332c77e5484539ca8caba9767610ee6da7 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Tue, 30 Jul 2024 23:04:50 +0000 Subject: [PATCH 061/126] see if credentials.json is created --- .github/workflows/run_smoke_test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 218d3c87..a377e786 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -74,6 +74,7 @@ jobs: chmod +x opa_darwin_amd64 # Setup credentials for service account - echo $env:GWS_GITHUB_AUTOMATION_CREDS > credentials.json + echo $env:GWS_GITHUB_AUTOMATION_CREDS + echo $env:GWS_GITHUB_AUTOMATION_CREDS >> credentials.json cat credentials.json #pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" From e387aeb88669036393174b09fa3695c575c86742 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Tue, 30 Jul 2024 23:19:34 +0000 Subject: [PATCH 062/126] try converting workflow to matrix --- .github/workflows/run_smoke_test.yml | 103 ++++++++++++++++++++------- 1 file changed, 77 insertions(+), 26 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index a377e786..e31a832d 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -20,10 +20,12 @@ env: GWS_GITHUB_AUTOMATION_CREDS: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }} jobs: - smoke-test-windows: - if: false - name: Smoke Test for Windows - runs-on: windows-latest + smoke-test: + strategy: + matrix: + os: [windows-latest, macos-latest] + python-version: [3.8.4, 3.12] + runs-on: ${{ matrix.os }} steps: - name: Checkout Repository uses: actions/checkout@v4 @@ -31,42 +33,32 @@ jobs: - name: Setup Python uses: ./.github/actions/setup-python with: - python-version: "3.12" + python-version: ${{ matrix.python-version }} cache-dependency-path: "requirements.txt" - - name: Setup dependencies + - name: Setup Windows dependencies + if: ${{ matrix.os }} == "windows-latest" uses: ./.github/actions/setup-windows-dependencies with: operating-system: "windows" opa-version: "0.60.0" + + - name: Setup macOS dependencies + if: ${{ matrix.os }} == "macos-latest" + uses: ./.github/actions/setup-windows-dependencies + with: + operating-system: "macos" + opa-version: "0.60.0" - name: Execute ScubaGoggles and check for correct output + if: ${{ matrix.os }} == "windows-latest" run: | # Setup credentials for service account Set-Content -Path credentials.json -Value $env:GWS_GITHUB_AUTOMATION_CREDS pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" - - smoke-test-macos: - name: Smoke Test for MacOS - runs-on: macos-latest - #needs: smoke-test-windows - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Setup Python - uses: ./.github/actions/setup-python - with: - python-version: "3.12" - cache-dependency-path: "requirements.txt" - - - name: Setup dependencies - uses: ./.github/actions/setup-macos-dependencies - with: - operating-system: "macos" - opa-version: "0.60.0" - name: Execute ScubaGoggles and check for correct output + if: ${{ matrix.os }} == "macos-latest" run: | echo "in second step" @@ -78,3 +70,62 @@ jobs: echo $env:GWS_GITHUB_AUTOMATION_CREDS >> credentials.json cat credentials.json #pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" + + #smoke-test-windows: + # if: false + # name: Smoke Test for Windows + # runs-on: windows-latest + # steps: + # - name: Checkout Repository + # uses: actions/checkout@v4 +# + # - name: Setup Python + # uses: ./.github/actions/setup-python + # with: + # python-version: "3.12" + # cache-dependency-path: "requirements.txt" + # + # - name: Setup dependencies + # uses: ./.github/actions/setup-windows-dependencies + # with: + # operating-system: "windows" + # opa-version: "0.60.0" +# + # - name: Execute ScubaGoggles and check for correct output + # run: | + # # Setup credentials for service account + # Set-Content -Path credentials.json -Value $env:GWS_GITHUB_AUTOMATION_CREDS + # pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" + # + #smoke-test-macos: + # name: Smoke Test for MacOS + # runs-on: macos-latest + # #needs: smoke-test-windows + # steps: + # - name: Checkout Repository + # uses: actions/checkout@v4 +# + # - name: Setup Python + # uses: ./.github/actions/setup-python + # with: + # python-version: "3.12" + # cache-dependency-path: "requirements.txt" + # + # - name: Setup dependencies + # uses: ./.github/actions/setup-macos-dependencies + # with: + # operating-system: "macos" + # opa-version: "0.60.0" + # + # - name: Execute ScubaGoggles and check for correct output + # run: | + # echo "in second step" + # + # # Give OPA executable execute permissions + # chmod +x opa_darwin_amd64 +# + # # Setup credentials for service account + # echo $env:GWS_GITHUB_AUTOMATION_CREDS + # echo $env:GWS_GITHUB_AUTOMATION_CREDS >> credentials.json + # cat credentials.json + # #pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" From 0b3ce1606ba8436f350e66db07105dada46ae419 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Tue, 30 Jul 2024 23:21:56 +0000 Subject: [PATCH 063/126] try converting workflow to matrix --- .github/workflows/run_smoke_test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index e31a832d..ad4a7c83 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -24,7 +24,7 @@ jobs: strategy: matrix: os: [windows-latest, macos-latest] - python-version: [3.8.4, 3.12] + python: [3.8.4, 3.12] runs-on: ${{ matrix.os }} steps: - name: Checkout Repository @@ -33,7 +33,7 @@ jobs: - name: Setup Python uses: ./.github/actions/setup-python with: - python-version: ${{ matrix.python-version }} + python-version: ${{ matrix.python }} cache-dependency-path: "requirements.txt" - name: Setup Windows dependencies From fae6b7347751648938412356e9e48a93085d897b Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Tue, 30 Jul 2024 23:26:34 +0000 Subject: [PATCH 064/126] try converting workflow to matrix --- .github/workflows/run_smoke_test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index ad4a7c83..c38394b1 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -22,9 +22,10 @@ env: jobs: smoke-test: strategy: + fail-fast: false matrix: os: [windows-latest, macos-latest] - python: [3.8.4, 3.12] + python: [3.8, 3.12] runs-on: ${{ matrix.os }} steps: - name: Checkout Repository From 515181d83981948348ddf6c89d3e2081b3c38ddc Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Tue, 30 Jul 2024 23:30:23 +0000 Subject: [PATCH 065/126] test matrix version --- .github/workflows/run_smoke_test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index c38394b1..05a09b59 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -38,28 +38,28 @@ jobs: cache-dependency-path: "requirements.txt" - name: Setup Windows dependencies - if: ${{ matrix.os }} == "windows-latest" + if: ${{ matrix.os == "windows-latest" }} uses: ./.github/actions/setup-windows-dependencies with: operating-system: "windows" opa-version: "0.60.0" - name: Setup macOS dependencies - if: ${{ matrix.os }} == "macos-latest" + if: ${{ matrix.os == "macos-latest" }} uses: ./.github/actions/setup-windows-dependencies with: operating-system: "macos" opa-version: "0.60.0" - name: Execute ScubaGoggles and check for correct output - if: ${{ matrix.os }} == "windows-latest" + if: ${{ matrix.os == "windows-latest" }} run: | # Setup credentials for service account Set-Content -Path credentials.json -Value $env:GWS_GITHUB_AUTOMATION_CREDS pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" - name: Execute ScubaGoggles and check for correct output - if: ${{ matrix.os }} == "macos-latest" + if: ${{ matrix.os == "macos-latest" }} run: | echo "in second step" From 7dd6c70aa225adac302267fa84592e4c01fdb4af Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Tue, 30 Jul 2024 23:46:42 +0000 Subject: [PATCH 066/126] lets see if refactoring into separate workflow changes things --- .github/workflows/run_scubagoggles.yml | 52 ++++++++++++++++++++ .github/workflows/run_smoke_test.yml | 68 ++++++++++++++------------ 2 files changed, 88 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/run_scubagoggles.yml diff --git a/.github/workflows/run_scubagoggles.yml b/.github/workflows/run_scubagoggles.yml new file mode 100644 index 00000000..5173a217 --- /dev/null +++ b/.github/workflows/run_scubagoggles.yml @@ -0,0 +1,52 @@ +name: Run ScubaGoggles +on: + workflow_call: + inputs: + os: + required: true + workflow_dispatch: + +jobs: + run-scubagoggles-windows: + if: ${{ inputs.os }} == "windows-latest" + runs-on: windows-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup dependencies + uses: ./.github/actions/setup-windows-dependencies + with: + operating-system: "windows" + opa-version: "0.60.0" + + - name: Execute ScubaGoggles and check for correct output + run: | + # Setup credentials for service account + Set-Content -Path credentials.json -Value $env:GWS_GITHUB_AUTOMATION_CREDS + pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" + + run-scubagoggles-macos: + if: ${{ inputs.os }} == "macos-latest" + runs-on: macos-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup dependencies + uses: ./.github/actions/setup-macos-dependencies + with: + operating-system: "macos" + opa-version: "0.60.0" + + - name: Execute ScubaGoggles and check for correct output + run: | + echo "in second step" + + # Give OPA executable execute permissions + chmod +x opa_darwin_amd64 + # Setup credentials for service account + echo $env:GWS_GITHUB_AUTOMATION_CREDS + echo $env:GWS_GITHUB_AUTOMATION_CREDS >> credentials.json + cat credentials.json + #pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 05a09b59..2b8c935b 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -37,40 +37,44 @@ jobs: python-version: ${{ matrix.python }} cache-dependency-path: "requirements.txt" - - name: Setup Windows dependencies - if: ${{ matrix.os == "windows-latest" }} - uses: ./.github/actions/setup-windows-dependencies - with: - operating-system: "windows" - opa-version: "0.60.0" - - - name: Setup macOS dependencies - if: ${{ matrix.os == "macos-latest" }} - uses: ./.github/actions/setup-windows-dependencies - with: - operating-system: "macos" + - name: Setup and Run ScubaGoggles + uses: ./.github/workflows/run_scubagoggles + with: + os: ${{ matrix.os }} opa-version: "0.60.0" - - - name: Execute ScubaGoggles and check for correct output - if: ${{ matrix.os == "windows-latest" }} - run: | - # Setup credentials for service account - Set-Content -Path credentials.json -Value $env:GWS_GITHUB_AUTOMATION_CREDS - pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" - - name: Execute ScubaGoggles and check for correct output - if: ${{ matrix.os == "macos-latest" }} - run: | - echo "in second step" - - # Give OPA executable execute permissions - chmod +x opa_darwin_amd64 - - # Setup credentials for service account - echo $env:GWS_GITHUB_AUTOMATION_CREDS - echo $env:GWS_GITHUB_AUTOMATION_CREDS >> credentials.json - cat credentials.json - #pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" + #- name: Setup Windows dependencies + # uses: ./.github/actions/setup-windows-dependencies + # with: + # operating-system: "windows" + # opa-version: "0.60.0" + # + #- name: Setup macOS dependencies + # uses: ./.github/actions/setup-windows-dependencies + # with: + # operating-system: "macos" + # opa-version: "0.60.0" +# + #- name: Execute ScubaGoggles and check for correct output + # if: ${{ matrix.os == "windows-latest" }} + # run: | + # # Setup credentials for service account + # Set-Content -Path credentials.json -Value $env:GWS_GITHUB_AUTOMATION_CREDS + # pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" + # + #- name: Execute ScubaGoggles and check for correct output + # if: ${{ matrix.os == "macos-latest" }} + # run: | + # echo "in second step" + # + # # Give OPA executable execute permissions + # chmod +x opa_darwin_amd64 +# + # # Setup credentials for service account + # echo $env:GWS_GITHUB_AUTOMATION_CREDS + # echo $env:GWS_GITHUB_AUTOMATION_CREDS >> credentials.json + # cat credentials.json + # #pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" #smoke-test-windows: # if: false From beefd50aa8ddc45606616fa1115d8cdabfc8b4a4 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Tue, 30 Jul 2024 23:55:09 +0000 Subject: [PATCH 067/126] retry conditionals --- .github/workflows/run_smoke_test.yml | 68 +++++++++++++--------------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 2b8c935b..17c2c3a3 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -37,44 +37,40 @@ jobs: python-version: ${{ matrix.python }} cache-dependency-path: "requirements.txt" - - name: Setup and Run ScubaGoggles - uses: ./.github/workflows/run_scubagoggles - with: - os: ${{ matrix.os }} + - name: Setup Windows dependencies + if: matrix.os = "windows-latest" + uses: ./.github/actions/setup-windows-dependencies + with: + operating-system: "windows" opa-version: "0.60.0" - #- name: Setup Windows dependencies - # uses: ./.github/actions/setup-windows-dependencies - # with: - # operating-system: "windows" - # opa-version: "0.60.0" - # - #- name: Setup macOS dependencies - # uses: ./.github/actions/setup-windows-dependencies - # with: - # operating-system: "macos" - # opa-version: "0.60.0" -# - #- name: Execute ScubaGoggles and check for correct output - # if: ${{ matrix.os == "windows-latest" }} - # run: | - # # Setup credentials for service account - # Set-Content -Path credentials.json -Value $env:GWS_GITHUB_AUTOMATION_CREDS - # pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" - # - #- name: Execute ScubaGoggles and check for correct output - # if: ${{ matrix.os == "macos-latest" }} - # run: | - # echo "in second step" - # - # # Give OPA executable execute permissions - # chmod +x opa_darwin_amd64 -# - # # Setup credentials for service account - # echo $env:GWS_GITHUB_AUTOMATION_CREDS - # echo $env:GWS_GITHUB_AUTOMATION_CREDS >> credentials.json - # cat credentials.json - # #pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" + - name: Setup macOS dependencies + if: matrix.os = "mac-latest" + uses: ./.github/actions/setup-windows-dependencies + with: + operating-system: "macos" + opa-version: "0.60.0" + + - name: Execute ScubaGoggles and check for correct output + if: matrix.os = "windows-latest" + run: | + # Setup credentials for service account + Set-Content -Path credentials.json -Value $env:GWS_GITHUB_AUTOMATION_CREDS + pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" + + - name: Execute ScubaGoggles and check for correct output + if: matrix.os == "macos-latest" + run: | + echo "in second step" + + # Give OPA executable execute permissions + chmod +x opa_darwin_amd64 + + # Setup credentials for service account + echo $env:GWS_GITHUB_AUTOMATION_CREDS + echo $env:GWS_GITHUB_AUTOMATION_CREDS >> credentials.json + cat credentials.json + #pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" #smoke-test-windows: # if: false From c73c465f80b7843a73f37c58b34c4dcc00214cc3 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Tue, 30 Jul 2024 23:55:54 +0000 Subject: [PATCH 068/126] commit --- .github/workflows/run_smoke_test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 17c2c3a3..de0ef125 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -38,21 +38,21 @@ jobs: cache-dependency-path: "requirements.txt" - name: Setup Windows dependencies - if: matrix.os = "windows-latest" + if: matrix.os == "windows-latest" uses: ./.github/actions/setup-windows-dependencies with: operating-system: "windows" opa-version: "0.60.0" - name: Setup macOS dependencies - if: matrix.os = "mac-latest" + if: matrix.os == "mac-latest" uses: ./.github/actions/setup-windows-dependencies with: operating-system: "macos" opa-version: "0.60.0" - name: Execute ScubaGoggles and check for correct output - if: matrix.os = "windows-latest" + if: matrix.os == "windows-latest" run: | # Setup credentials for service account Set-Content -Path credentials.json -Value $env:GWS_GITHUB_AUTOMATION_CREDS From 69a3a7236419d1ca1cf396ebeeae6f4aa2ca2f6e Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 00:01:11 +0000 Subject: [PATCH 069/126] commit --- .github/workflows/run_smoke_test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index de0ef125..f718ada1 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -38,28 +38,28 @@ jobs: cache-dependency-path: "requirements.txt" - name: Setup Windows dependencies - if: matrix.os == "windows-latest" + if: ${{ matrix.os == "windows-latest" }} uses: ./.github/actions/setup-windows-dependencies with: operating-system: "windows" opa-version: "0.60.0" - name: Setup macOS dependencies - if: matrix.os == "mac-latest" + if: ${{ matrix.os == "macos-latest" }} uses: ./.github/actions/setup-windows-dependencies with: operating-system: "macos" opa-version: "0.60.0" - name: Execute ScubaGoggles and check for correct output - if: matrix.os == "windows-latest" + if: ${{ matrix.os == "windows-latest" }} run: | # Setup credentials for service account Set-Content -Path credentials.json -Value $env:GWS_GITHUB_AUTOMATION_CREDS pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" - name: Execute ScubaGoggles and check for correct output - if: matrix.os == "macos-latest" + if: ${{ matrix.os == "macos-latest" }} run: | echo "in second step" From 8e259a2e45502824df14e82a3aacd91c20fa0f26 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 00:03:09 +0000 Subject: [PATCH 070/126] commit --- .github/workflows/run_smoke_test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index f718ada1..5a59af1a 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -38,28 +38,28 @@ jobs: cache-dependency-path: "requirements.txt" - name: Setup Windows dependencies - if: ${{ matrix.os == "windows-latest" }} + if: ${{ matrix.os == 'windows-latest' }} uses: ./.github/actions/setup-windows-dependencies with: operating-system: "windows" opa-version: "0.60.0" - name: Setup macOS dependencies - if: ${{ matrix.os == "macos-latest" }} + if: ${{ matrix.os == 'macos-latest' }} uses: ./.github/actions/setup-windows-dependencies with: operating-system: "macos" opa-version: "0.60.0" - name: Execute ScubaGoggles and check for correct output - if: ${{ matrix.os == "windows-latest" }} + if: ${{ matrix.os == 'windows-latest' }} run: | # Setup credentials for service account Set-Content -Path credentials.json -Value $env:GWS_GITHUB_AUTOMATION_CREDS pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" - name: Execute ScubaGoggles and check for correct output - if: ${{ matrix.os == "macos-latest" }} + if: ${{ matrix.os == 'macos-latest' }} run: | echo "in second step" From 67f836673fe6082a978ccfc4300572837d4d7af7 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 00:16:36 +0000 Subject: [PATCH 071/126] fairly major change to structure.. should be clear on which action to navigate to whether its windows/mac --- .../action.yml | 16 +++++- .../action.yml | 10 +++- .github/workflows/run_scubagoggles.yml | 52 ------------------- .github/workflows/run_smoke_test.yml | 34 ++++-------- 4 files changed, 31 insertions(+), 81 deletions(-) rename .github/actions/{setup-macos-dependencies => setup-dependencies-macos}/action.yml (59%) rename .github/actions/{setup-windows-dependencies => setup-dependencies-windows}/action.yml (72%) delete mode 100644 .github/workflows/run_scubagoggles.yml diff --git a/.github/actions/setup-macos-dependencies/action.yml b/.github/actions/setup-dependencies-macos/action.yml similarity index 59% rename from .github/actions/setup-macos-dependencies/action.yml rename to .github/actions/setup-dependencies-macos/action.yml index 1d46ca2f..1f995089 100644 --- a/.github/actions/setup-macos-dependencies/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -1,4 +1,4 @@ -name: Setup MacOS Dependencies +name: Setup Dependencies (macOS) inputs: operating-system: required: true @@ -28,4 +28,16 @@ runs: - name: Download OPA executable shell: bash - run: python download_opa.py -v ${{ inputs.opa-version }} -os ${{ inputs.operating-system }} \ No newline at end of file + run: python download_opa.py -v ${{ inputs.opa-version }} -os ${{ inputs.operating-system }} + + - name: Setup credentials for service account + shell: bash + run: | + echo "in second step" + + # Give OPA executable execute permissions + chmod +x opa_darwin_amd64 + # Setup credentials for service account + echo $env:GWS_GITHUB_AUTOMATION_CREDS + echo $env:GWS_GITHUB_AUTOMATION_CREDS >> credentials.json + cat credentials.json \ No newline at end of file diff --git a/.github/actions/setup-windows-dependencies/action.yml b/.github/actions/setup-dependencies-windows/action.yml similarity index 72% rename from .github/actions/setup-windows-dependencies/action.yml rename to .github/actions/setup-dependencies-windows/action.yml index 9ee62ebc..42d2c2f1 100644 --- a/.github/actions/setup-windows-dependencies/action.yml +++ b/.github/actions/setup-dependencies-windows/action.yml @@ -1,4 +1,4 @@ -name: Setup Windows Dependencies +name: Setup Dependencies (Windows) inputs: operating-system: required: true @@ -6,6 +6,8 @@ inputs: opa-version: required: true default: "0.60.0" + credentials: + required: true runs: using: "composite" @@ -28,4 +30,8 @@ runs: - name: Download OPA executable shell: powershell - run: python download_opa.py -v ${{ inputs.opa-version }} -os ${{ inputs.operating-system }} \ No newline at end of file + run: python download_opa.py -v ${{ inputs.opa-version }} -os ${{ inputs.operating-system }} + + - name: Setup credentials for service account + shell: powershell + run: Set-Content -Path credentials.json -Value ${{ inputs.credentials }} \ No newline at end of file diff --git a/.github/workflows/run_scubagoggles.yml b/.github/workflows/run_scubagoggles.yml deleted file mode 100644 index 5173a217..00000000 --- a/.github/workflows/run_scubagoggles.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Run ScubaGoggles -on: - workflow_call: - inputs: - os: - required: true - workflow_dispatch: - -jobs: - run-scubagoggles-windows: - if: ${{ inputs.os }} == "windows-latest" - runs-on: windows-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Setup dependencies - uses: ./.github/actions/setup-windows-dependencies - with: - operating-system: "windows" - opa-version: "0.60.0" - - - name: Execute ScubaGoggles and check for correct output - run: | - # Setup credentials for service account - Set-Content -Path credentials.json -Value $env:GWS_GITHUB_AUTOMATION_CREDS - pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" - - run-scubagoggles-macos: - if: ${{ inputs.os }} == "macos-latest" - runs-on: macos-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Setup dependencies - uses: ./.github/actions/setup-macos-dependencies - with: - operating-system: "macos" - opa-version: "0.60.0" - - - name: Execute ScubaGoggles and check for correct output - run: | - echo "in second step" - - # Give OPA executable execute permissions - chmod +x opa_darwin_amd64 - # Setup credentials for service account - echo $env:GWS_GITHUB_AUTOMATION_CREDS - echo $env:GWS_GITHUB_AUTOMATION_CREDS >> credentials.json - cat credentials.json - #pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 5a59af1a..45891c95 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -25,7 +25,7 @@ jobs: fail-fast: false matrix: os: [windows-latest, macos-latest] - python: [3.8, 3.12] + python-version: [3.12] runs-on: ${{ matrix.os }} steps: - name: Checkout Repository @@ -34,43 +34,27 @@ jobs: - name: Setup Python uses: ./.github/actions/setup-python with: - python-version: ${{ matrix.python }} + python-version: ${{ matrix.python-version }} cache-dependency-path: "requirements.txt" - - name: Setup Windows dependencies + - name: Run ScubaGoggles (Windows) if: ${{ matrix.os == 'windows-latest' }} - uses: ./.github/actions/setup-windows-dependencies + uses: ./.github/actions/setup-dependencies-windows with: operating-system: "windows" opa-version: "0.60.0" + credentials: $env:GWS_GITHUB_AUTOMATION_CREDS - - name: Setup macOS dependencies + - name: Run ScubaGoggles (macOS) if: ${{ matrix.os == 'macos-latest' }} - uses: ./.github/actions/setup-windows-dependencies + uses: ./.github/actions/setup-dependencies-macos with: operating-system: "macos" opa-version: "0.60.0" + credentials: $env:GWS_GITHUB_AUTOMATION_CREDS - name: Execute ScubaGoggles and check for correct output - if: ${{ matrix.os == 'windows-latest' }} - run: | - # Setup credentials for service account - Set-Content -Path credentials.json -Value $env:GWS_GITHUB_AUTOMATION_CREDS - pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" - - - name: Execute ScubaGoggles and check for correct output - if: ${{ matrix.os == 'macos-latest' }} - run: | - echo "in second step" - - # Give OPA executable execute permissions - chmod +x opa_darwin_amd64 - - # Setup credentials for service account - echo $env:GWS_GITHUB_AUTOMATION_CREDS - echo $env:GWS_GITHUB_AUTOMATION_CREDS >> credentials.json - cat credentials.json - #pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" + run: pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" #smoke-test-windows: # if: false From bc5cae6532a43852e66e2059b017c9c3b6d296b5 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 00:20:07 +0000 Subject: [PATCH 072/126] didnt add input in macos dependencies action --- .github/actions/setup-dependencies-macos/action.yml | 6 ++++-- .github/workflows/run_smoke_test.yml | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index 1f995089..a824835c 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -6,6 +6,8 @@ inputs: opa-version: required: true default: "0.60.0" + credentials: + required: true runs: using: "composite" @@ -38,6 +40,6 @@ runs: # Give OPA executable execute permissions chmod +x opa_darwin_amd64 # Setup credentials for service account - echo $env:GWS_GITHUB_AUTOMATION_CREDS - echo $env:GWS_GITHUB_AUTOMATION_CREDS >> credentials.json + echo ${{ inputs.credentials }} + echo ${{ inputs.credentials }} >> credentials.json cat credentials.json \ No newline at end of file diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 45891c95..2bb889d1 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -37,7 +37,7 @@ jobs: python-version: ${{ matrix.python-version }} cache-dependency-path: "requirements.txt" - - name: Run ScubaGoggles (Windows) + - name: Setup Dependencies (Windows) if: ${{ matrix.os == 'windows-latest' }} uses: ./.github/actions/setup-dependencies-windows with: @@ -45,7 +45,7 @@ jobs: opa-version: "0.60.0" credentials: $env:GWS_GITHUB_AUTOMATION_CREDS - - name: Run ScubaGoggles (macOS) + - name: Setup Dependencies (macOS) if: ${{ matrix.os == 'macos-latest' }} uses: ./.github/actions/setup-dependencies-macos with: From 0954b5c3f180fb779ebfb211d0241385489110a6 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 16:55:21 +0000 Subject: [PATCH 073/126] macos credentials.json update --- .github/actions/setup-dependencies-macos/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index a824835c..0612a6a8 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -40,6 +40,6 @@ runs: # Give OPA executable execute permissions chmod +x opa_darwin_amd64 # Setup credentials for service account - echo ${{ inputs.credentials }} - echo ${{ inputs.credentials }} >> credentials.json + echo "${{ inputs.credentials }}" + echo "${{ inputs.credentials }}" >> credentials.json cat credentials.json \ No newline at end of file From 9d3fad22df19c3695c387d68b364297eb9cf528a Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 16:57:35 +0000 Subject: [PATCH 074/126] macos credentials.json update --- .../setup-dependencies-macos/action.yml | 2 - .github/workflows/run_smoke_test.yml | 59 ------------------- 2 files changed, 61 deletions(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index 0612a6a8..8ad02a07 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -35,8 +35,6 @@ runs: - name: Setup credentials for service account shell: bash run: | - echo "in second step" - # Give OPA executable execute permissions chmod +x opa_darwin_amd64 # Setup credentials for service account diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 2bb889d1..2a2c4c20 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -55,62 +55,3 @@ jobs: - name: Execute ScubaGoggles and check for correct output run: pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" - - #smoke-test-windows: - # if: false - # name: Smoke Test for Windows - # runs-on: windows-latest - # steps: - # - name: Checkout Repository - # uses: actions/checkout@v4 -# - # - name: Setup Python - # uses: ./.github/actions/setup-python - # with: - # python-version: "3.12" - # cache-dependency-path: "requirements.txt" - # - # - name: Setup dependencies - # uses: ./.github/actions/setup-windows-dependencies - # with: - # operating-system: "windows" - # opa-version: "0.60.0" -# - # - name: Execute ScubaGoggles and check for correct output - # run: | - # # Setup credentials for service account - # Set-Content -Path credentials.json -Value $env:GWS_GITHUB_AUTOMATION_CREDS - # pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" - # - #smoke-test-macos: - # name: Smoke Test for MacOS - # runs-on: macos-latest - # #needs: smoke-test-windows - # steps: - # - name: Checkout Repository - # uses: actions/checkout@v4 -# - # - name: Setup Python - # uses: ./.github/actions/setup-python - # with: - # python-version: "3.12" - # cache-dependency-path: "requirements.txt" - # - # - name: Setup dependencies - # uses: ./.github/actions/setup-macos-dependencies - # with: - # operating-system: "macos" - # opa-version: "0.60.0" - # - # - name: Execute ScubaGoggles and check for correct output - # run: | - # echo "in second step" - # - # # Give OPA executable execute permissions - # chmod +x opa_darwin_amd64 -# - # # Setup credentials for service account - # echo $env:GWS_GITHUB_AUTOMATION_CREDS - # echo $env:GWS_GITHUB_AUTOMATION_CREDS >> credentials.json - # cat credentials.json - # #pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" From 7c6a58356de71b39b9f4391a237afb692250b3c7 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 17:25:31 +0000 Subject: [PATCH 075/126] macos credentials.json update --- .github/actions/setup-dependencies-macos/action.yml | 12 ++++++------ .../actions/setup-dependencies-windows/action.yml | 2 +- .github/workflows/run_smoke_test.yml | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index 8ad02a07..79d2a55d 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -30,14 +30,14 @@ runs: - name: Download OPA executable shell: bash - run: python download_opa.py -v ${{ inputs.opa-version }} -os ${{ inputs.operating-system }} + run: | + python download_opa.py -v ${{ inputs.opa-version }} -os ${{ inputs.operating-system }} + + # Give OPA executable execute permissions + chmod +x opa_darwin_amd64 - name: Setup credentials for service account shell: bash run: | - # Give OPA executable execute permissions - chmod +x opa_darwin_amd64 # Setup credentials for service account - echo "${{ inputs.credentials }}" - echo "${{ inputs.credentials }}" >> credentials.json - cat credentials.json \ No newline at end of file + echo ${{ inputs.credentials }} | base64 -d > credentials.json \ No newline at end of file diff --git a/.github/actions/setup-dependencies-windows/action.yml b/.github/actions/setup-dependencies-windows/action.yml index 42d2c2f1..0186bf8d 100644 --- a/.github/actions/setup-dependencies-windows/action.yml +++ b/.github/actions/setup-dependencies-windows/action.yml @@ -25,7 +25,7 @@ runs: python -m pip install . pip install -r requirements.txt pip install pytest - pip uninstall numpy + pip uninstall -y numpy pip install numpy==1.26.4 - name: Download OPA executable diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 2a2c4c20..cfe1bb4d 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -54,4 +54,5 @@ jobs: credentials: $env:GWS_GITHUB_AUTOMATION_CREDS - name: Execute ScubaGoggles and check for correct output - run: pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" + run: | + pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" From ee41ee09c81eef2c6d07ab46780cfd2114018431 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 17:37:08 +0000 Subject: [PATCH 076/126] macos credentials.json update --- .github/actions/setup-dependencies-macos/action.yml | 12 +++++++----- .github/workflows/run_smoke_test.yml | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index 79d2a55d..560ee3f9 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -12,6 +12,12 @@ inputs: runs: using: "composite" steps: + - name: Setup credentials for service account + shell: bash + run: | + # Setup credentials for service account + echo ${{ inputs.credentials }} | base64 -di > credentials.json + - name: Setup virtualenv shell: bash run: | @@ -36,8 +42,4 @@ runs: # Give OPA executable execute permissions chmod +x opa_darwin_amd64 - - name: Setup credentials for service account - shell: bash - run: | - # Setup credentials for service account - echo ${{ inputs.credentials }} | base64 -d > credentials.json \ No newline at end of file + \ No newline at end of file diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index cfe1bb4d..2706125f 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -55,4 +55,5 @@ jobs: - name: Execute ScubaGoggles and check for correct output run: | + echo "run scubagoggles" pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" From 1a70d8add217436bbe7d74766403f22d5663f048 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 17:47:51 +0000 Subject: [PATCH 077/126] macos credentials.json update --- .github/actions/setup-dependencies-macos/action.yml | 5 +++-- .github/workflows/run_smoke_test.yml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index 560ee3f9..74c7da2b 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -16,8 +16,9 @@ runs: shell: bash run: | # Setup credentials for service account - echo ${{ inputs.credentials }} | base64 -di > credentials.json - + touch credentials.json + echo ${{ inputs.credentials }} | base64 -d --ignore-garbage > credentials.json + - name: Setup virtualenv shell: bash run: | diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 2706125f..e550eca7 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -55,5 +55,5 @@ jobs: - name: Execute ScubaGoggles and check for correct output run: | - echo "run scubagoggles" + echo "run scubagoggles ttest" pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" From c69b3bc9eb4b6a9482ce9c60f7c00dfc64edac45 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 17:51:38 +0000 Subject: [PATCH 078/126] macos credentials.json update --- .../actions/setup-dependencies-macos/action.yml | 17 ++++++++++++----- .github/workflows/run_smoke_test.yml | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index 74c7da2b..c9a2a2e1 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -12,12 +12,19 @@ inputs: runs: using: "composite" steps: + #- name: Setup credentials for service account + # shell: bash + # run: | + # # Setup credentials for service account + # touch credentials.json + # echo ${{ inputs.credentials }} > credentials.json + # - name: Setup credentials for service account - shell: bash - run: | - # Setup credentials for service account - touch credentials.json - echo ${{ inputs.credentials }} | base64 -d --ignore-garbage > credentials.json + uses: jsdaniell/create-json@v1.2.3 + with: + name: "credentials.json" + json: ${{ inputs.credentials }} + dir: "./" - name: Setup virtualenv shell: bash diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index e550eca7..2706125f 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -55,5 +55,5 @@ jobs: - name: Execute ScubaGoggles and check for correct output run: | - echo "run scubagoggles ttest" + echo "run scubagoggles" pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" From 7dc0d4668a9a6b32a5f8dd5c06ae980dc70e7c6a Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 18:03:48 +0000 Subject: [PATCH 079/126] macos credentials.json update --- .github/actions/setup-dependencies-macos/action.yml | 12 ++++++------ .../actions/setup-dependencies-windows/action.yml | 6 +++--- .github/workflows/run_smoke_test.yml | 7 +++++++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index c9a2a2e1..4753a320 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -19,12 +19,12 @@ runs: # touch credentials.json # echo ${{ inputs.credentials }} > credentials.json # - - name: Setup credentials for service account - uses: jsdaniell/create-json@v1.2.3 - with: - name: "credentials.json" - json: ${{ inputs.credentials }} - dir: "./" + #- name: Setup credentials for service account + # uses: jsdaniell/create-json@v1.2.3 + # with: + # name: "credentials.json" + # json: ${{ inputs.credentials }} + # dir: "./" - name: Setup virtualenv shell: bash diff --git a/.github/actions/setup-dependencies-windows/action.yml b/.github/actions/setup-dependencies-windows/action.yml index 0186bf8d..ed1b473a 100644 --- a/.github/actions/setup-dependencies-windows/action.yml +++ b/.github/actions/setup-dependencies-windows/action.yml @@ -32,6 +32,6 @@ runs: shell: powershell run: python download_opa.py -v ${{ inputs.opa-version }} -os ${{ inputs.operating-system }} - - name: Setup credentials for service account - shell: powershell - run: Set-Content -Path credentials.json -Value ${{ inputs.credentials }} \ No newline at end of file + #- name: Setup credentials for service account + # shell: powershell + # run: Set-Content -Path credentials.json -Value ${{ inputs.credentials }} \ No newline at end of file diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 2706125f..043225ab 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -52,6 +52,13 @@ jobs: operating-system: "macos" opa-version: "0.60.0" credentials: $env:GWS_GITHUB_AUTOMATION_CREDS + + - name: Setup credentials for service account + uses: jsdaniell/create-json@v1.2.3 + with: + name: "credentials.json" + json: $env:GWS_GITHUB_AUTOMATION_CREDS + dir: "./" - name: Execute ScubaGoggles and check for correct output run: | From dc76de1c7afac78a0ddeec02de7b776127a07954 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 18:12:15 +0000 Subject: [PATCH 080/126] macos credentials.json update --- .github/workflows/run_smoke_test.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 043225ab..a2f83efa 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -11,9 +11,10 @@ on: push: paths: - ".github/workflows/run_smoke_test.yml" + - ".github/actions/setup-dependencies-windows/action.yml" + - ".github/actions/setup-dependencies-macos/action.yml" branches: - "main" - - "*smoke*" env: GWS_SUBJECT_EMAIL: ${{ secrets.GWS_SUBJECT_EMAIL }} @@ -58,9 +59,7 @@ jobs: with: name: "credentials.json" json: $env:GWS_GITHUB_AUTOMATION_CREDS - dir: "./" - name: Execute ScubaGoggles and check for correct output run: | - echo "run scubagoggles" pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" From 3b065c67c1796c349414d802711328f0031d12b2 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 18:23:09 +0000 Subject: [PATCH 081/126] macos credentials.json update --- .github/workflows/run_smoke_test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index a2f83efa..f6b6a5a4 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -62,4 +62,5 @@ jobs: - name: Execute ScubaGoggles and check for correct output run: | + echo "run scubagoggles" pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" From f7602780872786285e841fc946eddbc6455d67f5 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 18:24:07 +0000 Subject: [PATCH 082/126] macos credentials.json update --- .github/workflows/run_smoke_test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index f6b6a5a4..84bff0e7 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -11,8 +11,6 @@ on: push: paths: - ".github/workflows/run_smoke_test.yml" - - ".github/actions/setup-dependencies-windows/action.yml" - - ".github/actions/setup-dependencies-macos/action.yml" branches: - "main" From fd16c0b9443e5a9c98955e6455e598884b8ab797 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 18:28:58 +0000 Subject: [PATCH 083/126] macos credentials.json update --- .github/workflows/run_smoke_test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 84bff0e7..4c2ef453 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -11,8 +11,11 @@ on: push: paths: - ".github/workflows/run_smoke_test.yml" + - ".github/actions/setup-dependencies-windows/action.yml" + - ".github/actions/setup-dependencies-macos/action.yml" branches: - "main" + - "*smoke*" env: GWS_SUBJECT_EMAIL: ${{ secrets.GWS_SUBJECT_EMAIL }} From 5581955f92144b97a4effa490583c93de8d02a12 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 18:32:07 +0000 Subject: [PATCH 084/126] macos credentials.json update --- .github/workflows/run_smoke_test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 4c2ef453..bd1560ae 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -64,4 +64,5 @@ jobs: - name: Execute ScubaGoggles and check for correct output run: | echo "run scubagoggles" + ls pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" From 09c4be71d3ee8cd372a86420e19cb70682948ae1 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 18:55:29 +0000 Subject: [PATCH 085/126] macos credentials.json update --- .github/actions/setup-dependencies-macos/action.yml | 11 +++++------ .github/actions/setup-dependencies-windows/action.yml | 6 +++--- .github/workflows/run_smoke_test.yml | 6 ------ 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index 4753a320..794f5871 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -19,12 +19,11 @@ runs: # touch credentials.json # echo ${{ inputs.credentials }} > credentials.json # - #- name: Setup credentials for service account - # uses: jsdaniell/create-json@v1.2.3 - # with: - # name: "credentials.json" - # json: ${{ inputs.credentials }} - # dir: "./" + - name: Setup credentials for service account + uses: jsdaniell/create-json@v1.2.3 + with: + name: "credentials.json" + json: ${{ inputs.credentials }} - name: Setup virtualenv shell: bash diff --git a/.github/actions/setup-dependencies-windows/action.yml b/.github/actions/setup-dependencies-windows/action.yml index ed1b473a..0186bf8d 100644 --- a/.github/actions/setup-dependencies-windows/action.yml +++ b/.github/actions/setup-dependencies-windows/action.yml @@ -32,6 +32,6 @@ runs: shell: powershell run: python download_opa.py -v ${{ inputs.opa-version }} -os ${{ inputs.operating-system }} - #- name: Setup credentials for service account - # shell: powershell - # run: Set-Content -Path credentials.json -Value ${{ inputs.credentials }} \ No newline at end of file + - name: Setup credentials for service account + shell: powershell + run: Set-Content -Path credentials.json -Value ${{ inputs.credentials }} \ No newline at end of file diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index bd1560ae..9156f1e5 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -54,12 +54,6 @@ jobs: operating-system: "macos" opa-version: "0.60.0" credentials: $env:GWS_GITHUB_AUTOMATION_CREDS - - - name: Setup credentials for service account - uses: jsdaniell/create-json@v1.2.3 - with: - name: "credentials.json" - json: $env:GWS_GITHUB_AUTOMATION_CREDS - name: Execute ScubaGoggles and check for correct output run: | From fe4e3e1971cd5d592462ca75ab4db44e4caec790 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 19:05:27 +0000 Subject: [PATCH 086/126] try different approach for creating credentials.json --- .../actions/setup-dependencies-macos/action.yml | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index 794f5871..7aeb443f 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -12,18 +12,12 @@ inputs: runs: using: "composite" steps: - #- name: Setup credentials for service account - # shell: bash - # run: | - # # Setup credentials for service account - # touch credentials.json - # echo ${{ inputs.credentials }} > credentials.json - # - name: Setup credentials for service account - uses: jsdaniell/create-json@v1.2.3 - with: - name: "credentials.json" - json: ${{ inputs.credentials }} + shell: bash + run: | + apt install jq + echo ${{ inputs.credentials }} | jq '.' > credentials.json + ls -la - name: Setup virtualenv shell: bash From c207982ba4926815cc8322a10d03923c2f0cbd61 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 19:07:15 +0000 Subject: [PATCH 087/126] try different approach for creating credentials.json --- .github/actions/setup-dependencies-macos/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index 7aeb443f..97818de5 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -15,7 +15,7 @@ runs: - name: Setup credentials for service account shell: bash run: | - apt install jq + sudo apt-get install jq echo ${{ inputs.credentials }} | jq '.' > credentials.json ls -la From ec14d8bdbd5335ced98eee1625d7d56c397c50c8 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 19:11:38 +0000 Subject: [PATCH 088/126] try different approach for creating credentials.json --- .github/actions/setup-dependencies-macos/action.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index 97818de5..93e683f8 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -12,10 +12,12 @@ inputs: runs: using: "composite" steps: + - name: "Setup jq" + uses: dcarbone/install-jq-action@v2 + - name: Setup credentials for service account shell: bash run: | - sudo apt-get install jq echo ${{ inputs.credentials }} | jq '.' > credentials.json ls -la From 8217553e9e25e4982fbac67d7c84d53058c202ee Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 19:13:46 +0000 Subject: [PATCH 089/126] try different approach for creating credentials.json --- .github/actions/setup-dependencies-macos/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index 93e683f8..89680361 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -14,11 +14,11 @@ runs: steps: - name: "Setup jq" uses: dcarbone/install-jq-action@v2 - + - name: Setup credentials for service account shell: bash run: | - echo ${{ inputs.credentials }} | jq '.' > credentials.json + echo "${{ inputs.credentials }}" | jq '.' > credentials.json ls -la - name: Setup virtualenv From 2a86e9c5c35bb90fa3bb496f8165dc2a943c924a Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 19:58:20 +0000 Subject: [PATCH 090/126] try different approach for creating credentials.json --- .github/actions/setup-dependencies-macos/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index 89680361..08d2a629 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -18,7 +18,7 @@ runs: - name: Setup credentials for service account shell: bash run: | - echo "${{ inputs.credentials }}" | jq '.' > credentials.json + echo "${{ inputs.credentials }}" > credentials.json ls -la - name: Setup virtualenv From 478842a30fee3e0fe836d9861e4f1209dc866e88 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 20:00:46 +0000 Subject: [PATCH 091/126] try different approach for creating credentials.json --- .github/actions/setup-dependencies-macos/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index 08d2a629..c0ae10a1 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -18,7 +18,7 @@ runs: - name: Setup credentials for service account shell: bash run: | - echo "${{ inputs.credentials }}" > credentials.json + echo ${{ inputs.credentials }} > credentials.json ls -la - name: Setup virtualenv From e9aaa09c491241562bed6d35a029613ed08db836 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 20:08:07 +0000 Subject: [PATCH 092/126] try different approach for creating credentials.json --- .github/actions/setup-dependencies-macos/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index c0ae10a1..018669de 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -18,7 +18,7 @@ runs: - name: Setup credentials for service account shell: bash run: | - echo ${{ inputs.credentials }} > credentials.json + echo ${{ inputs.credentials }} >> credentials.json ls -la - name: Setup virtualenv From 24189169db7c2a829dd024d002e8da842d037baf Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 20:21:19 +0000 Subject: [PATCH 093/126] try different approach for creating credentials.json --- .../actions/setup-dependencies-macos/action.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index 018669de..49082ae5 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -12,14 +12,17 @@ inputs: runs: using: "composite" steps: - - name: "Setup jq" - uses: dcarbone/install-jq-action@v2 - - name: Setup credentials for service account - shell: bash - run: | - echo ${{ inputs.credentials }} >> credentials.json - ls -la + uses: jsdaniell/create-json@v1.2.3 + with: + name: "credentials.json" + json: ${{ inputs.credentials }} + + #- name: Setup credentials for service account + # shell: bash + # run: | + # echo ${{ inputs.credentials }} >> credentials.json + # ls -la - name: Setup virtualenv shell: bash From 57a2fb6da2184fe4fc8530e2653168e52a6b1766 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 20:23:21 +0000 Subject: [PATCH 094/126] try different approach for creating credentials.json --- .github/actions/setup-dependencies-macos/action.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index 49082ae5..3b3d5a3b 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -13,10 +13,18 @@ runs: using: "composite" steps: - name: Setup credentials for service account + id: create-json uses: jsdaniell/create-json@v1.2.3 with: name: "credentials.json" json: ${{ inputs.credentials }} + + - name: Setup credentials for service account + id: create-json-1 + uses: jsdaniell/create-json@v1.2.3 + with: + name: "credentials-1.json" + json: "${{ inputs.credentials }}" #- name: Setup credentials for service account # shell: bash From 7c4fe2e0010097030c6975f6069e412115cb08e5 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 20:24:38 +0000 Subject: [PATCH 095/126] try different approach for creating credentials.json --- .github/actions/setup-dependencies-macos/action.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index 3b3d5a3b..ccfb419f 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -26,11 +26,10 @@ runs: name: "credentials-1.json" json: "${{ inputs.credentials }}" - #- name: Setup credentials for service account - # shell: bash - # run: | - # echo ${{ inputs.credentials }} >> credentials.json - # ls -la + - name: Setup credentials for service account + shell: bash + run: | + ls -la - name: Setup virtualenv shell: bash From 5ff1c85de7122a85834ab6d7e6de0d45a9148b79 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 20:29:16 +0000 Subject: [PATCH 096/126] try different approach for creating credentials.json --- .github/actions/setup-dependencies-macos/action.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index ccfb419f..5ad9d89a 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -18,17 +18,11 @@ runs: with: name: "credentials.json" json: ${{ inputs.credentials }} - - - name: Setup credentials for service account - id: create-json-1 - uses: jsdaniell/create-json@v1.2.3 - with: - name: "credentials-1.json" - json: "${{ inputs.credentials }}" - name: Setup credentials for service account shell: bash run: | + cat credentials.json ls -la - name: Setup virtualenv From 269b900409216c99b71f36727cf7398d3993590e Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 20:38:20 +0000 Subject: [PATCH 097/126] switching to environment secrets.. issue is with repo secrets --- .github/workflows/run_smoke_test.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 9156f1e5..44aa77eb 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -17,9 +17,9 @@ on: - "main" - "*smoke*" -env: - GWS_SUBJECT_EMAIL: ${{ secrets.GWS_SUBJECT_EMAIL }} - GWS_GITHUB_AUTOMATION_CREDS: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }} +#env: +# GWS_SUBJECT_EMAIL: ${{ secrets.GWS_SUBJECT_EMAIL }} +# GWS_GITHUB_AUTOMATION_CREDS: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }} jobs: smoke-test: @@ -29,6 +29,7 @@ jobs: os: [windows-latest, macos-latest] python-version: [3.12] runs-on: ${{ matrix.os }} + environment: Development steps: - name: Checkout Repository uses: actions/checkout@v4 @@ -45,7 +46,7 @@ jobs: with: operating-system: "windows" opa-version: "0.60.0" - credentials: $env:GWS_GITHUB_AUTOMATION_CREDS + credentials: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }} - name: Setup Dependencies (macOS) if: ${{ matrix.os == 'macos-latest' }} @@ -53,10 +54,10 @@ jobs: with: operating-system: "macos" opa-version: "0.60.0" - credentials: $env:GWS_GITHUB_AUTOMATION_CREDS + credentials: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }} - name: Execute ScubaGoggles and check for correct output run: | echo "run scubagoggles" ls - pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="$env:GWS_SUBJECT_EMAIL" + pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" From 38f850104fef9229ba6ef49b024289ba8357ef9b Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 20:39:50 +0000 Subject: [PATCH 098/126] switching to environment secrets.. issue is with repo secrets --- .github/actions/setup-dependencies-macos/action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index 5ad9d89a..03e47773 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -22,7 +22,6 @@ runs: - name: Setup credentials for service account shell: bash run: | - cat credentials.json ls -la - name: Setup virtualenv From d818d704dfb31bbae92c593a4a8cad63b66b35dd Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 20:44:37 +0000 Subject: [PATCH 099/126] switching to environment secrets.. issue is with repo secrets --- .../setup-dependencies-macos/action.yml | 22 +++++++++---------- .../setup-dependencies-windows/action.yml | 6 ++--- .github/workflows/run_smoke_test.yml | 9 ++++++-- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index 03e47773..fda0ee83 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -12,17 +12,17 @@ inputs: runs: using: "composite" steps: - - name: Setup credentials for service account - id: create-json - uses: jsdaniell/create-json@v1.2.3 - with: - name: "credentials.json" - json: ${{ inputs.credentials }} - - - name: Setup credentials for service account - shell: bash - run: | - ls -la + #- name: Setup credentials for service account + # id: create-json + # uses: jsdaniell/create-json@v1.2.3 + # with: + # name: "credentials.json" + # json: ${{ inputs.credentials }} +# + #- name: Setup credentials for service account + # shell: bash + # run: | + # ls -la - name: Setup virtualenv shell: bash diff --git a/.github/actions/setup-dependencies-windows/action.yml b/.github/actions/setup-dependencies-windows/action.yml index 0186bf8d..ed1b473a 100644 --- a/.github/actions/setup-dependencies-windows/action.yml +++ b/.github/actions/setup-dependencies-windows/action.yml @@ -32,6 +32,6 @@ runs: shell: powershell run: python download_opa.py -v ${{ inputs.opa-version }} -os ${{ inputs.operating-system }} - - name: Setup credentials for service account - shell: powershell - run: Set-Content -Path credentials.json -Value ${{ inputs.credentials }} \ No newline at end of file + #- name: Setup credentials for service account + # shell: powershell + # run: Set-Content -Path credentials.json -Value ${{ inputs.credentials }} \ No newline at end of file diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 44aa77eb..a5835cb5 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -55,9 +55,14 @@ jobs: operating-system: "macos" opa-version: "0.60.0" credentials: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }} + + - name: Setup credentials for service account + id: create-json + uses: jsdaniell/create-json@v1.2.3 + with: + name: "credentials.json" + json: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }} - name: Execute ScubaGoggles and check for correct output run: | - echo "run scubagoggles" - ls pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" From 4f8c951026d3b7a4bad32fb27eb6bbebd407755e Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Wed, 31 Jul 2024 21:46:24 +0000 Subject: [PATCH 100/126] cleanup workflows/actions; add check for valid json; add types --- .../setup-dependencies-macos/action.yml | 14 -------- .../setup-dependencies-windows/action.yml | 8 +---- .github/workflows/run_smoke_test.yml | 9 +---- Testing/Functional/SmokeTests/smoke_test.py | 34 +++++-------------- .../Functional/SmokeTests/smoke_test_utils.py | 19 +++++++---- 5 files changed, 22 insertions(+), 62 deletions(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index fda0ee83..accf2871 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -6,24 +6,10 @@ inputs: opa-version: required: true default: "0.60.0" - credentials: - required: true runs: using: "composite" steps: - #- name: Setup credentials for service account - # id: create-json - # uses: jsdaniell/create-json@v1.2.3 - # with: - # name: "credentials.json" - # json: ${{ inputs.credentials }} -# - #- name: Setup credentials for service account - # shell: bash - # run: | - # ls -la - - name: Setup virtualenv shell: bash run: | diff --git a/.github/actions/setup-dependencies-windows/action.yml b/.github/actions/setup-dependencies-windows/action.yml index ed1b473a..5f0e9770 100644 --- a/.github/actions/setup-dependencies-windows/action.yml +++ b/.github/actions/setup-dependencies-windows/action.yml @@ -6,8 +6,6 @@ inputs: opa-version: required: true default: "0.60.0" - credentials: - required: true runs: using: "composite" @@ -30,8 +28,4 @@ runs: - name: Download OPA executable shell: powershell - run: python download_opa.py -v ${{ inputs.opa-version }} -os ${{ inputs.operating-system }} - - #- name: Setup credentials for service account - # shell: powershell - # run: Set-Content -Path credentials.json -Value ${{ inputs.credentials }} \ No newline at end of file + run: python download_opa.py -v ${{ inputs.opa-version }} -os ${{ inputs.operating-system }} \ No newline at end of file diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index a5835cb5..217ffb8e 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -17,10 +17,6 @@ on: - "main" - "*smoke*" -#env: -# GWS_SUBJECT_EMAIL: ${{ secrets.GWS_SUBJECT_EMAIL }} -# GWS_GITHUB_AUTOMATION_CREDS: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }} - jobs: smoke-test: strategy: @@ -46,7 +42,6 @@ jobs: with: operating-system: "windows" opa-version: "0.60.0" - credentials: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }} - name: Setup Dependencies (macOS) if: ${{ matrix.os == 'macos-latest' }} @@ -54,7 +49,6 @@ jobs: with: operating-system: "macos" opa-version: "0.60.0" - credentials: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }} - name: Setup credentials for service account id: create-json @@ -64,5 +58,4 @@ jobs: json: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }} - name: Execute ScubaGoggles and check for correct output - run: | - pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" + run: pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index d117e110..9b3432ae 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -10,37 +10,19 @@ from smoke_test_utils import verify_all_outputs_exist, verify_output_type class SmokeTest: - def test_venv_creation(self): + def test_scubagoggles_output(self, subjectemail): try: - result = subprocess.run(["ls", ".venv"], shell=True, capture_output=True, text=True, check=True) - if "Scripts" in result.stdout: - assert True - except subprocess.CalledProcessError as e: - pytest.fail(f"An error occurred, {e}") - - def test_scubagoggles(self, subjectemail): - try: - command = f"scubagoggles gws --subjectemail {subjectemail} --quiet" + command: str = f"scubagoggles gws --subjectemail {subjectemail} --quiet" subprocess.run(command, shell=True) - prefix = "GWSBaselineConformance" - directories = [d for d in os.listdir() if os.path.isdir(d) and d.startswith(prefix)] + prefix: str = "GWSBaselineConformance" + directories: list[str] = [d for d in os.listdir() if os.path.isdir(d) and d.startswith(prefix)] directories.sort(key=lambda d: os.path.getctime(d), reverse=True) - cwd = os.getcwd() - output_path = os.path.join(cwd, directories[0]) - contents = verify_output_type(output_path, []) + # Access the latest output directory at the 0th index after sorting + cwd: str = os.getcwd() + output_path: str = os.path.join(cwd, directories[0]) + contents: list[str] = verify_output_type(output_path, []) verify_all_outputs_exist(contents) except (OSError, ValueError, Exception) as e: pytest.fail(f"An error occurred, {e}") - -#def create_venv(env): -# result = subprocess.run(["python", "-m", "venv", env]) -# if result.returncode == 0: -# raise RuntimeError(f"Failed to create virtual environment, {result.stderr}") -# -#def activate_venv(env): -# command = f"{env}\\Scripts\\activate" -# result = subprocess.run(command) -# if result.returncode == 0: -# raise RuntimeError(f"Failed to activate virtual environment, {result.stderr}") diff --git a/Testing/Functional/SmokeTests/smoke_test_utils.py b/Testing/Functional/SmokeTests/smoke_test_utils.py index de30c8b2..836e9e8b 100644 --- a/Testing/Functional/SmokeTests/smoke_test_utils.py +++ b/Testing/Functional/SmokeTests/smoke_test_utils.py @@ -1,5 +1,6 @@ import pytest import os +import json required_contents = [ "BaselineReports.html", @@ -21,25 +22,29 @@ "triangle-exclamation-solid.svg" ] -def verify_output_type(output_path, contents): - entries = os.listdir(output_path) - +def verify_output_type(output_path: str, contents: list[str]) -> list[str]: + entries: list[str] = os.listdir(output_path) for entry in entries: contents.append(entry) - # Check if entry is a valid directory or file - child_path = os.path.join(output_path, entry) + child_path: str = os.path.join(output_path, entry) if os.path.isdir(child_path): assert True verify_output_type(child_path, contents) elif os.path.isfile(child_path): + # Check for valid json + if child_path.endswith(".json"): + try: + with open(child_path) as jsonfile: + json.load(jsonfile) + except ValueError as e: + pytest.fail(f"Invalid json, ${e}") assert True else: raise OSError(f"Entry is not a directory or file (symlink, etc.)") - return contents -def verify_all_outputs_exist(contents): +def verify_all_outputs_exist(contents: list[str]): for required_content in required_contents: if required_content in contents: assert True From 509d3081d9f2a39e2ff326e09bf78a7be9972a0d Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Thu, 1 Aug 2024 01:16:22 +0000 Subject: [PATCH 101/126] added test_scubagoggles_report pytest with selenium; testing BaselineReports.html successfully so far --- .../setup-dependencies-macos/action.yml | 1 + .../setup-dependencies-windows/action.yml | 1 + .github/workflows/run_smoke_test.yml | 2 +- Testing/Functional/SmokeTests/smoke_test.py | 72 ++++++++++++++++--- .../Functional/SmokeTests/smoke_test_utils.py | 43 ++++++----- Testing/Functional/conftest.py | 14 +++- 6 files changed, 103 insertions(+), 30 deletions(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index accf2871..fad75cd3 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -23,6 +23,7 @@ runs: python -m pip install . pip install -r requirements.txt pip install pytest + pip install selenium pip uninstall -y numpy pip install numpy==1.26.4 diff --git a/.github/actions/setup-dependencies-windows/action.yml b/.github/actions/setup-dependencies-windows/action.yml index 5f0e9770..8da70fd2 100644 --- a/.github/actions/setup-dependencies-windows/action.yml +++ b/.github/actions/setup-dependencies-windows/action.yml @@ -23,6 +23,7 @@ runs: python -m pip install . pip install -r requirements.txt pip install pytest + pip install selenium pip uninstall -y numpy pip install numpy==1.26.4 diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 217ffb8e..bf3577b1 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -58,4 +58,4 @@ jobs: json: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }} - name: Execute ScubaGoggles and check for correct output - run: pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" + run: pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" --domain="${{ secrets.GWS_DOMAIN }}" diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index 9b3432ae..20b930fe 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -6,8 +6,10 @@ import pytest import subprocess import os - -from smoke_test_utils import verify_all_outputs_exist, verify_output_type +from selenium.webdriver.common.by import By +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support import expected_conditions +from smoke_test_utils import get_output_path, verify_all_outputs_exist, verify_output_type class SmokeTest: def test_scubagoggles_output(self, subjectemail): @@ -15,14 +17,66 @@ def test_scubagoggles_output(self, subjectemail): command: str = f"scubagoggles gws --subjectemail {subjectemail} --quiet" subprocess.run(command, shell=True) - prefix: str = "GWSBaselineConformance" - directories: list[str] = [d for d in os.listdir() if os.path.isdir(d) and d.startswith(prefix)] - directories.sort(key=lambda d: os.path.getctime(d), reverse=True) - - # Access the latest output directory at the 0th index after sorting - cwd: str = os.getcwd() - output_path: str = os.path.join(cwd, directories[0]) + output_path: str = get_output_path() contents: list[str] = verify_output_type(output_path, []) verify_all_outputs_exist(contents) except (OSError, ValueError, Exception) as e: pytest.fail(f"An error occurred, {e}") + + def test_scubagoggles_report(self, browser, domain): + try: + output_path: str = get_output_path() + browser.get(os.path.join(output_path, "BaselineReports.html")) + + h1 = browser.find_element(By.TAG_NAME, "h1").text + assert h1 == "SCuBA GWS Security Baseline Conformance Reports" + + # verify domain is present in agency table + agency_table = browser.find_element(By.TAG_NAME, "table") + tbody = agency_table.find_element(By.TAG_NAME, "tbody") + rows = tbody.find_elements(By.TAG_NAME, "tr") + assert len(rows) == 2 + assert rows[1].find_elements(By.TAG_NAME, "td")[0].text == domain + + baseline_names = [ + "Google Calendar", + "Google Chat", + "Google Classroom", + "Common Controls", + "Google Drive and Docs", + "Gmail", + "Groups for Business", + "Google Meet", + "Rules", + "Google Sites" + ] + + for i in range(10): + reports_table = browser.find_elements(By.TAG_NAME, "table")[1] + tbody = reports_table.find_element(By.TAG_NAME, "tbody") + rows = tbody.find_elements(By.TAG_NAME, "tr") + td = rows[i].find_elements(By.TAG_NAME, "td")[0] + assert td.text in baseline_names + + individual_report_anchor = td.find_element(By.TAG_NAME, "a") + href = individual_report_anchor.get_attribute("href") + individual_report_anchor.get_attribute("href").click() + current_url = browser.current_url + assert href == current_url + + browser.back() + WebDriverWait(browser, 10).until( + expected_conditions.presence_of_element_located( + (By.TAG_NAME, "body") + ) + ) + + # Navigation to detailed reports + + # Check links work + + # Verify tables are populated + + + except Exception as e: + pytest.fail(f"An error occurred, {e}") \ No newline at end of file diff --git a/Testing/Functional/SmokeTests/smoke_test_utils.py b/Testing/Functional/SmokeTests/smoke_test_utils.py index 836e9e8b..e8cd70ce 100644 --- a/Testing/Functional/SmokeTests/smoke_test_utils.py +++ b/Testing/Functional/SmokeTests/smoke_test_utils.py @@ -2,25 +2,10 @@ import os import json -required_contents = [ - "BaselineReports.html", - "IndividualReports", - "ScubaResults.json", - "TestResults.json", - "images", - "CalendarReport.html", - "ChatReport.html", - "ClassroomReport.html", - "CommoncontrolsReport.html", - "DriveReport.html", - "GmailReport.html", - "GroupsReport.html", - "MeetReport.html", - "RulesReport.html", - "SitesReport.html", - "cisa_logo.png", - "triangle-exclamation-solid.svg" -] +def get_output_path() -> str: + directories: list[str] = [d for d in os.listdir() if os.path.isdir(d) and d.startswith("GWSBaselineConformance")] + directories.sort(key=lambda d: os.path.getctime(d), reverse=True) + return os.path.join(os.getcwd(), directories[0]) def verify_output_type(output_path: str, contents: list[str]) -> list[str]: entries: list[str] = os.listdir(output_path) @@ -44,6 +29,26 @@ def verify_output_type(output_path: str, contents: list[str]) -> list[str]: raise OSError(f"Entry is not a directory or file (symlink, etc.)") return contents +required_contents = [ + "BaselineReports.html", + "IndividualReports", + "ScubaResults.json", + "TestResults.json", + "images", + "CalendarReport.html", + "ChatReport.html", + "ClassroomReport.html", + "CommoncontrolsReport.html", + "DriveReport.html", + "GmailReport.html", + "GroupsReport.html", + "MeetReport.html", + "RulesReport.html", + "SitesReport.html", + "cisa_logo.png", + "triangle-exclamation-solid.svg" +] + def verify_all_outputs_exist(contents: list[str]): for required_content in required_contents: if required_content in contents: diff --git a/Testing/Functional/conftest.py b/Testing/Functional/conftest.py index 01326934..8cfef98f 100644 --- a/Testing/Functional/conftest.py +++ b/Testing/Functional/conftest.py @@ -1,8 +1,20 @@ import pytest +from selenium import webdriver def pytest_addoption(parser): parser.addoption("--subjectemail", action="store") + parser.addoption("--domain", action="store") @pytest.fixture def subjectemail(pytestconfig): - return pytestconfig.getoption("subjectemail") \ No newline at end of file + return pytestconfig.getoption("subjectemail") + +@pytest.fixture +def domain(pytestconfig): + return pytestconfig.getoption("domain") + +@pytest.fixture +def browser(): + driver = webdriver.Chrome() + yield driver + driver.quit() \ No newline at end of file From 22b94b6ecc416f77fb76c1fd61794bd8fddf142d Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Thu, 1 Aug 2024 01:24:20 +0000 Subject: [PATCH 102/126] added test_scubagoggles_report pytest with selenium; testing BaselineReports.html successfully so far --- Testing/Functional/SmokeTests/smoke_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index 20b930fe..ce9ac200 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -60,7 +60,7 @@ def test_scubagoggles_report(self, browser, domain): individual_report_anchor = td.find_element(By.TAG_NAME, "a") href = individual_report_anchor.get_attribute("href") - individual_report_anchor.get_attribute("href").click() + individual_report_anchor.click() current_url = browser.current_url assert href == current_url From e1830356aaa9cc7e44e0523e787980b22bc69d83 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Thu, 1 Aug 2024 01:26:32 +0000 Subject: [PATCH 103/126] added test_scubagoggles_report pytest with selenium; testing BaselineReports.html successfully so far --- .github/workflows/run_smoke_test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index bf3577b1..2c0a2da2 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -58,4 +58,5 @@ jobs: json: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }} - name: Execute ScubaGoggles and check for correct output - run: pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" --domain="${{ secrets.GWS_DOMAIN }}" + run: | + pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" --domain="${{ secrets.GWS_DOMAIN }}" From fecba85f24b6d508764e15b25214e626707bd585 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Thu, 1 Aug 2024 01:38:45 +0000 Subject: [PATCH 104/126] added test_scubagoggles_report pytest with selenium; testing BaselineReports.html successfully so far --- .github/workflows/run_smoke_test.yml | 3 +-- Testing/Functional/conftest.py | 8 +++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 2c0a2da2..bf3577b1 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -58,5 +58,4 @@ jobs: json: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }} - name: Execute ScubaGoggles and check for correct output - run: | - pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" --domain="${{ secrets.GWS_DOMAIN }}" + run: pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" --domain="${{ secrets.GWS_DOMAIN }}" diff --git a/Testing/Functional/conftest.py b/Testing/Functional/conftest.py index 8cfef98f..bb0ae9c5 100644 --- a/Testing/Functional/conftest.py +++ b/Testing/Functional/conftest.py @@ -1,5 +1,11 @@ import pytest from selenium import webdriver +from selenium.webdriver.chrome.options import Options + +chrome_options = Options() +chrome_options.add_argument("--headless") +chrome_options.add_argument("--no-sandbox") +chrome_options.add_argument("--disable-dev-shm-usage") def pytest_addoption(parser): parser.addoption("--subjectemail", action="store") @@ -15,6 +21,6 @@ def domain(pytestconfig): @pytest.fixture def browser(): - driver = webdriver.Chrome() + driver = webdriver.Chrome(options=chrome_options) yield driver driver.quit() \ No newline at end of file From 86fae506751faf671ae7dd72f30ae7a18be79d81 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Thu, 1 Aug 2024 03:29:48 +0000 Subject: [PATCH 105/126] added test_scubagoggles_report pytest with selenium; testing BaselineReports.html successfully so far --- .github/workflows/run_smoke_test.yml | 3 ++- Testing/Functional/SmokeTests/smoke_test.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index bf3577b1..2c0a2da2 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -58,4 +58,5 @@ jobs: json: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }} - name: Execute ScubaGoggles and check for correct output - run: pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" --domain="${{ secrets.GWS_DOMAIN }}" + run: | + pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" --domain="${{ secrets.GWS_DOMAIN }}" diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index ce9ac200..566ee9c4 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -26,7 +26,7 @@ def test_scubagoggles_output(self, subjectemail): def test_scubagoggles_report(self, browser, domain): try: output_path: str = get_output_path() - browser.get(os.path.join(output_path, "BaselineReports.html")) + browser.get("file://" + os.path.join(output_path, "BaselineReports.html")) h1 = browser.find_element(By.TAG_NAME, "h1").text assert h1 == "SCuBA GWS Security Baseline Conformance Reports" From d755517054f9d2146f13b1b6976e957e40f48f72 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Thu, 1 Aug 2024 04:01:53 +0000 Subject: [PATCH 106/126] best practice improvements for how file protocol is handled before invoking selenium; adding caching for both windows/macos deps --- .github/actions/setup-dependencies-macos/action.yml | 7 +++++++ .github/actions/setup-dependencies-windows/action.yml | 7 +++++++ .github/workflows/run_smoke_test.yml | 3 +-- Testing/Functional/SmokeTests/smoke_test.py | 10 ++++++++-- Testing/Functional/SmokeTests/smoke_test_utils.py | 5 +++++ 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index fad75cd3..5bc5004d 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -10,6 +10,13 @@ inputs: runs: using: "composite" steps: + - name: Cache packages + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip=${{ hashFiles("**/requirements.txt") }} + restore-keys: ${{ runner.os }}-pip- + - name: Setup virtualenv shell: bash run: | diff --git a/.github/actions/setup-dependencies-windows/action.yml b/.github/actions/setup-dependencies-windows/action.yml index 8da70fd2..e3793462 100644 --- a/.github/actions/setup-dependencies-windows/action.yml +++ b/.github/actions/setup-dependencies-windows/action.yml @@ -10,6 +10,13 @@ inputs: runs: using: "composite" steps: + - name: Cache packages + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip=${{ hashFiles("**/requirements.txt") }} + restore-keys: ${{ runner.os }}-pip- + - name: Setup virtualenv shell: powershell run: | diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 2c0a2da2..bf3577b1 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -58,5 +58,4 @@ jobs: json: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }} - name: Execute ScubaGoggles and check for correct output - run: | - pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" --domain="${{ secrets.GWS_DOMAIN }}" + run: pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" --domain="${{ secrets.GWS_DOMAIN }}" diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index 566ee9c4..e971c1b9 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -9,7 +9,12 @@ from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions -from smoke_test_utils import get_output_path, verify_all_outputs_exist, verify_output_type +from smoke_test_utils import ( + get_output_path, + prepend_file_protocol, + verify_all_outputs_exist, + verify_output_type, +) class SmokeTest: def test_scubagoggles_output(self, subjectemail): @@ -26,7 +31,8 @@ def test_scubagoggles_output(self, subjectemail): def test_scubagoggles_report(self, browser, domain): try: output_path: str = get_output_path() - browser.get("file://" + os.path.join(output_path, "BaselineReports.html")) + report_path: str = prepend_file_protocol(os.path.join(output_path, "BaselineReports.html")) + browser.get(report_path) h1 = browser.find_element(By.TAG_NAME, "h1").text assert h1 == "SCuBA GWS Security Baseline Conformance Reports" diff --git a/Testing/Functional/SmokeTests/smoke_test_utils.py b/Testing/Functional/SmokeTests/smoke_test_utils.py index e8cd70ce..6f900f5b 100644 --- a/Testing/Functional/SmokeTests/smoke_test_utils.py +++ b/Testing/Functional/SmokeTests/smoke_test_utils.py @@ -7,6 +7,11 @@ def get_output_path() -> str: directories.sort(key=lambda d: os.path.getctime(d), reverse=True) return os.path.join(os.getcwd(), directories[0]) +def prepend_file_protocol(path: str) -> str: + if not path.startsWith("file://"): + path = "file://" + path + return path + def verify_output_type(output_path: str, contents: list[str]) -> list[str]: entries: list[str] = os.listdir(output_path) for entry in entries: From 66637e0be3c281f6c0d625a403aa638a3ac53036 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Thu, 1 Aug 2024 04:06:40 +0000 Subject: [PATCH 107/126] best practice improvements for how file protocol is handled before invoking selenium; adding caching for both windows/macos deps --- .../setup-dependencies-macos/action.yml | 7 ------- .../setup-dependencies-windows/action.yml | 7 ------- .github/actions/setup-python/action.yml | 18 ------------------ .github/workflows/run_smoke_test.yml | 5 +++-- 4 files changed, 3 insertions(+), 34 deletions(-) delete mode 100644 .github/actions/setup-python/action.yml diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index 5bc5004d..fad75cd3 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -10,13 +10,6 @@ inputs: runs: using: "composite" steps: - - name: Cache packages - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip=${{ hashFiles("**/requirements.txt") }} - restore-keys: ${{ runner.os }}-pip- - - name: Setup virtualenv shell: bash run: | diff --git a/.github/actions/setup-dependencies-windows/action.yml b/.github/actions/setup-dependencies-windows/action.yml index e3793462..8da70fd2 100644 --- a/.github/actions/setup-dependencies-windows/action.yml +++ b/.github/actions/setup-dependencies-windows/action.yml @@ -10,13 +10,6 @@ inputs: runs: using: "composite" steps: - - name: Cache packages - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip=${{ hashFiles("**/requirements.txt") }} - restore-keys: ${{ runner.os }}-pip- - - name: Setup virtualenv shell: powershell run: | diff --git a/.github/actions/setup-python/action.yml b/.github/actions/setup-python/action.yml deleted file mode 100644 index 587d4596..00000000 --- a/.github/actions/setup-python/action.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Setup Python -inputs: - python-version: - required: true - default: "3.12" - cache-dependency-path: - required: true - default: "requirements.txt" - -runs: - using: "composite" - steps: - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: ${{ inputs.python-version }} - cache: "pip" - cache-dependency-path: ${{ inputs.cache-dependency-path }} diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index bf3577b1..cb34dd9e 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -31,9 +31,10 @@ jobs: uses: actions/checkout@v4 - name: Setup Python - uses: ./.github/actions/setup-python - with: + uses: actions/setup-python@v5 + with: python-version: ${{ matrix.python-version }} + cache: "pip" cache-dependency-path: "requirements.txt" - name: Setup Dependencies (Windows) From 4b216e58257b5c2d0e83802d5641d4e294e4a395 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Thu, 1 Aug 2024 04:14:51 +0000 Subject: [PATCH 108/126] test python v3.9, bug fix --- .github/workflows/run_smoke_test.yml | 2 +- Testing/Functional/SmokeTests/smoke_test_utils.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index cb34dd9e..940ecd02 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -23,7 +23,7 @@ jobs: fail-fast: false matrix: os: [windows-latest, macos-latest] - python-version: [3.12] + python-version: [3.9, 3.12] runs-on: ${{ matrix.os }} environment: Development steps: diff --git a/Testing/Functional/SmokeTests/smoke_test_utils.py b/Testing/Functional/SmokeTests/smoke_test_utils.py index 6f900f5b..e0b7e675 100644 --- a/Testing/Functional/SmokeTests/smoke_test_utils.py +++ b/Testing/Functional/SmokeTests/smoke_test_utils.py @@ -8,7 +8,7 @@ def get_output_path() -> str: return os.path.join(os.getcwd(), directories[0]) def prepend_file_protocol(path: str) -> str: - if not path.startsWith("file://"): + if not path.startswith("file://"): path = "file://" + path return path From d184b69fcd06fdbf2e39b428ce89fd0c060430f0 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Thu, 1 Aug 2024 17:47:57 +0000 Subject: [PATCH 109/126] readability improvements --- .github/workflows/run_smoke_test.yml | 10 ++++----- Testing/Functional/SmokeTests/smoke_test.py | 11 ++++++---- .../Functional/SmokeTests/smoke_test_utils.py | 21 ++++++++++--------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 940ecd02..bd9b37ca 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -23,28 +23,28 @@ jobs: fail-fast: false matrix: os: [windows-latest, macos-latest] - python-version: [3.9, 3.12] + python-version: ["3.8.4", "3.12"] runs-on: ${{ matrix.os }} environment: Development steps: - name: Checkout Repository uses: actions/checkout@v4 - - name: Setup Python + - name: Setup Python v${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} cache: "pip" cache-dependency-path: "requirements.txt" - - name: Setup Dependencies (Windows) + - name: Setup Dependencies (${{ matrix.os }}) if: ${{ matrix.os == 'windows-latest' }} uses: ./.github/actions/setup-dependencies-windows with: operating-system: "windows" opa-version: "0.60.0" - - name: Setup Dependencies (macOS) + - name: Setup Dependencies (${{ matrix.os }}) if: ${{ matrix.os == 'macos-latest' }} uses: ./.github/actions/setup-dependencies-macos with: @@ -58,5 +58,5 @@ jobs: name: "credentials.json" json: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }} - - name: Execute ScubaGoggles and check for correct output + - name: Run ScubaGoggles and check for correct output run: pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" --domain="${{ secrets.GWS_DOMAIN }}" diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index e971c1b9..ee8632b9 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -1,6 +1,9 @@ """ -smoke_test.py is a test script to verify `scubagoggles gws` -generates the correct outputs (i.e., directories, files). +smoke_test.py is a test script to verify `scubagoggles gws`. + +It checks for the following cases: +- Generate the correct output files (BaselineReports.html, ScubaResults.json, etc) +- Check the content of html files, verify href attributes are correct, etc """ import pytest @@ -23,8 +26,8 @@ def test_scubagoggles_output(self, subjectemail): subprocess.run(command, shell=True) output_path: str = get_output_path() - contents: list[str] = verify_output_type(output_path, []) - verify_all_outputs_exist(contents) + output: list[str] = verify_output_type(output_path, []) + verify_all_outputs_exist(output) except (OSError, ValueError, Exception) as e: pytest.fail(f"An error occurred, {e}") diff --git a/Testing/Functional/SmokeTests/smoke_test_utils.py b/Testing/Functional/SmokeTests/smoke_test_utils.py index e0b7e675..b86e6834 100644 --- a/Testing/Functional/SmokeTests/smoke_test_utils.py +++ b/Testing/Functional/SmokeTests/smoke_test_utils.py @@ -12,15 +12,16 @@ def prepend_file_protocol(path: str) -> str: path = "file://" + path return path -def verify_output_type(output_path: str, contents: list[str]) -> list[str]: +def verify_output_type(output_path: str, output: list[str]) -> list[str]: entries: list[str] = os.listdir(output_path) for entry in entries: - contents.append(entry) + output.append(entry) # Check if entry is a valid directory or file + # If a valid directory, then recurse child_path: str = os.path.join(output_path, entry) if os.path.isdir(child_path): assert True - verify_output_type(child_path, contents) + verify_output_type(child_path, output) elif os.path.isfile(child_path): # Check for valid json if child_path.endswith(".json"): @@ -28,13 +29,13 @@ def verify_output_type(output_path: str, contents: list[str]) -> list[str]: with open(child_path) as jsonfile: json.load(jsonfile) except ValueError as e: - pytest.fail(f"Invalid json, ${e}") + raise ValueError(f"{child_path} contains invalid json, {e}") assert True else: raise OSError(f"Entry is not a directory or file (symlink, etc.)") - return contents + return output -required_contents = [ +required_entries = [ "BaselineReports.html", "IndividualReports", "ScubaResults.json", @@ -54,9 +55,9 @@ def verify_output_type(output_path: str, contents: list[str]) -> list[str]: "triangle-exclamation-solid.svg" ] -def verify_all_outputs_exist(contents: list[str]): - for required_content in required_contents: - if required_content in contents: +def verify_all_outputs_exist(output: list[str]): + for required_entry in required_entries: + if required_entry in output: assert True else: - raise ValueError(f"{required_content} was not found in the generated report") \ No newline at end of file + raise ValueError(f"{required_entry} was not found in the generated report") \ No newline at end of file From 65a058236c670fc8001e0c5b160a406a6a25eed6 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Thu, 1 Aug 2024 22:55:05 +0000 Subject: [PATCH 110/126] expand selenium testing of scubagoggles reports, checks parent/individual reports --- .github/workflows/run_smoke_test.yml | 4 +- Testing/Functional/SmokeTests/smoke_test.py | 79 +++++++++++++-------- 2 files changed, 54 insertions(+), 29 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index bd9b37ca..61330902 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -23,7 +23,9 @@ jobs: fail-fast: false matrix: os: [windows-latest, macos-latest] - python-version: ["3.8.4", "3.12"] + # See https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json, + # ctrl + f and search "python-3..-" for supported versions + python-version: ["3.8.10", "3.9", "3.10", "3.12"] runs-on: ${{ matrix.os }} environment: Development steps: diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index ee8632b9..79449226 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -18,6 +18,7 @@ verify_all_outputs_exist, verify_output_type, ) +from scubagoggles.orchestrator import gws_products class SmokeTest: def test_scubagoggles_output(self, subjectemail): @@ -40,32 +41,29 @@ def test_scubagoggles_report(self, browser, domain): h1 = browser.find_element(By.TAG_NAME, "h1").text assert h1 == "SCuBA GWS Security Baseline Conformance Reports" - # verify domain is present in agency table - agency_table = browser.find_element(By.TAG_NAME, "table") - tbody = agency_table.find_element(By.TAG_NAME, "tbody") - rows = tbody.find_elements(By.TAG_NAME, "tr") - assert len(rows) == 2 - assert rows[1].find_elements(By.TAG_NAME, "td")[0].text == domain - - baseline_names = [ - "Google Calendar", - "Google Chat", - "Google Classroom", - "Common Controls", - "Google Drive and Docs", - "Gmail", - "Groups for Business", - "Google Meet", - "Rules", - "Google Sites" - ] + products = { + product: { "title": f"{product} Baseline Report" } + for product in gws_products()["prod_to_fullname"].values() + } + + print(products) + + # Before entering loop check that we actually display 10 rows in table for i in range(10): + # verify domain is present in agency table + tenant_table = browser.find_element(By.TAG_NAME, "table") + tbody = tenant_table.find_element(By.TAG_NAME, "tbody") + rows = tbody.find_elements(By.TAG_NAME, "tr") + assert len(rows) == 2 + assert rows[1].find_elements(By.TAG_NAME, "td")[0].text == domain + reports_table = browser.find_elements(By.TAG_NAME, "table")[1] tbody = reports_table.find_element(By.TAG_NAME, "tbody") rows = tbody.find_elements(By.TAG_NAME, "tr") td = rows[i].find_elements(By.TAG_NAME, "td")[0] - assert td.text in baseline_names + product = td.text + assert product in products individual_report_anchor = td.find_element(By.TAG_NAME, "a") href = individual_report_anchor.get_attribute("href") @@ -73,19 +71,44 @@ def test_scubagoggles_report(self, browser, domain): current_url = browser.current_url assert href == current_url + # Check at the individual report level + tenant_table = browser.find_element(By.TAG_NAME, "table") + tbody = tenant_table.find_element(By.TAG_NAME, "tbody") + rows = tbody.find_elements(By.TAG_NAME, "tr") + assert len(rows) == 2 + assert rows[1].find_elements(By.TAG_NAME, "td")[0].text == domain + + h1 = browser.find_element(By.TAG_NAME, "h1").text + print(products[product]) + print(products[product]["title"]) + assert h1 == products[product]["title"] + + policy_tables = browser.find_elements(By.TAG_NAME, "table") + for table in policy_tables[1:]: + # Verify policy table headers are correct + headers = ( + table.find_element(By.TAG_NAME, "thead") + .find_elements(By.TAG_NAME, "tr")[0] + .find_elements(By.TAG_NAME, "th") + ) + assert len(headers) == 5 + assert headers[0].text == "Control ID" + assert headers[1].text == "Requirement" or "Rule Name" + assert headers[2].text == "Result" + assert headers[3].text == "Criticality" + assert headers[4].text == "Details" or "Rule Description" + + # Verify policy table rows are populated + tbody = table.find_element(By.TAG_NAME, "tbody") + rows = tbody.find_elements(By.TAG_NAME, "tr") + assert len(rows) > 0 + browser.back() WebDriverWait(browser, 10).until( expected_conditions.presence_of_element_located( (By.TAG_NAME, "body") ) ) - - # Navigation to detailed reports - - # Check links work - - # Verify tables are populated - - except Exception as e: + browser.quit() pytest.fail(f"An error occurred, {e}") \ No newline at end of file From 15fcccb4475511005aedf868f03cd3b28222a961 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Thu, 1 Aug 2024 23:52:53 +0000 Subject: [PATCH 111/126] refactor smoke_test.py; add run_selenium method for handling report testing --- .github/workflows/run_smoke_test.yml | 4 +- Testing/Functional/SmokeTests/smoke_test.py | 79 +--------------- .../Functional/SmokeTests/smoke_test_utils.py | 91 ++++++++++++++++++- 3 files changed, 94 insertions(+), 80 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 61330902..88c66c03 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -39,14 +39,14 @@ jobs: cache: "pip" cache-dependency-path: "requirements.txt" - - name: Setup Dependencies (${{ matrix.os }}) + - name: Setup Dependencies (Windows) if: ${{ matrix.os == 'windows-latest' }} uses: ./.github/actions/setup-dependencies-windows with: operating-system: "windows" opa-version: "0.60.0" - - name: Setup Dependencies (${{ matrix.os }}) + - name: Setup Dependencies (macOS) if: ${{ matrix.os == 'macos-latest' }} uses: ./.github/actions/setup-dependencies-macos with: diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index 79449226..d533bb1d 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -9,17 +9,13 @@ import pytest import subprocess import os -from selenium.webdriver.common.by import By -from selenium.webdriver.support.ui import WebDriverWait -from selenium.webdriver.support import expected_conditions from smoke_test_utils import ( get_output_path, prepend_file_protocol, verify_all_outputs_exist, verify_output_type, + run_selenium, ) -from scubagoggles.orchestrator import gws_products - class SmokeTest: def test_scubagoggles_output(self, subjectemail): try: @@ -37,78 +33,7 @@ def test_scubagoggles_report(self, browser, domain): output_path: str = get_output_path() report_path: str = prepend_file_protocol(os.path.join(output_path, "BaselineReports.html")) browser.get(report_path) - - h1 = browser.find_element(By.TAG_NAME, "h1").text - assert h1 == "SCuBA GWS Security Baseline Conformance Reports" - - products = { - product: { "title": f"{product} Baseline Report" } - for product in gws_products()["prod_to_fullname"].values() - } - - print(products) - - # Before entering loop check that we actually display 10 rows in table - - for i in range(10): - # verify domain is present in agency table - tenant_table = browser.find_element(By.TAG_NAME, "table") - tbody = tenant_table.find_element(By.TAG_NAME, "tbody") - rows = tbody.find_elements(By.TAG_NAME, "tr") - assert len(rows) == 2 - assert rows[1].find_elements(By.TAG_NAME, "td")[0].text == domain - - reports_table = browser.find_elements(By.TAG_NAME, "table")[1] - tbody = reports_table.find_element(By.TAG_NAME, "tbody") - rows = tbody.find_elements(By.TAG_NAME, "tr") - td = rows[i].find_elements(By.TAG_NAME, "td")[0] - product = td.text - assert product in products - - individual_report_anchor = td.find_element(By.TAG_NAME, "a") - href = individual_report_anchor.get_attribute("href") - individual_report_anchor.click() - current_url = browser.current_url - assert href == current_url - - # Check at the individual report level - tenant_table = browser.find_element(By.TAG_NAME, "table") - tbody = tenant_table.find_element(By.TAG_NAME, "tbody") - rows = tbody.find_elements(By.TAG_NAME, "tr") - assert len(rows) == 2 - assert rows[1].find_elements(By.TAG_NAME, "td")[0].text == domain - - h1 = browser.find_element(By.TAG_NAME, "h1").text - print(products[product]) - print(products[product]["title"]) - assert h1 == products[product]["title"] - - policy_tables = browser.find_elements(By.TAG_NAME, "table") - for table in policy_tables[1:]: - # Verify policy table headers are correct - headers = ( - table.find_element(By.TAG_NAME, "thead") - .find_elements(By.TAG_NAME, "tr")[0] - .find_elements(By.TAG_NAME, "th") - ) - assert len(headers) == 5 - assert headers[0].text == "Control ID" - assert headers[1].text == "Requirement" or "Rule Name" - assert headers[2].text == "Result" - assert headers[3].text == "Criticality" - assert headers[4].text == "Details" or "Rule Description" - - # Verify policy table rows are populated - tbody = table.find_element(By.TAG_NAME, "tbody") - rows = tbody.find_elements(By.TAG_NAME, "tr") - assert len(rows) > 0 - - browser.back() - WebDriverWait(browser, 10).until( - expected_conditions.presence_of_element_located( - (By.TAG_NAME, "body") - ) - ) + run_selenium(browser, domain) except Exception as e: browser.quit() pytest.fail(f"An error occurred, {e}") \ No newline at end of file diff --git a/Testing/Functional/SmokeTests/smoke_test_utils.py b/Testing/Functional/SmokeTests/smoke_test_utils.py index b86e6834..cbe52806 100644 --- a/Testing/Functional/SmokeTests/smoke_test_utils.py +++ b/Testing/Functional/SmokeTests/smoke_test_utils.py @@ -1,6 +1,10 @@ import pytest import os import json +from scubagoggles.orchestrator import gws_products +from selenium.webdriver.common.by import By +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support import expected_conditions def get_output_path() -> str: directories: list[str] = [d for d in os.listdir() if os.path.isdir(d) and d.startswith("GWSBaselineConformance")] @@ -60,4 +64,89 @@ def verify_all_outputs_exist(output: list[str]): if required_entry in output: assert True else: - raise ValueError(f"{required_entry} was not found in the generated report") \ No newline at end of file + raise ValueError(f"{required_entry} was not found in the generated report") + +def run_selenium(browser, domain): + h1 = browser.find_element(By.TAG_NAME, "h1").text + assert h1 == "SCuBA GWS Security Baseline Conformance Reports" + + products = { + product: { "title": f"{product} Baseline Report" } + for product in gws_products()["prod_to_fullname"].values() + } + print(products) + + # Before entering loop check that we actually display 10 rows in table + reports_table = get_reports_table(browser) + + if len(reports_table) == 10: + for i in range(len(reports_table)): + # Verify domain is present in agency table + tenant_table = get_tenant_table(browser) + assert len(tenant_table) == 2 + customer_domain = tenant_table[1].find_elements(By.TAG_NAME, "td")[0].text + assert customer_domain == domain + + reports_table = get_reports_table(browser)[i] + baseline_report = reports_table.find_elements(By.TAG_NAME, "td")[0] + product = baseline_report.text + assert product in products + + individual_report_anchor = baseline_report.find_element(By.TAG_NAME, "a") + href = individual_report_anchor.get_attribute("href") + individual_report_anchor.click() + current_url = browser.current_url + assert href == current_url + + # Check at the individual report level + tenant_table = get_tenant_table(browser) + assert len(tenant_table) == 2 + assert tenant_table[1].find_elements(By.TAG_NAME, "td")[0].text == domain + + h1 = browser.find_element(By.TAG_NAME, "h1").text + print(products[product]) + print(products[product]["title"]) + assert h1 == products[product]["title"] + + policy_tables = browser.find_elements(By.TAG_NAME, "table") + for table in policy_tables[1:]: + # Verify policy table headers are correct + headers = ( + table.find_element(By.TAG_NAME, "thead") + .find_elements(By.TAG_NAME, "tr")[0] + .find_elements(By.TAG_NAME, "th") + ) + assert len(headers) == 5 + assert headers[0].text == "Control ID" + assert headers[1].text == "Requirement" or "Rule Name" + assert headers[2].text == "Result" + assert headers[3].text == "Criticality" + assert headers[4].text == "Details" or "Rule Description" + + # Verify policy table rows are populated + tbody = table.find_element(By.TAG_NAME, "tbody") + rows = tbody.find_elements(By.TAG_NAME, "tr") + assert len(rows) > 0 + + browser.back() + WebDriverWait(browser, 10).until( + expected_conditions.presence_of_element_located( + (By.TAG_NAME, "body") + ) + ) + else: + raise ValueError(f"Expected the reports table to have a length of 10") + +def get_tenant_table(browser): + return ( + browser.find_element(By.TAG_NAME, "table") + .find_element(By.TAG_NAME, "tbody") + .find_elements(By.TAG_NAME, "tr") + ) + +def get_reports_table(browser): + return ( + browser.find_elements(By.TAG_NAME, "table")[1] + .find_element(By.TAG_NAME, "tbody") + .find_elements(By.TAG_NAME, "tr") + ) \ No newline at end of file From cf3e5190c8d0450e74b008f7480d8a2e0ec1c952 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 2 Aug 2024 03:19:27 +0000 Subject: [PATCH 112/126] conditionally uninstall numpy to see if 3.8.10 passes smoke test; some additional refactoring/code improvements --- .../setup-dependencies-macos/action.yml | 6 +- .../setup-dependencies-windows/action.yml | 11 ++- .github/workflows/run_smoke_test.yml | 2 + Testing/Functional/SmokeTests/smoke_test.py | 7 +- .../Functional/SmokeTests/smoke_test_utils.py | 82 ++++++++++--------- 5 files changed, 59 insertions(+), 49 deletions(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index fad75cd3..161362c8 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -31,8 +31,4 @@ runs: shell: bash run: | python download_opa.py -v ${{ inputs.opa-version }} -os ${{ inputs.operating-system }} - - # Give OPA executable execute permissions - chmod +x opa_darwin_amd64 - - \ No newline at end of file + chmod +x opa_darwin_amd64 \ No newline at end of file diff --git a/.github/actions/setup-dependencies-windows/action.yml b/.github/actions/setup-dependencies-windows/action.yml index 8da70fd2..62a01ff8 100644 --- a/.github/actions/setup-dependencies-windows/action.yml +++ b/.github/actions/setup-dependencies-windows/action.yml @@ -6,6 +6,8 @@ inputs: opa-version: required: true default: "0.60.0" + python-version: + required: true runs: using: "composite" @@ -24,8 +26,13 @@ runs: pip install -r requirements.txt pip install pytest pip install selenium - pip uninstall -y numpy - pip install numpy==1.26.4 + + # Below python v3.9, a lower numpy v1.24.4 is used + $pythonVersion = [version]${{ inputs.python-version }} + if ($pythonVersion -ge [version]"3.9") { + pip uninstall -y numpy + pip install numpy==1.26.4 + } - name: Download OPA executable shell: powershell diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 88c66c03..f464ad64 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -45,6 +45,7 @@ jobs: with: operating-system: "windows" opa-version: "0.60.0" + python-version: ${{ matrix.python-version }} - name: Setup Dependencies (macOS) if: ${{ matrix.os == 'macos-latest' }} @@ -52,6 +53,7 @@ jobs: with: operating-system: "macos" opa-version: "0.60.0" + python-version: ${{ matrix.python-version }} - name: Setup credentials for service account id: create-json diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index d533bb1d..8ec7fbd1 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -12,6 +12,7 @@ from smoke_test_utils import ( get_output_path, prepend_file_protocol, + get_required_entries, verify_all_outputs_exist, verify_output_type, run_selenium, @@ -21,10 +22,10 @@ def test_scubagoggles_output(self, subjectemail): try: command: str = f"scubagoggles gws --subjectemail {subjectemail} --quiet" subprocess.run(command, shell=True) - output_path: str = get_output_path() output: list[str] = verify_output_type(output_path, []) - verify_all_outputs_exist(output) + required_entries = get_required_entries(os.path.join(os.getcwd(), "sample-report"), []) + verify_all_outputs_exist(output, required_entries) except (OSError, ValueError, Exception) as e: pytest.fail(f"An error occurred, {e}") @@ -34,6 +35,6 @@ def test_scubagoggles_report(self, browser, domain): report_path: str = prepend_file_protocol(os.path.join(output_path, "BaselineReports.html")) browser.get(report_path) run_selenium(browser, domain) - except Exception as e: + except (ValueError, Exception) as e: browser.quit() pytest.fail(f"An error occurred, {e}") \ No newline at end of file diff --git a/Testing/Functional/SmokeTests/smoke_test_utils.py b/Testing/Functional/SmokeTests/smoke_test_utils.py index cbe52806..43b0aa2e 100644 --- a/Testing/Functional/SmokeTests/smoke_test_utils.py +++ b/Testing/Functional/SmokeTests/smoke_test_utils.py @@ -6,6 +6,9 @@ from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions +CISA_GOV_URL = "https://www.cisa.gov/scuba" +SCUBAGOGGLES_BASELINES_URL = "https://github.com/cisagov/ScubaGoggles/tree/main/baselines" + def get_output_path() -> str: directories: list[str] = [d for d in os.listdir() if os.path.isdir(d) and d.startswith("GWSBaselineConformance")] directories.sort(key=lambda d: os.path.getctime(d), reverse=True) @@ -20,6 +23,7 @@ def verify_output_type(output_path: str, output: list[str]) -> list[str]: entries: list[str] = os.listdir(output_path) for entry in entries: output.append(entry) + # Check if entry is a valid directory or file # If a valid directory, then recurse child_path: str = os.path.join(output_path, entry) @@ -27,6 +31,7 @@ def verify_output_type(output_path: str, output: list[str]) -> list[str]: assert True verify_output_type(child_path, output) elif os.path.isfile(child_path): + # Check for valid json if child_path.endswith(".json"): try: @@ -39,27 +44,15 @@ def verify_output_type(output_path: str, output: list[str]) -> list[str]: raise OSError(f"Entry is not a directory or file (symlink, etc.)") return output -required_entries = [ - "BaselineReports.html", - "IndividualReports", - "ScubaResults.json", - "TestResults.json", - "images", - "CalendarReport.html", - "ChatReport.html", - "ClassroomReport.html", - "CommoncontrolsReport.html", - "DriveReport.html", - "GmailReport.html", - "GroupsReport.html", - "MeetReport.html", - "RulesReport.html", - "SitesReport.html", - "cisa_logo.png", - "triangle-exclamation-solid.svg" -] - -def verify_all_outputs_exist(output: list[str]): +def get_required_entries(directory, required_entries) -> list[str]: + with os.scandir(directory) as entries: + for entry in entries: + required_entries.append(entry.name) + if entry.is_dir(): + get_required_entries(entry.path, required_entries) + return required_entries + +def verify_all_outputs_exist(output: list[str], required_entries: list[str]): for required_entry in required_entries: if required_entry in output: assert True @@ -67,6 +60,7 @@ def verify_all_outputs_exist(output: list[str]): raise ValueError(f"{required_entry} was not found in the generated report") def run_selenium(browser, domain): + verify_navigation_links(browser) h1 = browser.find_element(By.TAG_NAME, "h1").text assert h1 == "SCuBA GWS Security Baseline Conformance Reports" @@ -74,18 +68,18 @@ def run_selenium(browser, domain): product: { "title": f"{product} Baseline Report" } for product in gws_products()["prod_to_fullname"].values() } - print(products) # Before entering loop check that we actually display 10 rows in table reports_table = get_reports_table(browser) if len(reports_table) == 10: for i in range(len(reports_table)): - # Verify domain is present in agency table - tenant_table = get_tenant_table(browser) - assert len(tenant_table) == 2 - customer_domain = tenant_table[1].find_elements(By.TAG_NAME, "td")[0].text - assert customer_domain == domain + + # Check if domain is present in agency table + verify_tenant_table(browser, domain) + + # TODO: + # Check for correct baseline and tool version, e.g. 0.2, 0.2.0 reports_table = get_reports_table(browser)[i] baseline_report = reports_table.find_elements(By.TAG_NAME, "td")[0] @@ -99,17 +93,15 @@ def run_selenium(browser, domain): assert href == current_url # Check at the individual report level - tenant_table = get_tenant_table(browser) - assert len(tenant_table) == 2 - assert tenant_table[1].find_elements(By.TAG_NAME, "td")[0].text == domain - + verify_navigation_links(browser) h1 = browser.find_element(By.TAG_NAME, "h1").text - print(products[product]) - print(products[product]["title"]) assert h1 == products[product]["title"] + verify_tenant_table(browser, domain) + policy_tables = browser.find_elements(By.TAG_NAME, "table") for table in policy_tables[1:]: + # Verify policy table headers are correct headers = ( table.find_element(By.TAG_NAME, "thead") @@ -137,16 +129,28 @@ def run_selenium(browser, domain): else: raise ValueError(f"Expected the reports table to have a length of 10") -def get_tenant_table(browser): - return ( - browser.find_element(By.TAG_NAME, "table") - .find_element(By.TAG_NAME, "tbody") - .find_elements(By.TAG_NAME, "tr") +def verify_navigation_links(browser): + links = ( + browser.find_element(By.CLASS_NAME, "links") + .find_elements(By.TAG_NAME, "a") ) + if len(links) == 2: + assert links[0].get_attribute("href") == CISA_GOV_URL + assert links[1].get_attribute("href") == SCUBAGOGGLES_BASELINES_URL def get_reports_table(browser): return ( browser.find_elements(By.TAG_NAME, "table")[1] .find_element(By.TAG_NAME, "tbody") .find_elements(By.TAG_NAME, "tr") - ) \ No newline at end of file + ) + +def verify_tenant_table(browser, domain): + tenant_table = ( + browser.find_element(By.TAG_NAME, "table") + .find_element(By.TAG_NAME, "tbody") + .find_elements(By.TAG_NAME, "tr") + ) + assert len(tenant_table) == 2 + customer_domain = tenant_table[1].find_elements(By.TAG_NAME, "td")[0].text + assert customer_domain == domain \ No newline at end of file From a21b27ba75cef751423d6a717d109d04f6f44946 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 2 Aug 2024 03:27:16 +0000 Subject: [PATCH 113/126] conditionally uninstall numpy to see if 3.8.10 passes smoke test; some additional refactoring/code improvements --- .../actions/setup-dependencies-windows/action.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/actions/setup-dependencies-windows/action.yml b/.github/actions/setup-dependencies-windows/action.yml index 62a01ff8..930eeca6 100644 --- a/.github/actions/setup-dependencies-windows/action.yml +++ b/.github/actions/setup-dependencies-windows/action.yml @@ -27,12 +27,14 @@ runs: pip install pytest pip install selenium + pip uninstall -y numpy + pip install numpy==1.26.4 # Below python v3.9, a lower numpy v1.24.4 is used - $pythonVersion = [version]${{ inputs.python-version }} - if ($pythonVersion -ge [version]"3.9") { - pip uninstall -y numpy - pip install numpy==1.26.4 - } + #$pythonVersion = [version]${{ inputs.python-version }} + #if ($pythonVersion -ge [version]"3.9") { + # pip uninstall -y numpy + # pip install numpy==1.26.4 + #} - name: Download OPA executable shell: powershell From 7075862123d390fb871916fcc96203d1da3353f9 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 2 Aug 2024 03:43:03 +0000 Subject: [PATCH 114/126] try simplifying types to see if 3.8.10 passes --- .../setup-dependencies-windows/action.yml | 12 ++++------ Testing/Functional/SmokeTests/smoke_test.py | 2 +- .../Functional/SmokeTests/smoke_test_utils.py | 24 ++++++++++++------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/.github/actions/setup-dependencies-windows/action.yml b/.github/actions/setup-dependencies-windows/action.yml index 930eeca6..0de8c8a2 100644 --- a/.github/actions/setup-dependencies-windows/action.yml +++ b/.github/actions/setup-dependencies-windows/action.yml @@ -27,14 +27,12 @@ runs: pip install pytest pip install selenium - pip uninstall -y numpy - pip install numpy==1.26.4 # Below python v3.9, a lower numpy v1.24.4 is used - #$pythonVersion = [version]${{ inputs.python-version }} - #if ($pythonVersion -ge [version]"3.9") { - # pip uninstall -y numpy - # pip install numpy==1.26.4 - #} + $pythonVersion = [version]${{ inputs.python-version }} + if ($pythonVersion -ge [version]"3.8.18") { + pip uninstall -y numpy + pip install numpy==1.26.4 + } - name: Download OPA executable shell: powershell diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index 8ec7fbd1..c6b37915 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -23,7 +23,7 @@ def test_scubagoggles_output(self, subjectemail): command: str = f"scubagoggles gws --subjectemail {subjectemail} --quiet" subprocess.run(command, shell=True) output_path: str = get_output_path() - output: list[str] = verify_output_type(output_path, []) + output: list = verify_output_type(output_path, []) required_entries = get_required_entries(os.path.join(os.getcwd(), "sample-report"), []) verify_all_outputs_exist(output, required_entries) except (OSError, ValueError, Exception) as e: diff --git a/Testing/Functional/SmokeTests/smoke_test_utils.py b/Testing/Functional/SmokeTests/smoke_test_utils.py index 43b0aa2e..2e9e92da 100644 --- a/Testing/Functional/SmokeTests/smoke_test_utils.py +++ b/Testing/Functional/SmokeTests/smoke_test_utils.py @@ -10,7 +10,7 @@ SCUBAGOGGLES_BASELINES_URL = "https://github.com/cisagov/ScubaGoggles/tree/main/baselines" def get_output_path() -> str: - directories: list[str] = [d for d in os.listdir() if os.path.isdir(d) and d.startswith("GWSBaselineConformance")] + directories: list = [d for d in os.listdir() if os.path.isdir(d) and d.startswith("GWSBaselineConformance")] directories.sort(key=lambda d: os.path.getctime(d), reverse=True) return os.path.join(os.getcwd(), directories[0]) @@ -19,8 +19,8 @@ def prepend_file_protocol(path: str) -> str: path = "file://" + path return path -def verify_output_type(output_path: str, output: list[str]) -> list[str]: - entries: list[str] = os.listdir(output_path) +def verify_output_type(output_path: str, output: list) -> list: + entries: list = os.listdir(output_path) for entry in entries: output.append(entry) @@ -44,7 +44,7 @@ def verify_output_type(output_path: str, output: list[str]) -> list[str]: raise OSError(f"Entry is not a directory or file (symlink, etc.)") return output -def get_required_entries(directory, required_entries) -> list[str]: +def get_required_entries(directory, required_entries) -> list: with os.scandir(directory) as entries: for entry in entries: required_entries.append(entry.name) @@ -52,7 +52,7 @@ def get_required_entries(directory, required_entries) -> list[str]: get_required_entries(entry.path, required_entries) return required_entries -def verify_all_outputs_exist(output: list[str], required_entries: list[str]): +def verify_all_outputs_exist(output: list, required_entries: list): for required_entry in required_entries: if required_entry in output: assert True @@ -87,10 +87,10 @@ def run_selenium(browser, domain): assert product in products individual_report_anchor = baseline_report.find_element(By.TAG_NAME, "a") - href = individual_report_anchor.get_attribute("href") + individual_report_anchor_href = individual_report_anchor.get_attribute("href") individual_report_anchor.click() current_url = browser.current_url - assert href == current_url + assert individual_report_anchor_href == current_url # Check at the individual report level verify_navigation_links(browser) @@ -120,7 +120,15 @@ def run_selenium(browser, domain): rows = tbody.find_elements(By.TAG_NAME, "tr") assert len(rows) > 0 - browser.back() + parent_report_anchor = ( + browser.find_element(By.TAG_NAME, "header") + .find_element(By.TAG_NAME, "a") + ) + parent_report_anchor_href = parent_report_anchor.get_attribute("href") + parent_report_anchor.click() + current_url = browser.current_url + assert parent_report_anchor_href == current_url + WebDriverWait(browser, 10).until( expected_conditions.presence_of_element_located( (By.TAG_NAME, "body") From bf18a9d1cc055f26a6502076174c559921ff13a8 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 2 Aug 2024 04:35:42 +0000 Subject: [PATCH 115/126] finish testing scubaresults for errors --- .../actions/setup-dependencies-windows/action.yml | 12 +++++++----- Testing/Functional/SmokeTests/smoke_test.py | 12 ++++++++++++ Testing/Functional/SmokeTests/smoke_test_utils.py | 6 ++++++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.github/actions/setup-dependencies-windows/action.yml b/.github/actions/setup-dependencies-windows/action.yml index 0de8c8a2..9b6e524c 100644 --- a/.github/actions/setup-dependencies-windows/action.yml +++ b/.github/actions/setup-dependencies-windows/action.yml @@ -27,12 +27,14 @@ runs: pip install pytest pip install selenium + pip uninstall -y numpy + pip install numpy==1.26.4 # Below python v3.9, a lower numpy v1.24.4 is used - $pythonVersion = [version]${{ inputs.python-version }} - if ($pythonVersion -ge [version]"3.8.18") { - pip uninstall -y numpy - pip install numpy==1.26.4 - } + #$pythonVersion = [version]${{ inputs.python-version }} + #if ($pythonVersion -ge [version]"3.8.18") { + # pip uninstall -y numpy + # pip install numpy==1.26.4 + #} - name: Download OPA executable shell: powershell diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index c6b37915..75d65a2d 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -4,6 +4,8 @@ It checks for the following cases: - Generate the correct output files (BaselineReports.html, ScubaResults.json, etc) - Check the content of html files, verify href attributes are correct, etc +- Check if ScubaResults.json contains errors in the summary. If errors exist, then + either API calls or functions produced exceptions which need to be handled """ import pytest @@ -16,6 +18,7 @@ verify_all_outputs_exist, verify_output_type, run_selenium, + verify_scubaresults, ) class SmokeTest: def test_scubagoggles_output(self, subjectemail): @@ -28,6 +31,15 @@ def test_scubagoggles_output(self, subjectemail): verify_all_outputs_exist(output, required_entries) except (OSError, ValueError, Exception) as e: pytest.fail(f"An error occurred, {e}") + + def test_scubaresults(self): + try: + output_path: str = get_output_path() + scubaresults_path: str = os.path.join(output_path, "ScubaResults.json") + with open(scubaresults_path) as jsonfile: + verify_scubaresults(jsonfile) + except ValueError as e: + raise ValueError(f"{scubaresults_path} contains invalid json, {e}") def test_scubagoggles_report(self, browser, domain): try: diff --git a/Testing/Functional/SmokeTests/smoke_test_utils.py b/Testing/Functional/SmokeTests/smoke_test_utils.py index 2e9e92da..fc952c9e 100644 --- a/Testing/Functional/SmokeTests/smoke_test_utils.py +++ b/Testing/Functional/SmokeTests/smoke_test_utils.py @@ -59,6 +59,12 @@ def verify_all_outputs_exist(output: list, required_entries: list): else: raise ValueError(f"{required_entry} was not found in the generated report") +def verify_scubaresults(jsonfile): + scubaresults = json.load(jsonfile) + summary = scubaresults["Summary"] + for v in summary.values(): + assert v["Errors"] == 0 + def run_selenium(browser, domain): verify_navigation_links(browser) h1 = browser.find_element(By.TAG_NAME, "h1").text From 55a7fda836c14235e2446ca32c1c81d200c8ef13 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 2 Aug 2024 17:00:08 +0000 Subject: [PATCH 116/126] encapsulate selenium driver setup into a class --- .github/workflows/run_smoke_test.yml | 2 +- .../Functional/SmokeTests/selenium_browser.py | 31 +++++++++++++++++++ Testing/Functional/SmokeTests/smoke_test.py | 6 ++-- .../Functional/SmokeTests/smoke_test_utils.py | 10 +++--- Testing/Functional/conftest.py | 14 +++------ 5 files changed, 45 insertions(+), 18 deletions(-) create mode 100644 Testing/Functional/SmokeTests/selenium_browser.py diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index f464ad64..6f337f9a 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -63,4 +63,4 @@ jobs: json: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }} - name: Run ScubaGoggles and check for correct output - run: pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" --domain="${{ secrets.GWS_DOMAIN }}" + run: pytest -s -vvv ./Testing/Functional/SmokeTests/ --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" --domain="${{ secrets.GWS_DOMAIN }}" diff --git a/Testing/Functional/SmokeTests/selenium_browser.py b/Testing/Functional/SmokeTests/selenium_browser.py new file mode 100644 index 00000000..746436ca --- /dev/null +++ b/Testing/Functional/SmokeTests/selenium_browser.py @@ -0,0 +1,31 @@ +""" +The Browser class encapsulates the setup, usage, and teardown of a +Selenium WebDriver instance for automated browser interactions. +""" + +from selenium import webdriver +from selenium.webdriver.chrome.options import Options + +class Browser: + def __init__(self): + chrome_options = Options() + chrome_options.add_argument("--headless") + chrome_options.add_argument("--no-sandbox") + chrome_options.add_argument("--disable-dev-shm-usage") + + self.driver = webdriver.Chrome(options=chrome_options) + + def get(self, url): + self.driver.get(url) + + def quit(self): + self.driver.quit() + + def find_element(self, by, value): + return self.driver.find_element(by, value) + + def find_elements(self, by, value): + return self.driver.find_elements(by, value) + + def current_url(self): + return self.driver.current_url \ No newline at end of file diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index 75d65a2d..8470456c 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -1,5 +1,5 @@ """ -smoke_test.py is a test script to verify `scubagoggles gws`. +smoke_test.py is a test script to verify `scubagoggles gws` output. It checks for the following cases: - Generate the correct output files (BaselineReports.html, ScubaResults.json, etc) @@ -39,7 +39,9 @@ def test_scubaresults(self): with open(scubaresults_path) as jsonfile: verify_scubaresults(jsonfile) except ValueError as e: - raise ValueError(f"{scubaresults_path} contains invalid json, {e}") + pytest.fail(f"{scubaresults_path} contains invalid json, {e}") + except Exception as e: + pytest.fail(f"An error occurred, {e}") def test_scubagoggles_report(self, browser, domain): try: diff --git a/Testing/Functional/SmokeTests/smoke_test_utils.py b/Testing/Functional/SmokeTests/smoke_test_utils.py index fc952c9e..2aa20884 100644 --- a/Testing/Functional/SmokeTests/smoke_test_utils.py +++ b/Testing/Functional/SmokeTests/smoke_test_utils.py @@ -61,9 +61,9 @@ def verify_all_outputs_exist(output: list, required_entries: list): def verify_scubaresults(jsonfile): scubaresults = json.load(jsonfile) - summary = scubaresults["Summary"] - for v in summary.values(): - assert v["Errors"] == 0 + summaries = scubaresults["Summary"] + for summary in summaries.values(): + assert summary["Errors"] == 0 def run_selenium(browser, domain): verify_navigation_links(browser) @@ -95,7 +95,7 @@ def run_selenium(browser, domain): individual_report_anchor = baseline_report.find_element(By.TAG_NAME, "a") individual_report_anchor_href = individual_report_anchor.get_attribute("href") individual_report_anchor.click() - current_url = browser.current_url + current_url = browser.current_url() assert individual_report_anchor_href == current_url # Check at the individual report level @@ -132,7 +132,7 @@ def run_selenium(browser, domain): ) parent_report_anchor_href = parent_report_anchor.get_attribute("href") parent_report_anchor.click() - current_url = browser.current_url + current_url = browser.current_url() assert parent_report_anchor_href == current_url WebDriverWait(browser, 10).until( diff --git a/Testing/Functional/conftest.py b/Testing/Functional/conftest.py index bb0ae9c5..b49a89fa 100644 --- a/Testing/Functional/conftest.py +++ b/Testing/Functional/conftest.py @@ -1,11 +1,5 @@ import pytest -from selenium import webdriver -from selenium.webdriver.chrome.options import Options - -chrome_options = Options() -chrome_options.add_argument("--headless") -chrome_options.add_argument("--no-sandbox") -chrome_options.add_argument("--disable-dev-shm-usage") +from SmokeTests.selenium_browser import Browser def pytest_addoption(parser): parser.addoption("--subjectemail", action="store") @@ -21,6 +15,6 @@ def domain(pytestconfig): @pytest.fixture def browser(): - driver = webdriver.Chrome(options=chrome_options) - yield driver - driver.quit() \ No newline at end of file + browser_instance = Browser() + yield browser_instance + browser_instance.quit() \ No newline at end of file From 31e644f2fdc7d6c513a9c58466663503ed673e9e Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 2 Aug 2024 17:13:26 +0000 Subject: [PATCH 117/126] remove 3.8 from workflow; convert some static strings to const --- .github/workflows/run_smoke_test.yml | 2 +- Testing/Functional/SmokeTests/smoke_test.py | 11 ++++++++--- Testing/Functional/SmokeTests/smoke_test_utils.py | 9 +++++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 6f337f9a..3f5f37c8 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -25,7 +25,7 @@ jobs: os: [windows-latest, macos-latest] # See https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json, # ctrl + f and search "python-3..-" for supported versions - python-version: ["3.8.10", "3.9", "3.10", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12"] # "3.8 fails with numpy uninstall" runs-on: ${{ matrix.os }} environment: Development steps: diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index 8470456c..f4a95eb2 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -20,6 +20,11 @@ run_selenium, verify_scubaresults, ) + +SAMPLE_REPORT = "sample-report" +SCUBA_RESULTS = "ScubaResults.json" +BASELINE_REPORTS = "BaselineReports.html" + class SmokeTest: def test_scubagoggles_output(self, subjectemail): try: @@ -27,7 +32,7 @@ def test_scubagoggles_output(self, subjectemail): subprocess.run(command, shell=True) output_path: str = get_output_path() output: list = verify_output_type(output_path, []) - required_entries = get_required_entries(os.path.join(os.getcwd(), "sample-report"), []) + required_entries = get_required_entries(os.path.join(os.getcwd(), SAMPLE_REPORT), []) verify_all_outputs_exist(output, required_entries) except (OSError, ValueError, Exception) as e: pytest.fail(f"An error occurred, {e}") @@ -35,7 +40,7 @@ def test_scubagoggles_output(self, subjectemail): def test_scubaresults(self): try: output_path: str = get_output_path() - scubaresults_path: str = os.path.join(output_path, "ScubaResults.json") + scubaresults_path: str = os.path.join(output_path, SCUBA_RESULTS) with open(scubaresults_path) as jsonfile: verify_scubaresults(jsonfile) except ValueError as e: @@ -46,7 +51,7 @@ def test_scubaresults(self): def test_scubagoggles_report(self, browser, domain): try: output_path: str = get_output_path() - report_path: str = prepend_file_protocol(os.path.join(output_path, "BaselineReports.html")) + report_path: str = prepend_file_protocol(os.path.join(output_path, BASELINE_REPORTS)) browser.get(report_path) run_selenium(browser, domain) except (ValueError, Exception) as e: diff --git a/Testing/Functional/SmokeTests/smoke_test_utils.py b/Testing/Functional/SmokeTests/smoke_test_utils.py index 2aa20884..e8826661 100644 --- a/Testing/Functional/SmokeTests/smoke_test_utils.py +++ b/Testing/Functional/SmokeTests/smoke_test_utils.py @@ -6,11 +6,16 @@ from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions +OUTPUT_DIRECTORY = "GWSBaselineConformance" +BASELINE_REPORT_H1 = "SCuBA GWS Security Baseline Conformance Reports" CISA_GOV_URL = "https://www.cisa.gov/scuba" SCUBAGOGGLES_BASELINES_URL = "https://github.com/cisagov/ScubaGoggles/tree/main/baselines" def get_output_path() -> str: - directories: list = [d for d in os.listdir() if os.path.isdir(d) and d.startswith("GWSBaselineConformance")] + directories: list = [ + d for d in os.listdir() + if os.path.isdir(d) and d.startswith(OUTPUT_DIRECTORY) + ] directories.sort(key=lambda d: os.path.getctime(d), reverse=True) return os.path.join(os.getcwd(), directories[0]) @@ -68,7 +73,7 @@ def verify_scubaresults(jsonfile): def run_selenium(browser, domain): verify_navigation_links(browser) h1 = browser.find_element(By.TAG_NAME, "h1").text - assert h1 == "SCuBA GWS Security Baseline Conformance Reports" + assert h1 == BASELINE_REPORT_H1 products = { product: { "title": f"{product} Baseline Report" } From b0d57a461ed5e0a9a222df87e7a45e30065bfcbf Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Mon, 5 Aug 2024 16:50:03 +0000 Subject: [PATCH 118/126] improve error handling when verifying scubaresults.json --- .github/actions/setup-dependencies-macos/action.yml | 2 ++ .github/workflows/run_smoke_test.yml | 2 +- Testing/Functional/SmokeTests/smoke_test.py | 4 +--- Testing/Functional/SmokeTests/smoke_test_utils.py | 5 +++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index 161362c8..06eedebe 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -6,6 +6,8 @@ inputs: opa-version: required: true default: "0.60.0" + python-version: + required: true runs: using: "composite" diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 3f5f37c8..4c5f1f68 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -3,7 +3,7 @@ on: workflow_call: workflow_dispatch: pull_request: - types: [opened, reopened] + types: [opened, reopened, synchronize] branches: - "main" pull_request_review: diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index f4a95eb2..a43a0f24 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -43,9 +43,7 @@ def test_scubaresults(self): scubaresults_path: str = os.path.join(output_path, SCUBA_RESULTS) with open(scubaresults_path) as jsonfile: verify_scubaresults(jsonfile) - except ValueError as e: - pytest.fail(f"{scubaresults_path} contains invalid json, {e}") - except Exception as e: + except (ValueError, Exception) as e: pytest.fail(f"An error occurred, {e}") def test_scubagoggles_report(self, browser, domain): diff --git a/Testing/Functional/SmokeTests/smoke_test_utils.py b/Testing/Functional/SmokeTests/smoke_test_utils.py index e8826661..222f7dba 100644 --- a/Testing/Functional/SmokeTests/smoke_test_utils.py +++ b/Testing/Functional/SmokeTests/smoke_test_utils.py @@ -67,8 +67,9 @@ def verify_all_outputs_exist(output: list, required_entries: list): def verify_scubaresults(jsonfile): scubaresults = json.load(jsonfile) summaries = scubaresults["Summary"] - for summary in summaries.values(): - assert summary["Errors"] == 0 + for product, summary in summaries.items(): + if summary["Errors"] != 0: + raise ValueError(f"{product} contains errors in the report") def run_selenium(browser, domain): verify_navigation_links(browser) From beb2a481963c5057ceddd288a803dde5a4f4b96f Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Mon, 5 Aug 2024 17:47:04 +0000 Subject: [PATCH 119/126] start addressing pylint warnings for selenium_browser.py --- .../setup-dependencies-macos/action.yml | 8 +++++-- .../setup-dependencies-windows/action.yml | 10 ++++++--- .github/workflows/run_smoke_test.yml | 11 +++++----- .../Functional/SmokeTests/selenium_browser.py | 22 ++++++++++++------- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index 06eedebe..9ae3b328 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -12,6 +12,12 @@ inputs: runs: using: "composite" steps: + - name: Install pytest and selenium + shell: bash + run: | + pip install pytest + pip install selenium + - name: Setup virtualenv shell: bash run: | @@ -24,8 +30,6 @@ runs: run: | python -m pip install . pip install -r requirements.txt - pip install pytest - pip install selenium pip uninstall -y numpy pip install numpy==1.26.4 diff --git a/.github/actions/setup-dependencies-windows/action.yml b/.github/actions/setup-dependencies-windows/action.yml index 9b6e524c..319055e1 100644 --- a/.github/actions/setup-dependencies-windows/action.yml +++ b/.github/actions/setup-dependencies-windows/action.yml @@ -12,6 +12,12 @@ inputs: runs: using: "composite" steps: + - name: Install pytest and selenium + shell: powershell + run: | + pip install pytest + pip install selenium + - name: Setup virtualenv shell: powershell run: | @@ -24,11 +30,9 @@ runs: run: | python -m pip install . pip install -r requirements.txt - pip install pytest - pip install selenium - pip uninstall -y numpy pip install numpy==1.26.4 + # Below python v3.9, a lower numpy v1.24.4 is used #$pythonVersion = [version]${{ inputs.python-version }} #if ($pythonVersion -ge [version]"3.8.18") { diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 4c5f1f68..2a8c3f98 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -9,10 +9,11 @@ on: pull_request_review: types: [submitted] push: - paths: - - ".github/workflows/run_smoke_test.yml" - - ".github/actions/setup-dependencies-windows/action.yml" - - ".github/actions/setup-dependencies-macos/action.yml" + # Uncomment when testing locally + #paths: + # - ".github/workflows/run_smoke_test.yml" + # - ".github/actions/setup-dependencies-windows/action.yml" + # - ".github/actions/setup-dependencies-macos/action.yml" branches: - "main" - "*smoke*" @@ -25,7 +26,7 @@ jobs: os: [windows-latest, macos-latest] # See https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json, # ctrl + f and search "python-3..-" for supported versions - python-version: ["3.9", "3.10", "3.11", "3.12"] # "3.8 fails with numpy uninstall" + python-version: ["3.9", "3.12"] # "3.8 fails with numpy uninstall" runs-on: ${{ matrix.os }} environment: Development steps: diff --git a/Testing/Functional/SmokeTests/selenium_browser.py b/Testing/Functional/SmokeTests/selenium_browser.py index 746436ca..775b985f 100644 --- a/Testing/Functional/SmokeTests/selenium_browser.py +++ b/Testing/Functional/SmokeTests/selenium_browser.py @@ -1,12 +1,12 @@ -""" -The Browser class encapsulates the setup, usage, and teardown of a -Selenium WebDriver instance for automated browser interactions. -""" - from selenium import webdriver from selenium.webdriver.chrome.options import Options class Browser: + """ + The Browser class encapsulates the setup, usage, and teardown of a + Selenium WebDriver instance for automated browser interactions. + """ + def __init__(self): chrome_options = Options() chrome_options.add_argument("--headless") @@ -16,14 +16,20 @@ def __init__(self): self.driver = webdriver.Chrome(options=chrome_options) def get(self, url): + """ + Load a new web page in the current browser window. + + Args: + url: The URL to load. Bust be a fully qualified URL + """ self.driver.get(url) - + def quit(self): self.driver.quit() - + def find_element(self, by, value): return self.driver.find_element(by, value) - + def find_elements(self, by, value): return self.driver.find_elements(by, value) From 5033e8c02ef83ad179779a8bef65d871a5174f50 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Mon, 5 Aug 2024 19:14:35 +0000 Subject: [PATCH 120/126] address pylint warnings across selenium_browser.py, smoke_test.py, smoke_test_utils.py --- .github/workflows/run_smoke_test.yml | 2 +- .../Functional/SmokeTests/selenium_browser.py | 39 ++++++++++++++- Testing/Functional/SmokeTests/smoke_test.py | 48 ++++++++++++------- .../Functional/SmokeTests/smoke_test_utils.py | 2 +- 4 files changed, 69 insertions(+), 22 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 2a8c3f98..7ce74d2d 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -16,7 +16,7 @@ on: # - ".github/actions/setup-dependencies-macos/action.yml" branches: - "main" - - "*smoke*" + #- "*smoke*" jobs: smoke-test: diff --git a/Testing/Functional/SmokeTests/selenium_browser.py b/Testing/Functional/SmokeTests/selenium_browser.py index 775b985f..821e225c 100644 --- a/Testing/Functional/SmokeTests/selenium_browser.py +++ b/Testing/Functional/SmokeTests/selenium_browser.py @@ -20,18 +20,53 @@ def get(self, url): Load a new web page in the current browser window. Args: - url: The URL to load. Bust be a fully qualified URL + url: The URL to load. Must be a fully qualified URL """ self.driver.get(url) def quit(self): + """ + Quits the driver, closing every associated window. + """ self.driver.quit() def find_element(self, by, value): + """ + Find the first WebElement using the given method. + This method is affected by the 'implicit wait' times in force at the time and execution. + The find_element(...) invocation will return a matching row, or try again repeatedly + until the configured timeout is reached. + + Args: + by: The locating mechanism to use, i.e. By.CLASS_NAME, By.TAG_NAME + value: The locator, i.e. "h1", "header" + + Returns: + WebElement: The first matching element on the current page + """ return self.driver.find_element(by, value) def find_elements(self, by, value): + """ + Find all WebElements within the current page. + This method is affected by the 'implicit wait' times in force at the time and execution. + The find_elements(...) invocation will return as soon as there are more than 0 items in + the found collection, or will return an empty list of the timeout is reached. + + Args: + by: The locating mechanism to use, i.e. By.CLASS_NAME, By.TAG_NAME + value: The locator, i.e. "h1", "header" + + Returns: + WebElement: A list of all matching WebElements, or an empty list if nothing matches + """ return self.driver.find_elements(by, value) def current_url(self): - return self.driver.current_url \ No newline at end of file + """ + Get a string representing the current URL that the browser is looking at. + + Returns: + The URL of the page currently loaded in the browser + """ + return self.driver.current_url diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index a43a0f24..3e9d895b 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -1,21 +1,11 @@ -""" -smoke_test.py is a test script to verify `scubagoggles gws` output. - -It checks for the following cases: -- Generate the correct output files (BaselineReports.html, ScubaResults.json, etc) -- Check the content of html files, verify href attributes are correct, etc -- Check if ScubaResults.json contains errors in the summary. If errors exist, then - either API calls or functions produced exceptions which need to be handled -""" - -import pytest import subprocess import os +import pytest from smoke_test_utils import ( - get_output_path, - prepend_file_protocol, + get_output_path, + prepend_file_protocol, get_required_entries, - verify_all_outputs_exist, + verify_all_outputs_exist, verify_output_type, run_selenium, verify_scubaresults, @@ -26,27 +16,49 @@ BASELINE_REPORTS = "BaselineReports.html" class SmokeTest: + """ + Pytest class to encapsulate the following test cases: + + - Generate the correct output files (BaselineReports.html, ScubaResults.json, etc) + - Check the content of html files, verify href attributes are correct, etc + - Check if ScubaResults.json contains errors in the summary. If errors exist, then + either API calls or functions produced exceptions which need to be handled + """ + def test_scubagoggles_output(self, subjectemail): + """ + Test if the `scubagoggles gws` command generates correct output for all baselines. + + Args: + subjectemail: The email address of a user for the service account + """ try: command: str = f"scubagoggles gws --subjectemail {subjectemail} --quiet" - subprocess.run(command, shell=True) + subprocess.run(command, shell=True, check=True) output_path: str = get_output_path() output: list = verify_output_type(output_path, []) required_entries = get_required_entries(os.path.join(os.getcwd(), SAMPLE_REPORT), []) verify_all_outputs_exist(output, required_entries) except (OSError, ValueError, Exception) as e: pytest.fail(f"An error occurred, {e}") - + def test_scubaresults(self): + """ + Determine if ScubaResults.json contains API errors or exceptions. + """ try: output_path: str = get_output_path() scubaresults_path: str = os.path.join(output_path, SCUBA_RESULTS) - with open(scubaresults_path) as jsonfile: + with open(scubaresults_path, encoding="utf-8") as jsonfile: verify_scubaresults(jsonfile) except (ValueError, Exception) as e: pytest.fail(f"An error occurred, {e}") def test_scubagoggles_report(self, browser, domain): + """ + Test if the generated baseline reports are correct, + i.e. BaselineReports.html, CalendarReport.html, ChatReport.html + """ try: output_path: str = get_output_path() report_path: str = prepend_file_protocol(os.path.join(output_path, BASELINE_REPORTS)) @@ -54,4 +66,4 @@ def test_scubagoggles_report(self, browser, domain): run_selenium(browser, domain) except (ValueError, Exception) as e: browser.quit() - pytest.fail(f"An error occurred, {e}") \ No newline at end of file + pytest.fail(f"An error occurred, {e}") diff --git a/Testing/Functional/SmokeTests/smoke_test_utils.py b/Testing/Functional/SmokeTests/smoke_test_utils.py index 222f7dba..9755859d 100644 --- a/Testing/Functional/SmokeTests/smoke_test_utils.py +++ b/Testing/Functional/SmokeTests/smoke_test_utils.py @@ -40,7 +40,7 @@ def verify_output_type(output_path: str, output: list) -> list: # Check for valid json if child_path.endswith(".json"): try: - with open(child_path) as jsonfile: + with open(child_path, encoding="utf-8") as jsonfile: json.load(jsonfile) except ValueError as e: raise ValueError(f"{child_path} contains invalid json, {e}") From b268e26862ca6cd4657b6dfd4de1ab589500401a Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Mon, 5 Aug 2024 20:29:55 +0000 Subject: [PATCH 121/126] addressing more of pylint warnings --- .../Functional/SmokeTests/selenium_browser.py | 4 ++++ Testing/Functional/SmokeTests/smoke_test.py | 4 ++++ .../Functional/SmokeTests/smoke_test_utils.py | 22 ++++++++++++++----- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/Testing/Functional/SmokeTests/selenium_browser.py b/Testing/Functional/SmokeTests/selenium_browser.py index 821e225c..c43744d7 100644 --- a/Testing/Functional/SmokeTests/selenium_browser.py +++ b/Testing/Functional/SmokeTests/selenium_browser.py @@ -1,3 +1,7 @@ +""" + selenium_browser.py declares a Browser class for use in ScubaGoggles testing. +""" + from selenium import webdriver from selenium.webdriver.chrome.options import Options diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index 3e9d895b..eb76ef41 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -1,3 +1,7 @@ +""" + smoke_test.py declares a SmokeTest class for ScubaGoggles automation testing. +""" + import subprocess import os import pytest diff --git a/Testing/Functional/SmokeTests/smoke_test_utils.py b/Testing/Functional/SmokeTests/smoke_test_utils.py index 9755859d..58a5fad9 100644 --- a/Testing/Functional/SmokeTests/smoke_test_utils.py +++ b/Testing/Functional/SmokeTests/smoke_test_utils.py @@ -1,3 +1,7 @@ +""" + Helper methods for running the functional smoke tests. +""" + import pytest import os import json @@ -12,8 +16,16 @@ SCUBAGOGGLES_BASELINES_URL = "https://github.com/cisagov/ScubaGoggles/tree/main/baselines" def get_output_path() -> str: + """ + Get the latest output directory created by `scubagoggles gws`. + The default name is "GWSBaselineConformance_. + + Returns: + str: The path to the latest output directory + """ + directories: list = [ - d for d in os.listdir() + d for d in os.listdir() if os.path.isdir(d) and d.startswith(OUTPUT_DIRECTORY) ] directories.sort(key=lambda d: os.path.getctime(d), reverse=True) @@ -85,12 +97,12 @@ def run_selenium(browser, domain): reports_table = get_reports_table(browser) if len(reports_table) == 10: - for i in range(len(reports_table)): + for i in range(len(reports_table)): # Check if domain is present in agency table verify_tenant_table(browser, domain) - # TODO: + # TODO # Check for correct baseline and tool version, e.g. 0.2, 0.2.0 reports_table = get_reports_table(browser)[i] @@ -114,7 +126,7 @@ def run_selenium(browser, domain): policy_tables = browser.find_elements(By.TAG_NAME, "table") for table in policy_tables[1:]: - # Verify policy table headers are correct + # Verify policy table headers are correct headers = ( table.find_element(By.TAG_NAME, "thead") .find_elements(By.TAG_NAME, "tr")[0] @@ -173,4 +185,4 @@ def verify_tenant_table(browser, domain): ) assert len(tenant_table) == 2 customer_domain = tenant_table[1].find_elements(By.TAG_NAME, "td")[0].text - assert customer_domain == domain \ No newline at end of file + assert customer_domain == domain From e9add6b7ada7e2c8e9021e67e5a305aaa05406c5 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Mon, 5 Aug 2024 21:58:06 +0000 Subject: [PATCH 122/126] address some path issues with importing orchestrator methods --- .github/workflows/run_smoke_test.yml | 2 +- Testing/Functional/SmokeTests/smoke_test_utils.py | 9 +++++++-- Testing/Functional/conftest.py | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 7ce74d2d..39ec0c51 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -64,4 +64,4 @@ jobs: json: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }} - name: Run ScubaGoggles and check for correct output - run: pytest -s -vvv ./Testing/Functional/SmokeTests/ --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" --domain="${{ secrets.GWS_DOMAIN }}" + run: python -m pytest -s -vvv ./Testing/Functional/SmokeTests/ --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" --domain="${{ secrets.GWS_DOMAIN }}" diff --git a/Testing/Functional/SmokeTests/smoke_test_utils.py b/Testing/Functional/SmokeTests/smoke_test_utils.py index 58a5fad9..898c4639 100644 --- a/Testing/Functional/SmokeTests/smoke_test_utils.py +++ b/Testing/Functional/SmokeTests/smoke_test_utils.py @@ -5,7 +5,7 @@ import pytest import os import json -from scubagoggles.orchestrator import gws_products +from scubagoggles.orchestrator import Orchestrator from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions @@ -32,6 +32,10 @@ def get_output_path() -> str: return os.path.join(os.getcwd(), directories[0]) def prepend_file_protocol(path: str) -> str: + """ + + """ + if not path.startswith("file://"): path = "file://" + path return path @@ -88,9 +92,10 @@ def run_selenium(browser, domain): h1 = browser.find_element(By.TAG_NAME, "h1").text assert h1 == BASELINE_REPORT_H1 + gws_products = Orchestrator.gws_products() products = { product: { "title": f"{product} Baseline Report" } - for product in gws_products()["prod_to_fullname"].values() + for product in gws_products["prod_to_fullname"].values() } # Before entering loop check that we actually display 10 rows in table diff --git a/Testing/Functional/conftest.py b/Testing/Functional/conftest.py index b49a89fa..72982e2a 100644 --- a/Testing/Functional/conftest.py +++ b/Testing/Functional/conftest.py @@ -5,7 +5,7 @@ def pytest_addoption(parser): parser.addoption("--subjectemail", action="store") parser.addoption("--domain", action="store") -@pytest.fixture +@pytest.fixture def subjectemail(pytestconfig): return pytestconfig.getoption("subjectemail") From 808bf0d38daf42f8835d3897c74523c8ba056c53 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Mon, 5 Aug 2024 22:12:38 +0000 Subject: [PATCH 123/126] move pytest.ini to root --- .github/workflows/run_smoke_test.yml | 2 +- Testing/Functional/pytest.ini | 2 -- pytest.ini | 3 +++ 3 files changed, 4 insertions(+), 3 deletions(-) delete mode 100644 Testing/Functional/pytest.ini create mode 100644 pytest.ini diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index 39ec0c51..7ce74d2d 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -64,4 +64,4 @@ jobs: json: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }} - name: Run ScubaGoggles and check for correct output - run: python -m pytest -s -vvv ./Testing/Functional/SmokeTests/ --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" --domain="${{ secrets.GWS_DOMAIN }}" + run: pytest -s -vvv ./Testing/Functional/SmokeTests/ --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" --domain="${{ secrets.GWS_DOMAIN }}" diff --git a/Testing/Functional/pytest.ini b/Testing/Functional/pytest.ini deleted file mode 100644 index bbd61f63..00000000 --- a/Testing/Functional/pytest.ini +++ /dev/null @@ -1,2 +0,0 @@ -[pytest] -python_classes = *Test \ No newline at end of file diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 00000000..5947a673 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +python_classes = *Test +pythonpath = . scubagoggles \ No newline at end of file From 94e7cd1f767e7e28c830b94057ba20906360f046 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Mon, 5 Aug 2024 23:25:56 +0000 Subject: [PATCH 124/126] continue to address pylint errors, most should be resolved now --- .../setup-dependencies-macos/action.yml | 8 +- .../setup-dependencies-windows/action.yml | 8 +- .github/workflows/pylint.yml | 2 +- Testing/Functional/SmokeTests/smoke_test.py | 1 - .../Functional/SmokeTests/smoke_test_utils.py | 83 ++++++++++++++++--- Testing/Functional/conftest.py | 23 ++++- 6 files changed, 99 insertions(+), 26 deletions(-) diff --git a/.github/actions/setup-dependencies-macos/action.yml b/.github/actions/setup-dependencies-macos/action.yml index 9ae3b328..06eedebe 100644 --- a/.github/actions/setup-dependencies-macos/action.yml +++ b/.github/actions/setup-dependencies-macos/action.yml @@ -12,12 +12,6 @@ inputs: runs: using: "composite" steps: - - name: Install pytest and selenium - shell: bash - run: | - pip install pytest - pip install selenium - - name: Setup virtualenv shell: bash run: | @@ -30,6 +24,8 @@ runs: run: | python -m pip install . pip install -r requirements.txt + pip install pytest + pip install selenium pip uninstall -y numpy pip install numpy==1.26.4 diff --git a/.github/actions/setup-dependencies-windows/action.yml b/.github/actions/setup-dependencies-windows/action.yml index 319055e1..771ee2a8 100644 --- a/.github/actions/setup-dependencies-windows/action.yml +++ b/.github/actions/setup-dependencies-windows/action.yml @@ -12,12 +12,6 @@ inputs: runs: using: "composite" steps: - - name: Install pytest and selenium - shell: powershell - run: | - pip install pytest - pip install selenium - - name: Setup virtualenv shell: powershell run: | @@ -30,6 +24,8 @@ runs: run: | python -m pip install . pip install -r requirements.txt + pip install pytest + pip install selenium pip uninstall -y numpy pip install numpy==1.26.4 diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index b345351a..14ab44f0 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -31,7 +31,7 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.txt - pip install pylint + pip install pylint pytest selenium - name: Analysing the code with pylint run: | pylint -d R0913,R0914,R0915,R1702,W0718,W0719,R0801 $(git ls-files '*.py') diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index eb76ef41..ff058f9b 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -28,7 +28,6 @@ class SmokeTest: - Check if ScubaResults.json contains errors in the summary. If errors exist, then either API calls or functions produced exceptions which need to be handled """ - def test_scubagoggles_output(self, subjectemail): """ Test if the `scubagoggles gws` command generates correct output for all baselines. diff --git a/Testing/Functional/SmokeTests/smoke_test_utils.py b/Testing/Functional/SmokeTests/smoke_test_utils.py index 898c4639..bde5fe8b 100644 --- a/Testing/Functional/SmokeTests/smoke_test_utils.py +++ b/Testing/Functional/SmokeTests/smoke_test_utils.py @@ -2,13 +2,12 @@ Helper methods for running the functional smoke tests. """ -import pytest import os import json -from scubagoggles.orchestrator import Orchestrator from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions +from scubagoggles.orchestrator import Orchestrator OUTPUT_DIRECTORY = "GWSBaselineConformance" BASELINE_REPORT_H1 = "SCuBA GWS Security Baseline Conformance Reports" @@ -23,7 +22,6 @@ def get_output_path() -> str: Returns: str: The path to the latest output directory """ - directories: list = [ d for d in os.listdir() if os.path.isdir(d) and d.startswith(OUTPUT_DIRECTORY) @@ -33,14 +31,27 @@ def get_output_path() -> str: def prepend_file_protocol(path: str) -> str: """ + Prepends "file://", which is used to locate files on a local filesystem. + Returns: + str: Path to a file with the local filesystem prepended """ - if not path.startswith("file://"): path = "file://" + path return path def verify_output_type(output_path: str, output: list) -> list: + """ + Checks if the output generated from `scubagoggles` creates the correct output. + Validate files/directories and catch invalid json. + + Args: + output_path: The output path, i.e. "GWSBaselineConformance_" + output: Initialized as an empty list + + Returns: + list: All output file and directory names + """ entries: list = os.listdir(output_path) for entry in entries: output.append(entry) @@ -59,14 +70,26 @@ def verify_output_type(output_path: str, output: list) -> list: with open(child_path, encoding="utf-8") as jsonfile: json.load(jsonfile) except ValueError as e: - raise ValueError(f"{child_path} contains invalid json, {e}") + raise ValueError(f"{child_path} contains invalid json") from e assert True else: - raise OSError(f"Entry is not a directory or file (symlink, etc.)") + raise OSError("Entry is not a directory or file (symlink, etc.)") return output -def get_required_entries(directory, required_entries) -> list: - with os.scandir(directory) as entries: +def get_required_entries(sample_report, required_entries) -> list: + """ + From the "sample-report" directory, add all file and directory names + into a list "required_entries". All entries must be present + for smoke tests to pass. + + Args: + sample_report: Path where "sample-report" is located in the project + required_entries: Initialized as an empty list + + Returns: + list: All required file and directory names + """ + with os.scandir(sample_report) as entries: for entry in entries: required_entries.append(entry.name) if entry.is_dir(): @@ -74,6 +97,13 @@ def get_required_entries(directory, required_entries) -> list: return required_entries def verify_all_outputs_exist(output: list, required_entries: list): + """ + Verify all files and directories are created after running `scubagoggles gws`. + + Args: + output: a list of all files and directories generated by `scubagoggles gws` + required_entries: a list of all required file and directory names + """ for required_entry in required_entries: if required_entry in output: assert True @@ -81,6 +111,13 @@ def verify_all_outputs_exist(output: list, required_entries: list): raise ValueError(f"{required_entry} was not found in the generated report") def verify_scubaresults(jsonfile): + """ + Verify "ScubaResults.json" is valid, and check if any errors + are displayed in the reports. + + Args: + jsonfile: Path to a json file + """ scubaresults = json.load(jsonfile) summaries = scubaresults["Summary"] for product, summary in summaries.items(): @@ -88,6 +125,13 @@ def verify_scubaresults(jsonfile): raise ValueError(f"{product} contains errors in the report") def run_selenium(browser, domain): + """ + Run Selenium tests against the generated reports. + + Args: + browser: A Selenium WebDriver instance + domain: The user's domain + """ verify_navigation_links(browser) h1 = browser.find_element(By.TAG_NAME, "h1").text assert h1 == BASELINE_REPORT_H1 @@ -139,10 +183,10 @@ def run_selenium(browser, domain): ) assert len(headers) == 5 assert headers[0].text == "Control ID" - assert headers[1].text == "Requirement" or "Rule Name" + assert headers[1].text in { "Requirement", "Rule Name" } assert headers[2].text == "Result" assert headers[3].text == "Criticality" - assert headers[4].text == "Details" or "Rule Description" + assert headers[4].text == { "Details", "Rule Description" } # Verify policy table rows are populated tbody = table.find_element(By.TAG_NAME, "tbody") @@ -164,9 +208,15 @@ def run_selenium(browser, domain): ) ) else: - raise ValueError(f"Expected the reports table to have a length of 10") + raise ValueError("Expected the reports table to have a length of 10") def verify_navigation_links(browser): + """ + For each baseline report, check that the navigation links display correctly. + + Args: + browser: A Selenium WebDriver instance + """ links = ( browser.find_element(By.CLASS_NAME, "links") .find_elements(By.TAG_NAME, "a") @@ -176,6 +226,13 @@ def verify_navigation_links(browser): assert links[1].get_attribute("href") == SCUBAGOGGLES_BASELINES_URL def get_reports_table(browser): + """ + Get the reports table element from the DOM. + (Table in BaselineReports.html with list of baselines and pass/fail/warning of each) + + Args: + browser: A Selenium WebDriver instance + """ return ( browser.find_elements(By.TAG_NAME, "table")[1] .find_element(By.TAG_NAME, "tbody") @@ -183,6 +240,10 @@ def get_reports_table(browser): ) def verify_tenant_table(browser, domain): + """ + Get the tenant table element from the DOM. + (Table at the top of each report with user domain, baseline/tool version) + """ tenant_table = ( browser.find_element(By.TAG_NAME, "table") .find_element(By.TAG_NAME, "tbody") diff --git a/Testing/Functional/conftest.py b/Testing/Functional/conftest.py index 72982e2a..9c3febbe 100644 --- a/Testing/Functional/conftest.py +++ b/Testing/Functional/conftest.py @@ -2,19 +2,40 @@ from SmokeTests.selenium_browser import Browser def pytest_addoption(parser): + """ + Add custom cli arguments when running `pytest`. + + Args: + parser: An instance of "argparse.ArgumentParser" + """ parser.addoption("--subjectemail", action="store") parser.addoption("--domain", action="store") @pytest.fixture def subjectemail(pytestconfig): + """ + Setup code that shares the "subjectemail" parameter across tests. + + Args: + pytestconfig: Provides access to the "Config" object for a current test session + """ return pytestconfig.getoption("subjectemail") @pytest.fixture def domain(pytestconfig): + """ + Setup code that shares the "domain" parameter across tests. + + Args: + pytestconfig: Provides access to the "Config" object for a current test session + """ return pytestconfig.getoption("domain") @pytest.fixture def browser(): + """ + Setup code that shares a Selenium WebDriver instance across tests. + """ browser_instance = Browser() yield browser_instance - browser_instance.quit() \ No newline at end of file + browser_instance.quit() From ed24be495c3e0d564b663615da16f3ef4697b51e Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Tue, 6 Aug 2024 00:15:11 +0000 Subject: [PATCH 125/126] address final pylinter errors, add get_package_version() method in orchestrator/utils --- .../Functional/SmokeTests/selenium_browser.py | 3 +- Testing/Functional/SmokeTests/smoke_test.py | 18 +-- .../Functional/SmokeTests/smoke_test_utils.py | 126 ++++++++++-------- Testing/Functional/conftest.py | 4 + scubagoggles/utils.py | 11 ++ 5 files changed, 95 insertions(+), 67 deletions(-) diff --git a/Testing/Functional/SmokeTests/selenium_browser.py b/Testing/Functional/SmokeTests/selenium_browser.py index c43744d7..69bf9d9d 100644 --- a/Testing/Functional/SmokeTests/selenium_browser.py +++ b/Testing/Functional/SmokeTests/selenium_browser.py @@ -1,5 +1,5 @@ """ - selenium_browser.py declares a Browser class for use in ScubaGoggles testing. +selenium_browser.py declares a Browser class for use in ScubaGoggles testing. """ from selenium import webdriver @@ -10,7 +10,6 @@ class Browser: The Browser class encapsulates the setup, usage, and teardown of a Selenium WebDriver instance for automated browser interactions. """ - def __init__(self): chrome_options = Options() chrome_options.add_argument("--headless") diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index ff058f9b..8c9c6839 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -1,5 +1,5 @@ """ - smoke_test.py declares a SmokeTest class for ScubaGoggles automation testing. +smoke_test.py declares a SmokeTest class for ScubaGoggles automation testing. """ import subprocess @@ -30,10 +30,10 @@ class SmokeTest: """ def test_scubagoggles_output(self, subjectemail): """ - Test if the `scubagoggles gws` command generates correct output for all baselines. - - Args: - subjectemail: The email address of a user for the service account + Test if the `scubagoggles gws` command generates correct output for all baselines. + + Args: + subjectemail: The email address of a user for the service account """ try: command: str = f"scubagoggles gws --subjectemail {subjectemail} --quiet" @@ -47,7 +47,7 @@ def test_scubagoggles_output(self, subjectemail): def test_scubaresults(self): """ - Determine if ScubaResults.json contains API errors or exceptions. + Determine if ScubaResults.json contains API errors or exceptions. """ try: output_path: str = get_output_path() @@ -59,14 +59,14 @@ def test_scubaresults(self): def test_scubagoggles_report(self, browser, domain): """ - Test if the generated baseline reports are correct, - i.e. BaselineReports.html, CalendarReport.html, ChatReport.html + Test if the generated baseline reports are correct, + i.e. BaselineReports.html, CalendarReport.html, ChatReport.html """ try: output_path: str = get_output_path() report_path: str = prepend_file_protocol(os.path.join(output_path, BASELINE_REPORTS)) browser.get(report_path) run_selenium(browser, domain) - except (ValueError, Exception) as e: + except (ValueError, AssertionError, Exception) as e: browser.quit() pytest.fail(f"An error occurred, {e}") diff --git a/Testing/Functional/SmokeTests/smoke_test_utils.py b/Testing/Functional/SmokeTests/smoke_test_utils.py index bde5fe8b..7073750c 100644 --- a/Testing/Functional/SmokeTests/smoke_test_utils.py +++ b/Testing/Functional/SmokeTests/smoke_test_utils.py @@ -1,5 +1,5 @@ """ - Helper methods for running the functional smoke tests. +Helper methods for running the functional smoke tests. """ import os @@ -8,6 +8,7 @@ from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions from scubagoggles.orchestrator import Orchestrator +from scubagoggles.utils import get_package_version OUTPUT_DIRECTORY = "GWSBaselineConformance" BASELINE_REPORT_H1 = "SCuBA GWS Security Baseline Conformance Reports" @@ -16,25 +17,25 @@ def get_output_path() -> str: """ - Get the latest output directory created by `scubagoggles gws`. - The default name is "GWSBaselineConformance_. + Get the latest output directory created by `scubagoggles gws`. + The default name is "GWSBaselineConformance_. - Returns: - str: The path to the latest output directory + Returns: + str: The path to the latest output directory """ directories: list = [ d for d in os.listdir() if os.path.isdir(d) and d.startswith(OUTPUT_DIRECTORY) ] - directories.sort(key=lambda d: os.path.getctime(d), reverse=True) + directories.sort(key=os.path.getctime, reverse=True) return os.path.join(os.getcwd(), directories[0]) def prepend_file_protocol(path: str) -> str: """ - Prepends "file://", which is used to locate files on a local filesystem. + Prepends "file://", which is used to locate files on a local filesystem. - Returns: - str: Path to a file with the local filesystem prepended + Returns: + str: Path to a file with the local filesystem prepended """ if not path.startswith("file://"): path = "file://" + path @@ -42,15 +43,15 @@ def prepend_file_protocol(path: str) -> str: def verify_output_type(output_path: str, output: list) -> list: """ - Checks if the output generated from `scubagoggles` creates the correct output. - Validate files/directories and catch invalid json. + Checks if the output generated from `scubagoggles` creates the correct output. + Validate files/directories and catch invalid json. - Args: - output_path: The output path, i.e. "GWSBaselineConformance_" - output: Initialized as an empty list + Args: + output_path: The output path, i.e. "GWSBaselineConformance_" + output: Initialized as an empty list - Returns: - list: All output file and directory names + Returns: + list: All output file and directory names """ entries: list = os.listdir(output_path) for entry in entries: @@ -78,16 +79,16 @@ def verify_output_type(output_path: str, output: list) -> list: def get_required_entries(sample_report, required_entries) -> list: """ - From the "sample-report" directory, add all file and directory names - into a list "required_entries". All entries must be present - for smoke tests to pass. + From the "sample-report" directory, add all file and directory names + into a list "required_entries". All entries must be present + for smoke tests to pass. - Args: - sample_report: Path where "sample-report" is located in the project - required_entries: Initialized as an empty list + Args: + sample_report: Path where "sample-report" is located in the project + required_entries: Initialized as an empty list - Returns: - list: All required file and directory names + Returns: + list: All required file and directory names """ with os.scandir(sample_report) as entries: for entry in entries: @@ -98,11 +99,11 @@ def get_required_entries(sample_report, required_entries) -> list: def verify_all_outputs_exist(output: list, required_entries: list): """ - Verify all files and directories are created after running `scubagoggles gws`. + Verify all files and directories are created after running `scubagoggles gws`. - Args: - output: a list of all files and directories generated by `scubagoggles gws` - required_entries: a list of all required file and directory names + Args: + output: a list of all files and directories generated by `scubagoggles gws` + required_entries: a list of all required file and directory names """ for required_entry in required_entries: if required_entry in output: @@ -112,11 +113,11 @@ def verify_all_outputs_exist(output: list, required_entries: list): def verify_scubaresults(jsonfile): """ - Verify "ScubaResults.json" is valid, and check if any errors - are displayed in the reports. + Verify "ScubaResults.json" is valid, and check if any errors + are displayed in the reports. - Args: - jsonfile: Path to a json file + Args: + jsonfile: Path to a json file """ scubaresults = json.load(jsonfile) summaries = scubaresults["Summary"] @@ -126,11 +127,11 @@ def verify_scubaresults(jsonfile): def run_selenium(browser, domain): """ - Run Selenium tests against the generated reports. + Run Selenium tests against the generated reports. - Args: - browser: A Selenium WebDriver instance - domain: The user's domain + Args: + browser: A Selenium WebDriver instance + domain: The user's domain """ verify_navigation_links(browser) h1 = browser.find_element(By.TAG_NAME, "h1").text @@ -149,10 +150,8 @@ def run_selenium(browser, domain): for i in range(len(reports_table)): # Check if domain is present in agency table - verify_tenant_table(browser, domain) - - # TODO - # Check for correct baseline and tool version, e.g. 0.2, 0.2.0 + # Skip tool version if assessing the parent report + verify_tenant_table(browser, domain, True) reports_table = get_reports_table(browser)[i] baseline_report = reports_table.find_elements(By.TAG_NAME, "td")[0] @@ -170,7 +169,8 @@ def run_selenium(browser, domain): h1 = browser.find_element(By.TAG_NAME, "h1").text assert h1 == products[product]["title"] - verify_tenant_table(browser, domain) + # Check if domain and tool version are present in individual report + verify_tenant_table(browser, domain, False) policy_tables = browser.find_elements(By.TAG_NAME, "table") for table in policy_tables[1:]: @@ -183,10 +183,10 @@ def run_selenium(browser, domain): ) assert len(headers) == 5 assert headers[0].text == "Control ID" - assert headers[1].text in { "Requirement", "Rule Name" } + assert headers[1].text in "Requirements" or headers[1].text in "Rule Name" assert headers[2].text == "Result" assert headers[3].text == "Criticality" - assert headers[4].text == { "Details", "Rule Description" } + assert headers[4].text in "Details" or headers[4].text in "Rule Description" # Verify policy table rows are populated tbody = table.find_element(By.TAG_NAME, "tbody") @@ -212,10 +212,10 @@ def run_selenium(browser, domain): def verify_navigation_links(browser): """ - For each baseline report, check that the navigation links display correctly. + For each baseline report, check that the navigation links display correctly. - Args: - browser: A Selenium WebDriver instance + Args: + browser: A Selenium WebDriver instance """ links = ( browser.find_element(By.CLASS_NAME, "links") @@ -227,11 +227,11 @@ def verify_navigation_links(browser): def get_reports_table(browser): """ - Get the reports table element from the DOM. - (Table in BaselineReports.html with list of baselines and pass/fail/warning of each) + Get the reports table element from the DOM. + (Table in BaselineReports.html with list of baselines and pass/fail/warning of each) - Args: - browser: A Selenium WebDriver instance + Args: + browser: A Selenium WebDriver instance """ return ( browser.find_elements(By.TAG_NAME, "table")[1] @@ -239,16 +239,30 @@ def get_reports_table(browser): .find_elements(By.TAG_NAME, "tr") ) -def verify_tenant_table(browser, domain): +def verify_tenant_table(browser, domain, parent): """ - Get the tenant table element from the DOM. - (Table at the top of each report with user domain, baseline/tool version) + Get the tenant table rows elements from the DOM. + (Table at the top of each report with user domain, baseline/tool version) + + Args: + browser: A Selenium WebDriver instance + domain: The user's domain + parent: boolean to determine parent/individual reports """ - tenant_table = ( + tenant_table_rows = ( browser.find_element(By.TAG_NAME, "table") .find_element(By.TAG_NAME, "tbody") .find_elements(By.TAG_NAME, "tr") ) - assert len(tenant_table) == 2 - customer_domain = tenant_table[1].find_elements(By.TAG_NAME, "td")[0].text + assert len(tenant_table_rows) == 2 + customer_domain = tenant_table_rows[1].find_elements(By.TAG_NAME, "td")[0].text assert customer_domain == domain + + if not parent: + # Check for correct tool version, e.g. 0.2.0 + version = get_package_version("scubagoggles") + tool_version = tenant_table_rows[1].find_elements(By.TAG_NAME, "td")[3].text + assert version == tool_version + + # Baseline version should also be checked in this method + # Add as an additional todo diff --git a/Testing/Functional/conftest.py b/Testing/Functional/conftest.py index 9c3febbe..456f9be3 100644 --- a/Testing/Functional/conftest.py +++ b/Testing/Functional/conftest.py @@ -1,3 +1,7 @@ +""" + conftest.py serves as a configuration file for pytest. +""" + import pytest from SmokeTests.selenium_browser import Browser diff --git a/scubagoggles/utils.py b/scubagoggles/utils.py index 41b70501..2e59f8df 100644 --- a/scubagoggles/utils.py +++ b/scubagoggles/utils.py @@ -4,6 +4,7 @@ """ from pathlib import Path +from importlib.metadata import version, PackageNotFoundError def create_subset_inverted_dict(dictionary: dict, keys: list) -> dict: """ @@ -53,3 +54,13 @@ def rel_abs_path(file_path: str, rel_path) -> str: """ current_dir = Path(file_path).resolve().parent return (current_dir / rel_path).resolve() + +def get_package_version(package: str) -> str: + """ + Get the current version for a package + """ + try: + package_version = version(package) + return package_version + except PackageNotFoundError as e: + raise PackageNotFoundError(f"Package was not found, {e}") From a3c7cf50c923671f137fc1100ddffeace6b74523 Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Tue, 6 Aug 2024 00:17:41 +0000 Subject: [PATCH 126/126] address last pylinter error --- scubagoggles/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scubagoggles/utils.py b/scubagoggles/utils.py index 2e59f8df..ae45a454 100644 --- a/scubagoggles/utils.py +++ b/scubagoggles/utils.py @@ -63,4 +63,4 @@ def get_package_version(package: str) -> str: package_version = version(package) return package_version except PackageNotFoundError as e: - raise PackageNotFoundError(f"Package was not found, {e}") + raise PackageNotFoundError("Package was not found") from e