Skip to content

Commit

Permalink
Debug runner
Browse files Browse the repository at this point in the history
  • Loading branch information
niknetniko committed May 29, 2024
1 parent ead9992 commit ad4bfcc
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 18 deletions.
36 changes: 18 additions & 18 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: docker build -t "local-image" -f ${{ github.workspace }}/.github/dodona-image.dockerfile --network=host .
name: Build Dodona Docker image
- run: docker run -v ${{ github.workspace }}:/github/workspace -e TESTED_SOURCE=/github/workspace local-image
name: Run tests in Dodona Docker image
# - run: docker build -t "local-image" -f ${{ github.workspace }}/.github/dodona-image.dockerfile --network=host .
# name: Build Dodona Docker image
# - run: docker run -v ${{ github.workspace }}:/github/workspace -e TESTED_SOURCE=/github/workspace local-image
# name: Run tests in Dodona Docker image
# Runs in the Docker image to check if the JS exercises still work.
javascript-dodona:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
echo "$JAVASCRIPT_EXERCISES_KEY" > private
chmod 0600 private
GIT_SSH_COMMAND='ssh -o "StrictHostKeyChecking no" -i private' git clone git@github.ugent.be:Scriptingtalen/javascript-oefeningen.git
rm private
env:
JAVASCRIPT_EXERCISES_KEY: ${{ secrets.JAVASCRIPT_EXERCISES_KEY }}
- run: git checkout $EXERCISES_COMMIT
working-directory: ./javascript-oefeningen
- run: docker build -t "integration-image" -f ${{ github.workspace }}/.github/dodona-image-integration.dockerfile --network=host .
name: Build Dodona Docker image
- run: docker run -v ${{ github.workspace }}:/github/workspace -e TESTED_SOURCE=/github/workspace -e EXERCISE_REPO=/github/workspace/javascript-oefeningen integration-image
name: Run integration tests in Dodona Docker image
# - run: |
# echo "$JAVASCRIPT_EXERCISES_KEY" > private
# chmod 0600 private
# GIT_SSH_COMMAND='ssh -o "StrictHostKeyChecking no" -i private' git clone git@github.ugent.be:Scriptingtalen/javascript-oefeningen.git
# rm private
# env:
# JAVASCRIPT_EXERCISES_KEY: ${{ secrets.JAVASCRIPT_EXERCISES_KEY }}
# - run: git checkout $EXERCISES_COMMIT
# working-directory: ./javascript-oefeningen
# - run: docker build -t "integration-image" -f ${{ github.workspace }}/.github/dodona-image-integration.dockerfile --network=host .
# name: Build Dodona Docker image
# - run: docker run -v ${{ github.workspace }}:/github/workspace -e TESTED_SOURCE=/github/workspace -e EXERCISE_REPO=/github/workspace/javascript-oefeningen integration-image
# name: Run integration tests in Dodona Docker image
# Runs in the repo to check if the JS exercises still work.
javascript-repository:
runs-on: ubuntu-latest
Expand All @@ -51,4 +51,4 @@ jobs:
JAVASCRIPT_EXERCISES_KEY: ${{ secrets.JAVASCRIPT_EXERCISES_KEY }}
- run: git checkout $EXERCISES_COMMIT
working-directory: ./javascript-oefeningen
- run: nix develop -c bash -c 'EXERCISE_REPO=${{ github.workspace }}/javascript-oefeningen poetry run pytest -n auto ${{ github.workspace }}/tests/test_integration_javascript.py'
- run: nix develop -c bash -c "EXERCISE_REPO=./javascript-oefeningen poetry run pytest -x tests/test_integration_javascript.py"
8 changes: 8 additions & 0 deletions tested/judge/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,14 @@ def _execute_one_unit(
else:
execution_result = None

if execution_result is not None:
print("---------------- STDOUT EXECUTION -------------------")
print(execution_result.stdout)
print("---------------- STDERR EXECUTION -------------------")
print(execution_result.stderr)
print("---------------- EXIT CODE -------------------")
print(execution_result.exit)

return local_compilation_results, execution_result, execution_dir


Expand Down
13 changes: 13 additions & 0 deletions tested/judge/execution.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import itertools
import logging
import subprocess
from pathlib import Path

from attrs import define
Expand Down Expand Up @@ -259,6 +260,18 @@ def execute_unit(
values = _get_contents_or_empty(value_file(bundle, execution_dir))
exceptions = _get_contents_or_empty(exception_file(bundle, execution_dir))

print("---------------- VALUES AFTER EXECUTION --------------")
print(values)
print("---------------- EXCEPTIONS AFTER EXECUTION --------------")
print(exceptions)
print("---------------- LS --------------------------------------")
return_code = subprocess.call(f"tree {str(execution_dir)}", shell=True, text=True)
print(return_code)
print("---------------- ACTUAL SOURCE AS EXECUTED ---------------")
with open(execution_dir / "submission.js", "r") as subm:
print(subm.read())
print("---------------- END ACTUAL SOURCE -----------------------")

return ExecutionResult(
stdout=base_result.stdout,
stderr=base_result.stderr,
Expand Down
18 changes: 18 additions & 0 deletions tests/test_integration_javascript.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"""

import json
import logging
import os
import sys
from pathlib import Path

import pytest
Expand Down Expand Up @@ -81,6 +83,18 @@ def get_exercises() -> list[Path]:

@pytest.mark.parametrize("exercise", ALL_EXERCISES, ids=lambda ex: ex.name)
def test_javascript_exercise(exercise: Path, tmp_path: Path, pytestconfig, snapshot):
log = logging.getLogger()
log.setLevel(logging.DEBUG)
ch = logging.StreamHandler(stream=sys.stdout)
formatter = logging.Formatter("%(name)s:%(levelname)s:%(message)s")
ch.setFormatter(formatter)
log.addHandler(ch)

# Some modules are very verbose, hide those by default.
logger = logging.getLogger("tested.judge.collector")
logger.setLevel(logging.INFO)
logger = logging.getLogger("tested.parsing")
logger.setLevel(logging.INFO)
conf = exercise_configuration(
pytestconfig,
exercise,
Expand All @@ -89,6 +103,10 @@ def test_javascript_exercise(exercise: Path, tmp_path: Path, pytestconfig, snaps
"suite.yaml",
"solution.nl",
)
print("------------ SOURCE -------------")
with open(conf.source, 'r') as s:
print(s.read())
print("END OF ------------ SOURCE -------------")
result = execute_config(conf)
updates = assert_valid_output(result, pytestconfig)
status = updates.find_status_enum()
Expand Down

0 comments on commit ad4bfcc

Please sign in to comment.