Skip to content

Commit

Permalink
Merge branch 'main'
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLovesDoggo committed Dec 23, 2024
2 parents b199763 + 6373e30 commit f2875e2
Show file tree
Hide file tree
Showing 11 changed files with 11,258 additions and 156 deletions.
2 changes: 1 addition & 1 deletion .docker.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from dmoj.executors import get_available

arch = platform.machine()
ALLOW_FAIL = {'GASARM'}
ALLOW_FAIL = {'GASARM', 'LCODE'}
EXECUTORS = get_available()

if arch == 'aarch64':
Expand Down
29 changes: 29 additions & 0 deletions .docker/wlmoj/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM dmoj/runtimes-tier3

LABEL org.opencontainers.image.source="https://github.com/mcpt/wlmoj-judge"

# Keep in a seperate RUN command as this should always have a cache hit while the rest of the image may not
RUN apt-get update && \
apt-get -y --no-install-recommends install make cmake git gcc-multilib git && \
rm -rf /var/lib/apt/lists/*

RUN cd /tmp/ && git clone https://github.com/justinmeza/lci && \
cd lci && \
cmake . && \
make && \
make install && \
rm -rf /tmp/lci/ && \
cd /tmp/ && \
git clone --recursive https://github.com/mcpt/wlmoj-judge /judge && \
cd /judge && \
python3 -m venv --prompt=DMOJ /env && \
/env/bin/pip3 install cython setuptools && \
/env/bin/pip3 install -e . && \
/env/bin/python3 setup.py develop && \
HOME=~judge . ~judge/.profile && \
runuser -u judge -w PATH -- /env/bin/dmoj-autoconf -V > /judge-runtime-paths.yml && \
echo ' crt_x86_in_lib32: true' >> /judge-runtime-paths.yml

COPY .docker/wlmoj/config.yml /config.yml

ENTRYPOINT ["/usr/bin/tini", "--", "/judge/.docker/entry"]
2 changes: 2 additions & 0 deletions .docker/wlmoj/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
problem_storage_root:
- /problems/
176 changes: 79 additions & 97 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,65 @@
name: build
on: [push, pull_request]
on: [ push ]

jobs:
lint:
runs-on: ubuntu-latest
runs-on: blacksmith-2vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install Black and Flake8
run: |
pip install black==22.3 flake8==5.0.4 flake8-future-import flake8-logging-format flake8-import-order flake8-quotes flake8-black
- name: Run Flake8
run: |
black --version
flake8 --version
flake8
- name: Install clang-format 12
run: |
wget -O clang-format https://github.com/DMOJ/clang-tools-static-binaries/releases/download/master-5ea3d18c/clang-format-12_linux-amd64
chmod a+x ./clang-format
- name: Run clang-format
run: find dmoj/ \( -name '*.h' -or -name '*.cpp' -or -name '*.c' \) -not -name _cptbox.cpp -print0 | xargs -0 ./clang-format --dry-run -Werror --color
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: useblacksmith/setup-python@v6
with:
python-version: '3.10'
- name: Install Black and Flake8
run: |
pip install black==22.3 flake8==5.0.4 flake8-future-import flake8-logging-format flake8-import-order flake8-quotes flake8-black
- name: Run Flake8
run: |
black --version
flake8 --version
flake8
- name: Install clang-format 12
run: |
wget -O clang-format https://github.com/DMOJ/clang-tools-static-binaries/releases/download/master-5ea3d18c/clang-format-12_linux-amd64
chmod a+x ./clang-format
- name: Run clang-format
run: find dmoj/ \( -name '*.h' -or -name '*.cpp' -or -name '*.c' \) -not -name _cptbox.cpp -print0 | xargs -0 ./clang-format --dry-run -Werror --color
mypy:
runs-on: ubuntu-latest
runs-on: blacksmith-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies and mypy
run: |
pip install cython mypy types-termcolor types-requests types-PyYAML
pip install -r requirements.txt
- name: Verify mypy types
run: |
mypy --version
mypy dmoj
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: useblacksmith/setup-python@v6
with:
python-version: '3.10'
- name: Install dependencies and mypy
run: |
pip install cython mypy types-termcolor types-requests types-PyYAML
pip install -r requirements.txt
- name: Verify mypy types
run: |
mypy --version
mypy dmoj
test-sdist:
runs-on: ubuntu-latest
runs-on: blacksmith-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install build dependencies
run: pip install cython
- name: Create sdist
run: python setup.py sdist
- name: Install test dependencies
run: sudo apt-get install -y libseccomp-dev
- name: Test sdist
run: |
pip install dist/*.tar.gz
dmoj-autoconf
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: useblacksmith/setup-python@v6
with:
python-version: '3.10'
- name: Install build dependencies
run: pip install cython
- name: Create sdist
run: python setup.py sdist
- name: Install test dependencies
run: sudo apt-get install -y libseccomp-dev
- name: Test sdist
run: |
pip install dist/*.tar.gz
dmoj-autoconf
amd64:
runs-on: ubuntu-latest
runs-on: blacksmith-4vcpu-ubuntu-2204
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
Expand Down Expand Up @@ -97,7 +98,7 @@ jobs:
EOF
chmod a+x run run-su
- uses: actions/cache@v4
- uses: useblacksmith/cache@v5
with:
path: ~/docker-cache
key: ${{ runner.os }}-python-${{ matrix.python-version }}-pip-${{ hashFiles('**/requirements.txt') }}
Expand All @@ -113,53 +114,34 @@ jobs:
uses: codecov/codecov-action@v1
- name: Prepare cache for storage
run: sudo chown -R "$USER:$USER" "$HOME/docker-cache"
arm64:
runs-on: [self-hosted, Linux, ARM64]
strategy:
matrix:
python-version: [ '3.11' ]

