diff --git a/.github/workflows/sanity_test.yml b/.github/workflows/sanity_test.yml deleted file mode 100644 index 8cefe9f0..00000000 --- a/.github/workflows/sanity_test.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Example CI - -on: - push: {} - pull_request: - branches: [main] - -jobs: - build: - runs-on: self-hosted - - steps: - - uses: actions/checkout@v2 - - - name: Run a script - run: echo Hello, world! diff --git a/.github/workflows/unittest_ci.yml b/.github/workflows/unittest_ci.yml new file mode 100644 index 00000000..0c088c98 --- /dev/null +++ b/.github/workflows/unittest_ci.yml @@ -0,0 +1,35 @@ +name: Unit Tests + +on: + push: {} + pull_request: + branches: [main] + +jobs: + build: + runs-on: self-hosted + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + # We could choose to set up dependencies manually in the GHA runner instead of installing them during the GHA. + # + # However, I think it's better to do them in the GHA itself so that we're testing our dependency installation step + # in addition to our actual code. It also removes the need to manually reinstall dependencies on the GHA runners + # every time we add a new dependency. + # + # Note that the GHA runners are stateful. Dependencies installed from previous runs will still be on the runner. + # This means this step will usually be pretty fast as most dependencies will already be cached. However, it also + # means that past runs might interfere with the current run, so you sometimes may need to restart the GHA runners. + - name: Install dependencies + run: | + ./dependencies/install_dependencies.sh + . "$HOME/.cargo/env" + + - name: Run unit tests + run: python scripts/run_unittests.py diff --git a/dependencies/install_dependencies.sh b/dependencies/install_dependencies.sh index 8a516880..da6c7bad 100755 --- a/dependencies/install_dependencies.sh +++ b/dependencies/install_dependencies.sh @@ -1,5 +1,5 @@ #!/bin/bash # You may want to create a conda environment before doing this -pip install -r dependency/requirements.txt -cat dependency/apt_requirements.txt | xargs sudo apt-get install -y -curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh \ No newline at end of file +pip install -r dependencies/requirements.txt +cat dependencies/apt_requirements.txt | xargs sudo apt-get install -y +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \ No newline at end of file diff --git a/dependencies/rust.sh b/dependencies/rust.sh deleted file mode 100755 index 9af316fc..00000000 --- a/dependencies/rust.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh \ No newline at end of file diff --git a/scripts/run_unittests.py b/scripts/run_unittests.py index bbd74cb5..56aadd28 100644 --- a/scripts/run_unittests.py +++ b/scripts/run_unittests.py @@ -1,8 +1,11 @@ import unittest +import sys if __name__ == "__main__": loader = unittest.TestLoader() suite = loader.discover(".") - print(f"suite={suite}") runner = unittest.TextTestRunner() - runner.run(suite) + result = runner.run(suite) + if not result.wasSuccessful(): + # This is needed so that the GHA fails if the unit tests fail. + sys.exit(1) diff --git a/tune/protox/env/workload.py b/tune/protox/env/workload.py index 2b3c7e8c..5d646f54 100644 --- a/tune/protox/env/workload.py +++ b/tune/protox/env/workload.py @@ -223,7 +223,6 @@ def __init__( workload_timeout_penalty: float = 1.0, logger: Optional[Logger] = None, ) -> None: - self.dbgym_cfg = dbgym_cfg self.workload_path = workload_path # Whether we should use benchbase or not. @@ -257,7 +256,7 @@ def __init__( sqls = [ ( line.split(",")[0], - Path(line.split(",")[1]), + self.workload_path / Path(line.split(",")[1]), 1.0, ) for line in lines @@ -271,7 +270,7 @@ def __init__( sqls = [ ( split[0], - Path(split[1]), + self.workload_path / Path(split[1]), float(split[2]), ) for split in splits diff --git a/tune/protox/tests/test_index_space.py b/tune/protox/tests/test_index_space.py index 6e583b36..73d72c5c 100644 --- a/tune/protox/tests/test_index_space.py +++ b/tune/protox/tests/test_index_space.py @@ -11,7 +11,7 @@ class IndexSpaceTests(unittest.TestCase): @staticmethod def load( - config_path=Path("tune/protox/tests/unittest_benchmark_configs/unittest_tpch.yaml"), + config_path=Path("tune/protox/tests/unittest_benchmark_configs/unittest_tpch.yaml").resolve(), aux_type=True, aux_include=True, ): @@ -27,7 +27,7 @@ def load( tables=benchmark_config["tables"], attributes=benchmark_config["attributes"], query_spec=benchmark_config["query_spec"], - workload_path=Path("tune/protox/tests/unittest_tpch_dir"), + workload_path=Path("tune/protox/tests/unittest_tpch_dir").resolve(), pid=None, workload_timeout=0, workload_timeout_penalty=1.0, diff --git a/tune/protox/tests/test_primitive.py b/tune/protox/tests/test_primitive.py index 9469ffea..f9c2bd29 100644 --- a/tune/protox/tests/test_primitive.py +++ b/tune/protox/tests/test_primitive.py @@ -98,7 +98,7 @@ def test_ia(self): IndexAction.index_counter = 0 self.assertEqual( ia1.sql(add=True), - "CREATE INDEX index1 ON tbl USING btree (a,b,c) INCLUDE (d,e)", + "CREATE INDEX index0 ON tbl USING btree (a,b,c) INCLUDE (d,e)", ) ia2 = IndexAction( diff --git a/tune/protox/tests/test_workload.py b/tune/protox/tests/test_workload.py index ac4a0223..f31ac71b 100644 --- a/tune/protox/tests/test_workload.py +++ b/tune/protox/tests/test_workload.py @@ -56,7 +56,7 @@ def test_tpch(self): for k, v in ref.items() } - w, i = WorkloadTests.load("tune/protox/tests/unittest_benchmark_configs/unittest_tpch.yaml", Path("tune/protox/tests/unittest_tpch_dir")) + w, i = WorkloadTests.load("tune/protox/tests/unittest_benchmark_configs/unittest_tpch.yaml", Path("tune/protox/tests/unittest_tpch_dir").resolve()) self.assertEqual(i.class_mapping, ref) def test_job(self): @@ -68,7 +68,7 @@ def test_job(self): for k, v in ref.items() } - w, i = WorkloadTests.load("tune/protox/tests/unittest_benchmark_configs/unittest_job_full.yaml", Path("tune/protox/tests/unittest_job_full_dir")) + w, i = WorkloadTests.load("tune/protox/tests/unittest_benchmark_configs/unittest_job_full.yaml", Path("tune/protox/tests/unittest_job_full_dir").resolve()) self.assertEqual(i.class_mapping, ref) def test_dsb(self): @@ -80,7 +80,7 @@ def test_dsb(self): for k, v in ref.items() } - w, i = WorkloadTests.load("tune/protox/tests/unittest_benchmark_configs/unittest_dsb.yaml", Path("tune/protox/tests/unittest_dsb_dir")) + w, i = WorkloadTests.load("tune/protox/tests/unittest_benchmark_configs/unittest_dsb.yaml", Path("tune/protox/tests/unittest_dsb_dir").resolve()) self.diff_classmapping(ref, i.class_mapping) def test_tpcc(self): @@ -92,5 +92,5 @@ def test_tpcc(self): for k, v in ref.items() } - w, i = WorkloadTests.load("tune/protox/tests/unittest_benchmark_configs/unittest_tpcc.yaml", Path("tune/protox/tests/unittest_tpcc_dir")) + w, i = WorkloadTests.load("tune/protox/tests/unittest_benchmark_configs/unittest_tpcc.yaml", Path("tune/protox/tests/unittest_tpcc_dir").resolve()) self.assertEqual(i.class_mapping, ref)