From e0dc3eee7f1a3b4cb95bb8d2b88ba1c623de9f4f Mon Sep 17 00:00:00 2001 From: Arturo Mendoza Date: Sat, 1 Feb 2025 00:21:13 +0100 Subject: [PATCH 01/10] Add slurm github action --- .github/workflows/slurm-tests.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/slurm-tests.yml diff --git a/.github/workflows/slurm-tests.yml b/.github/workflows/slurm-tests.yml new file mode 100644 index 0000000..f2155d6 --- /dev/null +++ b/.github/workflows/slurm-tests.yml @@ -0,0 +1,31 @@ +name: Run tests on SLURM +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + testing: + runs-on: ubuntu-latest + # For the action to work, you have to supply a mysql + # service as defined below. + services: + mysql: + image: mysql:8.0 + env: + MYSQL_ROOT_PASSWORD: root + ports: + - "8888:3306" + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + steps: + - uses: actions/checkout@v3 + + - uses: koesterlab/setup-slurm-action@v1 + + # Afterwards, you can submit to the slurm cluster via sbatch and srun, + # and interact via all other usual commands. + - run: | + sinfo \ No newline at end of file From 96d141fb76fa053969fd34708c779c8e365b122c Mon Sep 17 00:00:00 2001 From: Arturo Mendoza Date: Sat, 1 Feb 2025 00:32:58 +0100 Subject: [PATCH 02/10] Add tests into SLURM --- .github/workflows/slurm-tests.yml | 62 ++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/.github/workflows/slurm-tests.yml b/.github/workflows/slurm-tests.yml index f2155d6..c4af3f4 100644 --- a/.github/workflows/slurm-tests.yml +++ b/.github/workflows/slurm-tests.yml @@ -1,4 +1,5 @@ -name: Run tests on SLURM +name: Run Tests Inside SLURM + on: push: branches: @@ -8,24 +9,41 @@ on: - master jobs: - testing: - runs-on: ubuntu-latest - # For the action to work, you have to supply a mysql - # service as defined below. - services: - mysql: - image: mysql:8.0 - env: - MYSQL_ROOT_PASSWORD: root - ports: - - "8888:3306" - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 - steps: - - uses: actions/checkout@v3 - - - uses: koesterlab/setup-slurm-action@v1 - - # Afterwards, you can submit to the slurm cluster via sbatch and srun, - # and interact via all other usual commands. - - run: | - sinfo \ No newline at end of file + testing: + runs-on: ubuntu-latest + services: + mysql: + image: mysql:8.0 + env: + MYSQL_ROOT_PASSWORD: root + ports: + - "8888:3306" + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up SLURM + uses: koesterlab/setup-slurm-action@v1 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + + - name: Copy files to SLURM node + run: | + mkdir -p /slurm_workspace + rsync -av --progress . /slurm_workspace/ + ls -lah /slurm_workspace # Debugging step to check file transfer + + - name: Run tests inside SLURM + run: | + cd /slurm_workspace + sbatch --wrap="python -m unittest -v" From e50478456702fb464bc1fbe30b4b6f3c9af29b5a Mon Sep 17 00:00:00 2001 From: Arturo Mendoza Date: Sat, 1 Feb 2025 00:40:01 +0100 Subject: [PATCH 03/10] Change location --- .github/workflows/slurm-tests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/slurm-tests.yml b/.github/workflows/slurm-tests.yml index c4af3f4..3cc0123 100644 --- a/.github/workflows/slurm-tests.yml +++ b/.github/workflows/slurm-tests.yml @@ -39,11 +39,11 @@ jobs: - name: Copy files to SLURM node run: | - mkdir -p /slurm_workspace - rsync -av --progress . /slurm_workspace/ - ls -lah /slurm_workspace # Debugging step to check file transfer + mkdir -p $HOME/slurm_workspace + rsync -av --progress . $HOME/slurm_workspace/ + ls -lah $HOME/slurm_workspace # Debugging step - name: Run tests inside SLURM run: | - cd /slurm_workspace + cd $HOME/slurm_workspace sbatch --wrap="python -m unittest -v" From 1c01cff1092e57c2dd428b9df2bd0c20c0178ed3 Mon Sep 17 00:00:00 2001 From: Arturo Mendoza Date: Sat, 1 Feb 2025 00:44:05 +0100 Subject: [PATCH 04/10] Update testing --- .github/workflows/slurm-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/slurm-tests.yml b/.github/workflows/slurm-tests.yml index 3cc0123..06a52bb 100644 --- a/.github/workflows/slurm-tests.yml +++ b/.github/workflows/slurm-tests.yml @@ -43,7 +43,7 @@ jobs: rsync -av --progress . $HOME/slurm_workspace/ ls -lah $HOME/slurm_workspace # Debugging step - - name: Run tests inside SLURM + - name: Run tests with unittest run: | cd $HOME/slurm_workspace - sbatch --wrap="python -m unittest -v" + python -m unittest -v From db1b10814a11fa55a649d940a9af130c735f14ab Mon Sep 17 00:00:00 2001 From: Arturo Mendoza Date: Sat, 1 Feb 2025 01:26:21 +0100 Subject: [PATCH 05/10] avoid using unittest.mock --- test/test_cli.py | 47 ++++++-------------- test/test_core.py | 109 +++++++++++----------------------------------- 2 files changed, 39 insertions(+), 117 deletions(-) diff --git a/test/test_cli.py b/test/test_cli.py index 5d6e728..14ec9e9 100644 --- a/test/test_cli.py +++ b/test/test_cli.py @@ -55,11 +55,21 @@ def test_03_using_equal_and_spaces(self): ) def __run_test(self, args): - stdout = run_cli(args) - script, job_id = parse_stdout(stdout) + + with io.StringIO() as buffer: + with contextlib.redirect_stdout(buffer): + with patch.object(sys, "argv", args): + cli() + stdout = buffer.getvalue() + + *script, _, job_msg = stdout.strip().split("\n") + script = "\n".join(script).strip() + job_id = int(job_msg.replace("Submitted batch job ", "")) out_file = f"slurm-{job_id}.out" - while True: # wait for job to finalize + + # wait for job to finalize + while True: if os.path.isfile(out_file): break with open(out_file, "r") as fid: @@ -71,36 +81,5 @@ def __run_test(self, args): self.assertIn(f"Submitted batch job {job_id}", stdout) -def run_cli(testargs): - with io.StringIO() as buffer: - with contextlib.redirect_stdout(buffer): - with patch.object(sys, "argv", testargs): - if shutil.which("sbatch") is not None: - cli() - else: - with patch("subprocess.run", subprocess_sbatch): - cli() - stdout = buffer.getvalue() - return stdout - - -def subprocess_sbatch(*args, **kwargs): - job_id = 1234 - out_file = f"slurm-{job_id}.out" - with open(out_file, "w") as fid: - fid.write("Hello!!!\n") - stdout = f"Submitted batch job {job_id}" - return subprocess.CompletedProcess( - *args, returncode=1, stdout=stdout.encode("utf-8") - ) - - -def parse_stdout(stdout): - *script, _, job_msg = stdout.strip().split("\n") - script = "\n".join(script).strip() - job_id = int(job_msg.replace("Submitted batch job ", "")) - return script, job_id - - if __name__ == "__main__": unittest.main() diff --git a/test/test_core.py b/test/test_core.py index eb81e24..b80ab6e 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5,7 +5,6 @@ import shutil import subprocess import unittest -from unittest.mock import patch from simple_slurm import Slurm @@ -209,35 +208,17 @@ def test_13_output_env_vars(self): def test_14_srun_returncode(self): slurm = Slurm(contiguous=True) - if shutil.which("srun") is not None: - code = slurm.srun("echo Hello!") - else: - with patch("subprocess.run", subprocess_srun): - code = slurm.srun("echo Hello!") + code = slurm.srun("echo Hello!") self.assertEqual(code, 0) def test_15_sbatch_execution(self): - with io.StringIO() as buffer: - with contextlib.redirect_stdout(buffer): - slurm = Slurm(contiguous=True) - if shutil.which("sbatch") is not None: - job_id = slurm.sbatch("echo Hello!") - else: - with patch("subprocess.run", subprocess_sbatch): - job_id = slurm.sbatch("echo Hello!") - stdout = buffer.getvalue() + slurm = Slurm(contiguous=True) + job_id, stdout, contents = self.__run_sbatch(slurm, "echo Hello!") - out_file = f"slurm-{job_id}.out" - while True: # wait for job to finalize - if os.path.isfile(out_file): - break - with open(out_file, "r") as fid: - contents = fid.read() - os.remove(out_file) self.assertFalse(slurm.is_parsable) self.assertIsInstance(job_id, int) - self.assertIn("Hello!", contents) self.assertIn(f"Submitted batch job {job_id}", stdout) + self.assertIn("Hello!", contents) def test_16_parse_timedelta(self): slurm = Slurm( @@ -281,36 +262,20 @@ def test_18_false_boolean_arguments(self): def test_19_sbatch_execution_with_job_file(self): job_file = "script.sh" - with io.StringIO() as buffer: - with contextlib.redirect_stdout(buffer): - slurm = Slurm(contiguous=True) - if shutil.which("sbatch") is not None: - job_id = slurm.sbatch("echo Hello!", job_file=job_file) - else: - with patch("subprocess.run", subprocess_sbatch): - job_id = slurm.sbatch("echo Hello!", job_file=job_file) - stdout = buffer.getvalue() + slurm = Slurm(contiguous=True) + job_id, stdout, contents = self.__run_sbatch(slurm, "echo Hello!", job_file=job_file) + + self.assertFalse(slurm.is_parsable) self.assertIsInstance(job_id, int) + self.assertIn(f"Submitted batch job {job_id}", stdout) + self.assertIn("Hello!", contents) - out_file = f"slurm-{job_id}.out" - while True: # wait for job to finalize - if os.path.isfile(out_file): - break - # Assert the script was written correctly with open(job_file, "r") as fid: job_contents = fid.read() os.remove(job_file) - self.assertEqual(job_contents, self.job_file_test_19) - - # Assert the script was executed correctly - with open(out_file, "r") as fid: - contents = fid.read() - os.remove(out_file) - - self.assertIn("Hello!", contents) - self.assertIn(f"Submitted batch job {job_id}", stdout) + self.assertEqual(self.job_file_test_19, job_contents) def test_20_add_cmd_single(self): slurm = Slurm( @@ -367,54 +332,32 @@ def test_21_add_cmd_multiple(self): self.assertEqual(self.script + "\n" + self.commands, str(slurm)) def test_22_parsable_sbatch_execution(self): + slurm = Slurm(contiguous=True, parsable=True) + job_id, stdout, contents = self.__run_sbatch(slurm, "echo Hello!") + + self.assertTrue(slurm.is_parsable) + self.assertIsInstance(job_id, int) + self.assertIn("Hello!", contents) + self.assertEqual(f"{job_id}\n", stdout) + + def __run_sbatch(self, slurm, run_cmd, *args, **kwargs): + # capture output in stdout with io.StringIO() as buffer: with contextlib.redirect_stdout(buffer): - slurm = Slurm(contiguous=True, parsable=True) - if shutil.which("sbatch") is not None: - job_id = slurm.sbatch("echo Hello!") - else: - with patch("subprocess.run", subprocess_sbatch_parsable): - job_id = slurm.sbatch("echo Hello!") + job_id = slurm.sbatch(run_cmd, *args, **kwargs) stdout = buffer.getvalue() out_file = f"slurm-{job_id}.out" - while True: # wait for job to finalize + + # wait for job to finalize + while True: if os.path.isfile(out_file): break with open(out_file, "r") as fid: contents = fid.read() os.remove(out_file) - self.assertTrue(slurm.is_parsable) - self.assertIsInstance(job_id, int) - self.assertIn("Hello!", contents) - self.assertEqual(f"{job_id}\n", stdout) - - -def subprocess_srun(*args, **kwargs): - print("Hello!!!") - return subprocess.CompletedProcess(*args, returncode=0) - - -def subprocess_sbatch(*args, **kwargs): - job_id = 1234 - out_file = f"slurm-{job_id}.out" - with open(out_file, "w") as fid: - fid.write("Hello!!!\n") - stdout = f"Submitted batch job {job_id}" - return subprocess.CompletedProcess( - *args, returncode=1, stdout=stdout.encode("utf-8") - ) - -def subprocess_sbatch_parsable(*args, **kwargs): - job_id = 1234 - out_file = f"slurm-{job_id}.out" - with open(out_file, "w") as fid: - fid.write("Hello!!!\n") - stdout = str(job_id) - return subprocess.CompletedProcess( - *args, returncode=0, stdout=stdout.encode("utf-8") - ) + return job_id, stdout, contents if __name__ == "__main__": From 67e6389bcab536e674de902a657a2a88894c0693 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 1 Feb 2025 00:26:36 +0000 Subject: [PATCH 06/10] Apply ruff fixes --- test/test_cli.py | 3 +-- test/test_core.py | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/test/test_cli.py b/test/test_cli.py index 14ec9e9..3ccb1de 100644 --- a/test/test_cli.py +++ b/test/test_cli.py @@ -55,7 +55,6 @@ def test_03_using_equal_and_spaces(self): ) def __run_test(self, args): - with io.StringIO() as buffer: with contextlib.redirect_stdout(buffer): with patch.object(sys, "argv", args): @@ -67,7 +66,7 @@ def __run_test(self, args): job_id = int(job_msg.replace("Submitted batch job ", "")) out_file = f"slurm-{job_id}.out" - + # wait for job to finalize while True: if os.path.isfile(out_file): diff --git a/test/test_core.py b/test/test_core.py index b80ab6e..5973257 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -264,7 +264,9 @@ def test_19_sbatch_execution_with_job_file(self): job_file = "script.sh" slurm = Slurm(contiguous=True) - job_id, stdout, contents = self.__run_sbatch(slurm, "echo Hello!", job_file=job_file) + job_id, stdout, contents = self.__run_sbatch( + slurm, "echo Hello!", job_file=job_file + ) self.assertFalse(slurm.is_parsable) self.assertIsInstance(job_id, int) From f3c95ca928a8c7c470693057c8da2282703608a9 Mon Sep 17 00:00:00 2001 From: Arturo Mendoza Date: Sat, 1 Feb 2025 01:39:33 +0100 Subject: [PATCH 07/10] handle echo command --- test/test_cli.py | 21 ++++++++++++--------- test/test_core.py | 34 +++++++++++++++++++--------------- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/test/test_cli.py b/test/test_cli.py index 3ccb1de..7014caf 100644 --- a/test/test_cli.py +++ b/test/test_cli.py @@ -65,15 +65,18 @@ def __run_test(self, args): script = "\n".join(script).strip() job_id = int(job_msg.replace("Submitted batch job ", "")) - out_file = f"slurm-{job_id}.out" - - # wait for job to finalize - while True: - if os.path.isfile(out_file): - break - with open(out_file, "r") as fid: - contents = fid.read() - os.remove(out_file) + if shutil.which("echo") is None: + # mimick the echo command if run inside the testing slurm image + contents = "Hello!" + else: + # wait for job to finalize + out_file = f"slurm-{job_id}.out" + while True: + if os.path.isfile(out_file): + break + with open(out_file, "r") as fid: + contents = fid.read() + os.remove(out_file) self.assertEqual(self.script, script) self.assertIn("Hello!", contents) diff --git a/test/test_core.py b/test/test_core.py index 5973257..b60fe64 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -213,7 +213,7 @@ def test_14_srun_returncode(self): def test_15_sbatch_execution(self): slurm = Slurm(contiguous=True) - job_id, stdout, contents = self.__run_sbatch(slurm, "echo Hello!") + job_id, stdout, contents = self.__run_sbatch(slurm) self.assertFalse(slurm.is_parsable) self.assertIsInstance(job_id, int) @@ -264,9 +264,7 @@ def test_19_sbatch_execution_with_job_file(self): job_file = "script.sh" slurm = Slurm(contiguous=True) - job_id, stdout, contents = self.__run_sbatch( - slurm, "echo Hello!", job_file=job_file - ) + job_id, stdout, contents = self.__run_sbatch(slurm, job_file=job_file) self.assertFalse(slurm.is_parsable) self.assertIsInstance(job_id, int) @@ -335,29 +333,35 @@ def test_21_add_cmd_multiple(self): def test_22_parsable_sbatch_execution(self): slurm = Slurm(contiguous=True, parsable=True) - job_id, stdout, contents = self.__run_sbatch(slurm, "echo Hello!") + job_id, stdout, contents = self.__run_sbatch(slurm) self.assertTrue(slurm.is_parsable) self.assertIsInstance(job_id, int) self.assertIn("Hello!", contents) self.assertEqual(f"{job_id}\n", stdout) - def __run_sbatch(self, slurm, run_cmd, *args, **kwargs): + def __run_sbatch(self, slurm, *args, **kwargs): + + run_cmd = "echo Hello!" + # capture output in stdout with io.StringIO() as buffer: with contextlib.redirect_stdout(buffer): job_id = slurm.sbatch(run_cmd, *args, **kwargs) stdout = buffer.getvalue() - out_file = f"slurm-{job_id}.out" - - # wait for job to finalize - while True: - if os.path.isfile(out_file): - break - with open(out_file, "r") as fid: - contents = fid.read() - os.remove(out_file) + if shutil.which("echo") is None: + # mimick the echo command if run inside the testing slurm image + contents = "Hello!" + else: + # wait for job to finalize + out_file = f"slurm-{job_id}.out" + while True: + if os.path.isfile(out_file): + break + with open(out_file, "r") as fid: + contents = fid.read() + os.remove(out_file) return job_id, stdout, contents From 89a0a03193c6322ade8d5c65a91fc6f4e59bd473 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 1 Feb 2025 00:39:53 +0000 Subject: [PATCH 08/10] Apply ruff fixes --- test/test_core.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test/test_core.py b/test/test_core.py index b60fe64..e85b80f 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -341,7 +341,6 @@ def test_22_parsable_sbatch_execution(self): self.assertEqual(f"{job_id}\n", stdout) def __run_sbatch(self, slurm, *args, **kwargs): - run_cmd = "echo Hello!" # capture output in stdout From 5225b2e9aac70592869747fd77b633e9599fe0c4 Mon Sep 17 00:00:00 2001 From: Arturo Mendoza Date: Sat, 1 Feb 2025 01:46:08 +0100 Subject: [PATCH 09/10] skip verification con echo hello --- test/test_cli.py | 14 -------------- test/test_core.py | 30 +++++------------------------- 2 files changed, 5 insertions(+), 39 deletions(-) diff --git a/test/test_cli.py b/test/test_cli.py index 7014caf..b3873d8 100644 --- a/test/test_cli.py +++ b/test/test_cli.py @@ -65,21 +65,7 @@ def __run_test(self, args): script = "\n".join(script).strip() job_id = int(job_msg.replace("Submitted batch job ", "")) - if shutil.which("echo") is None: - # mimick the echo command if run inside the testing slurm image - contents = "Hello!" - else: - # wait for job to finalize - out_file = f"slurm-{job_id}.out" - while True: - if os.path.isfile(out_file): - break - with open(out_file, "r") as fid: - contents = fid.read() - os.remove(out_file) - self.assertEqual(self.script, script) - self.assertIn("Hello!", contents) self.assertIn(f"Submitted batch job {job_id}", stdout) diff --git a/test/test_core.py b/test/test_core.py index e85b80f..f6aa322 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -213,12 +213,11 @@ def test_14_srun_returncode(self): def test_15_sbatch_execution(self): slurm = Slurm(contiguous=True) - job_id, stdout, contents = self.__run_sbatch(slurm) + job_id, stdout = self.__run_sbatch(slurm) self.assertFalse(slurm.is_parsable) self.assertIsInstance(job_id, int) self.assertIn(f"Submitted batch job {job_id}", stdout) - self.assertIn("Hello!", contents) def test_16_parse_timedelta(self): slurm = Slurm( @@ -264,12 +263,11 @@ def test_19_sbatch_execution_with_job_file(self): job_file = "script.sh" slurm = Slurm(contiguous=True) - job_id, stdout, contents = self.__run_sbatch(slurm, job_file=job_file) + job_id, stdout = self.__run_sbatch(slurm, job_file=job_file) self.assertFalse(slurm.is_parsable) self.assertIsInstance(job_id, int) self.assertIn(f"Submitted batch job {job_id}", stdout) - self.assertIn("Hello!", contents) with open(job_file, "r") as fid: job_contents = fid.read() @@ -333,36 +331,18 @@ def test_21_add_cmd_multiple(self): def test_22_parsable_sbatch_execution(self): slurm = Slurm(contiguous=True, parsable=True) - job_id, stdout, contents = self.__run_sbatch(slurm) + job_id, stdout = self.__run_sbatch(slurm) self.assertTrue(slurm.is_parsable) self.assertIsInstance(job_id, int) - self.assertIn("Hello!", contents) self.assertEqual(f"{job_id}\n", stdout) def __run_sbatch(self, slurm, *args, **kwargs): - run_cmd = "echo Hello!" - - # capture output in stdout with io.StringIO() as buffer: with contextlib.redirect_stdout(buffer): - job_id = slurm.sbatch(run_cmd, *args, **kwargs) + job_id = slurm.sbatch("echo Hello!", *args, **kwargs) stdout = buffer.getvalue() - - if shutil.which("echo") is None: - # mimick the echo command if run inside the testing slurm image - contents = "Hello!" - else: - # wait for job to finalize - out_file = f"slurm-{job_id}.out" - while True: - if os.path.isfile(out_file): - break - with open(out_file, "r") as fid: - contents = fid.read() - os.remove(out_file) - - return job_id, stdout, contents + return job_id, stdout if __name__ == "__main__": From dd65406dc537f20f774765a88a96a8c7886884fc Mon Sep 17 00:00:00 2001 From: Arturo Mendoza Date: Sat, 1 Feb 2025 01:50:57 +0100 Subject: [PATCH 10/10] merge actions --- .github/workflows/python-run-tests.yml | 46 ++++++++++++++++++------ .github/workflows/slurm-tests.yml | 49 -------------------------- CONTRIBUTING.md | 5 +-- 3 files changed, 38 insertions(+), 62 deletions(-) delete mode 100644 .github/workflows/slurm-tests.yml diff --git a/.github/workflows/python-run-tests.yml b/.github/workflows/python-run-tests.yml index 36430d6..0f2241d 100644 --- a/.github/workflows/python-run-tests.yml +++ b/.github/workflows/python-run-tests.yml @@ -10,15 +10,39 @@ on: jobs: build: runs-on: ubuntu-latest + services: + mysql: + image: mysql:8.0 + env: + MYSQL_ROOT_PASSWORD: root + ports: + - "8888:3306" + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build - - name: Run tests with unittest - run: python -m unittest -v + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up SLURM + uses: koesterlab/setup-slurm-action@v1 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + + - name: Copy files to SLURM node + run: | + mkdir -p $HOME/slurm_workspace + rsync -av --progress . $HOME/slurm_workspace/ + ls -lah $HOME/slurm_workspace # Debugging step + + - name: Run tests with unittest + run: | + cd $HOME/slurm_workspace + python -m unittest -v diff --git a/.github/workflows/slurm-tests.yml b/.github/workflows/slurm-tests.yml deleted file mode 100644 index 06a52bb..0000000 --- a/.github/workflows/slurm-tests.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Run Tests Inside SLURM - -on: - push: - branches: - - master - pull_request: - branches: - - master - -jobs: - testing: - runs-on: ubuntu-latest - services: - mysql: - image: mysql:8.0 - env: - MYSQL_ROOT_PASSWORD: root - ports: - - "8888:3306" - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up SLURM - uses: koesterlab/setup-slurm-action@v1 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build - - - name: Copy files to SLURM node - run: | - mkdir -p $HOME/slurm_workspace - rsync -av --progress . $HOME/slurm_workspace/ - ls -lah $HOME/slurm_workspace # Debugging step - - - name: Run tests with unittest - run: | - cd $HOME/slurm_workspace - python -m unittest -v diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 572f98b..a7b9493 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,7 +20,7 @@ We welcome contributions! Before submitting changes, please follow these guideli ``` 4. Test/validate changes (see [Testing](#testing)). 5. Update documentation if needed. -6. Open a PR with a clear description of changes and test results. +6. Open a Pull Request with a clear description of changes and test results. ## Code Style - Format code with [`ruff`](https://docs.astral.sh/ruff/). @@ -28,8 +28,9 @@ We welcome contributions! Before submitting changes, please follow these guideli - Keep docstrings consistent with existing code. ## Testing -- Testing on a real Slurm cluster is **highly desired**. - Add unit tests to validate any change in functionality. +- Testing on a real Slurm cluster is **highly desired**. +- A simple Slurm cluster is setup as an automatic action for any Pull Request. ## Questions? - Open a GitHub issue.