# build the docker image the tests pass
build:
permissions:
packages: write
# needs: [ lint, mypy, test-sdist, amd64, arm64 ]
needs: [ amd64 ]
runs-on: blacksmith-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v4
- name: Download docker image
run: docker pull dmoj/runtimes-tier3
- name: Create docker scripts
run: |
cat > run <<'EOF'
#!/bin/bash -e
cp -r /source /code
cd /code
curl -L "https://github.com/DMOJ/runtimes-python/releases/latest/download/python${{ matrix.python-version }}-aarch64.tar.gz" | tar -xz

export PYTHONUNBUFFERED=1
export LANG=C.UTF-8
export PYTHONIOENCODING=utf8
export PYTHON="/code/python${{ matrix.python-version }}/bin/python${{ matrix.python-version }}"
"$PYTHON" -m pip install --upgrade pip wheel
"$PYTHON" -m pip install cython coverage
"$PYTHON" -m pip install -e .[test]
chmod o+w .
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

code=0
runuser -u judge -w PATH /source/run-su || code=$?
cp /code/coverage.xml /source || true
exit "$code"
EOF
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

cat > run-su <<'EOF'
#!/bin/bash -e
. ~/.profile
cd /code
"$PYTHON" -m coverage run -m unittest discover dmoj/tests/
"$PYTHON" -m coverage run --append .docker.test.py
"$PYTHON" -m coverage combine
"$PYTHON" -m coverage xml
EOF
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: .docker/wlmoj/Dockerfile
push: true
tags: "ghcr.io/mcpt/wlmoj-judge:latest"
cache-from: type=gha
cache-to: type=gha,mode=max

chmod a+x run run-su
- name: Execute tests in docker
run: |
docker run -e PYTHON_VERSION="${{ matrix.python-version }}" -v "$(pwd):/source" -v "$HOME/docker-cache:/root/.cache" \
--entrypoint=/usr/bin/tini --cap-add=SYS_PTRACE dmoj/runtimes-tier3 /source/run
- name: Upload coverage data
uses: codecov/codecov-action@v1
30 changes: 0 additions & 30 deletions .github/workflows/update-syscalls.yml

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/upload-pypi.yml

This file was deleted.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ The judge can also grade in the languages listed below:
* Turing
* V8 JavaScript
* Zig
* LOLCODE
* Processing

## Installation

Expand Down
20 changes: 20 additions & 0 deletions dmoj/executors/LCODE.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from dmoj.executors.script_executor import ScriptExecutor


class Executor(ScriptExecutor):
name = 'LOLCODE'
ext = '.lic'
command = 'lci'
command_paths = ['lci']

test_program = """\
HAI 1.2
CAN HAS STDIO?
I HAS A INPUT
GIMMEH INPUT
VISIBLE INPUT
KTHXBYE
"""

def get_cmdline(self, **kwargs):
return ['lci', self._code]
Loading

0 comments on commit f2875e2

Please sign in to comment.