From bd2f235c33979d611acf6d78e2c48177c4eb4720 Mon Sep 17 00:00:00 2001 From: Donny Wong Date: Tue, 30 Apr 2024 15:27:30 -0400 Subject: [PATCH 1/6] haskell tester: make stack resolver a setting --- docker-compose.yml | 1 + server/autotest_server/settings.yml | 1 + server/autotest_server/testers/haskell/haskell_tester.py | 3 ++- server/autotest_server/testers/haskell/setup.py | 6 +++--- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 90b52b1c..351e49a6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,6 +19,7 @@ services: - SUPERVISOR_URL=127.0.0.1:9001 - AUTOTESTER_CONFIG=/app/.dockerfiles/docker-config.yml - STACK_ROOT=/home/docker/.autotesting/.stack + - STACK_RESOLVER=lts-16.17 depends_on: - postgres - redis diff --git a/server/autotest_server/settings.yml b/server/autotest_server/settings.yml index 0325289b..4d32c71f 100644 --- a/server/autotest_server/settings.yml +++ b/server/autotest_server/settings.yml @@ -1,6 +1,7 @@ workspace: !ENV ${WORKSPACE} redis_url: !ENV ${REDIS_URL} supervisor_url: !ENV ${SUPERVISOR_URL} +stack_resolver: !ENV ${STACK_RESOLVER} workers: - user: !ENV ${USER} queues: diff --git a/server/autotest_server/testers/haskell/haskell_tester.py b/server/autotest_server/testers/haskell/haskell_tester.py index 754e3c25..f22c0718 100644 --- a/server/autotest_server/testers/haskell/haskell_tester.py +++ b/server/autotest_server/testers/haskell/haskell_tester.py @@ -6,8 +6,9 @@ from ..tester import Tester, Test, TestError from ..specs import TestSpecs +from config import config -STACK_OPTIONS = ["--resolver=lts-16.17", "--system-ghc", "--allow-different-user"] +STACK_OPTIONS = [f"--resolver={config['stack_resolver']}", "--system-ghc", "--allow-different-user"] class HaskellTest(Test): diff --git a/server/autotest_server/testers/haskell/setup.py b/server/autotest_server/testers/haskell/setup.py index 43f8090c..77e4ab9d 100644 --- a/server/autotest_server/testers/haskell/setup.py +++ b/server/autotest_server/testers/haskell/setup.py @@ -1,13 +1,13 @@ import os import json import subprocess - +from ...config import config HASKELL_TEST_DEPS = ["tasty-discover", "tasty-quickcheck"] def create_environment(_settings, _env_dir, default_env_dir): - resolver = "lts-16.17" + resolver = config["stack_resolver"] cmd = ["stack", "build", "--resolver", resolver, "--system-ghc", *HASKELL_TEST_DEPS] subprocess.run(cmd, check=True) @@ -16,7 +16,7 @@ def create_environment(_settings, _env_dir, default_env_dir): def install(): subprocess.run(os.path.join(os.path.dirname(os.path.realpath(__file__)), "requirements.system"), check=True) - resolver = "lts-16.17" + resolver = config["stack_resolver"] cmd = ["stack", "build", "--resolver", resolver, "--system-ghc", *HASKELL_TEST_DEPS] subprocess.run(cmd, check=True) subprocess.run( From 68ac5dd20a398a30d72618b385827427fc0116eb Mon Sep 17 00:00:00 2001 From: Donny Wong Date: Tue, 30 Apr 2024 15:38:07 -0400 Subject: [PATCH 2/6] updated changelog --- Changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog.md b/Changelog.md index d746537e..2ef0a01d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented here. ## [unreleased] - Add tidyverse as a default R tester package (#512) +- haskell tester: make stack resolver a setting (#515) ## [v2.4.2] - Ensure _env_status is updated to "setup" earlier when a request to update test settings is made (#499) From d79046c757cb18958a5fe3bae102491fcdccdc18 Mon Sep 17 00:00:00 2001 From: Donny Wong Date: Wed, 1 May 2024 22:34:28 -0400 Subject: [PATCH 3/6] install dependencies from requirements file --- server/autotest_server/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/autotest_server/__init__.py b/server/autotest_server/__init__.py index 217421e3..3be5db24 100644 --- a/server/autotest_server/__init__.py +++ b/server/autotest_server/__init__.py @@ -1,4 +1,6 @@ from __future__ import annotations + +import logging import os import sys import shutil @@ -368,12 +370,11 @@ def ignore_missing_dir_error( if err_type == FileNotFoundError: return raise err_inst - +logger = logging.getLogger(__name__) def update_test_settings(user, settings_id, test_settings, file_url): try: settings_dir = os.path.join(TEST_SCRIPT_DIR, str(settings_id)) - os.makedirs(settings_dir, exist_ok=True) os.chmod(TEST_SCRIPT_DIR, 0o755) @@ -396,6 +397,8 @@ def update_test_settings(user, settings_id, test_settings, file_url): default_env = os.path.join(TEST_SCRIPT_DIR, DEFAULT_ENV_DIR) if not os.path.isdir(default_env): subprocess.run([sys.executable, "-m", "venv", default_env], check=True) + requirements_path = os.path.join(os.path.dirname(__file__), '../requirements.txt') + subprocess.run([f"{default_env}/bin/pip", 'install', '-r', requirements_path], check=True) try: tester_settings["_env"] = tester_install.create_environment(tester_settings, env_dir, default_env) except Exception as e: From f2bb7d86a91c2ce4f607ece090ca838228c4189c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 2 May 2024 02:34:53 +0000 Subject: [PATCH 4/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- server/autotest_server/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/autotest_server/__init__.py b/server/autotest_server/__init__.py index 3be5db24..17dc289f 100644 --- a/server/autotest_server/__init__.py +++ b/server/autotest_server/__init__.py @@ -370,8 +370,11 @@ def ignore_missing_dir_error( if err_type == FileNotFoundError: return raise err_inst + + logger = logging.getLogger(__name__) + def update_test_settings(user, settings_id, test_settings, file_url): try: settings_dir = os.path.join(TEST_SCRIPT_DIR, str(settings_id)) @@ -397,8 +400,8 @@ def update_test_settings(user, settings_id, test_settings, file_url): default_env = os.path.join(TEST_SCRIPT_DIR, DEFAULT_ENV_DIR) if not os.path.isdir(default_env): subprocess.run([sys.executable, "-m", "venv", default_env], check=True) - requirements_path = os.path.join(os.path.dirname(__file__), '../requirements.txt') - subprocess.run([f"{default_env}/bin/pip", 'install', '-r', requirements_path], check=True) + requirements_path = os.path.join(os.path.dirname(__file__), "../requirements.txt") + subprocess.run([f"{default_env}/bin/pip", "install", "-r", requirements_path], check=True) try: tester_settings["_env"] = tester_install.create_environment(tester_settings, env_dir, default_env) except Exception as e: From fec7c16698bdeca1c0ffbebf0a14b423b654a800 Mon Sep 17 00:00:00 2001 From: Donny Wong Date: Wed, 1 May 2024 22:40:41 -0400 Subject: [PATCH 5/6] reverting empty line removal --- server/autotest_server/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/server/autotest_server/__init__.py b/server/autotest_server/__init__.py index 17dc289f..537994f9 100644 --- a/server/autotest_server/__init__.py +++ b/server/autotest_server/__init__.py @@ -378,6 +378,7 @@ def ignore_missing_dir_error( def update_test_settings(user, settings_id, test_settings, file_url): try: settings_dir = os.path.join(TEST_SCRIPT_DIR, str(settings_id)) + os.makedirs(settings_dir, exist_ok=True) os.chmod(TEST_SCRIPT_DIR, 0o755) From dbe9c3743ca235f2f31ab452f772da070cdd3c53 Mon Sep 17 00:00:00 2001 From: Donny Wong Date: Wed, 1 May 2024 22:46:34 -0400 Subject: [PATCH 6/6] removed logger --- server/autotest_server/__init__.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/server/autotest_server/__init__.py b/server/autotest_server/__init__.py index 537994f9..4d26d1b4 100644 --- a/server/autotest_server/__init__.py +++ b/server/autotest_server/__init__.py @@ -1,6 +1,4 @@ from __future__ import annotations - -import logging import os import sys import shutil @@ -372,9 +370,6 @@ def ignore_missing_dir_error( raise err_inst -logger = logging.getLogger(__name__) - - def update_test_settings(user, settings_id, test_settings, file_url): try: settings_dir = os.path.join(TEST_SCRIPT_DIR, str(settings_id))