Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

haskell tester: make stack resolver version a setting #526

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ All notable changes to this project will be documented here.

## [unreleased]
- Add tidyverse as a default R tester package (#512)
- For the Haskell tester, make stack resolver a test and environment setting (#526)

## [v2.4.3]
- Omit skipped test cases in Python tester (#522)
pretendWhale marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions server/autotest_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,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")
donny-wong marked this conversation as resolved.
Show resolved Hide resolved
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:
Expand Down
1 change: 1 addition & 0 deletions server/autotest_server/settings.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 2 additions & 2 deletions server/autotest_server/testers/haskell/haskell_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
from ..tester import Tester, Test, TestError
from ..specs import TestSpecs

STACK_OPTIONS = ["--resolver=lts-16.17", "--system-ghc", "--allow-different-user"]


class HaskellTest(Test):
def __init__(
Expand Down Expand Up @@ -101,6 +99,8 @@ def run_haskell_tests(self) -> Dict[str, List[Dict[str, Union[int, str]]]]:
Tests are run by first discovering all tests from a specific module (using tasty-discover)
and then running all the discovered tests and parsing the results from a csv file.
"""
resolver = self.specs["env_data", "resolver_version"]
STACK_OPTIONS = [f"--resolver={resolver}", "--system-ghc", "--allow-different-user"]
results = {}
this_dir = os.getcwd()
haskell_lib = os.path.join(os.path.dirname(os.path.realpath(__file__)), "lib")
Expand Down
17 changes: 17 additions & 0 deletions server/autotest_server/testers/haskell/settings_schema.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
{
"type": "object",
"required": [
"env_data"
],
"properties": {
"tester_type": {
"type": "string",
"enum": [
"haskell"
]
},
"env_data": {
"title": "Haskell environment",
"type": "object",
"required": [
"resolver_version"
],
"properties": {
"resolver_version": {
"title": "Resolver version",
"type": "string",
"enum": []
donny-wong marked this conversation as resolved.
Show resolved Hide resolved
}
}
},
"test_data": {
"title": "Test Groups",
"type": "array",
Expand Down
14 changes: 10 additions & 4 deletions server/autotest_server/testers/haskell/setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
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"
env_data = _settings.get("env_data", {})
resolver = env_data.get("resolver_version", config["stack_resolver"])
cmd = ["stack", "build", "--resolver", resolver, "--system-ghc", *HASKELL_TEST_DEPS]
subprocess.run(cmd, check=True)

Expand All @@ -16,7 +17,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(
Expand All @@ -26,4 +27,9 @@ def install():

def settings():
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), "settings_schema.json")) as f:
return json.load(f)
settings_ = json.load(f)
resolvers = [config["stack_resolver"]]
resolver_versions = settings_["properties"]["env_data"]["properties"]["resolver_version"]
resolver_versions["enum"] = resolvers
resolver_versions["default"] = resolvers[-1]
return settings_
Loading