From 0ca69fb11813669e16dd53e88af338f8a3005368 Mon Sep 17 00:00:00 2001 From: Kadek Surya Mahardika Date: Sun, 22 Oct 2023 09:30:38 +0800 Subject: [PATCH 1/7] feat: accept javascript programming language --- .../judgels-grader-app/Dockerfile | 7 +++- .../languages/GradingLanguageRegistry.java | 2 + .../JavascriptNode18GradingLanguage.java | 37 +++++++++++++++++++ .../src/modules/api/gabriel/language.js | 5 +++ 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/languages/javascript/JavascriptNode18GradingLanguage.java diff --git a/judgels-backends/judgels-grader-app/Dockerfile b/judgels-backends/judgels-grader-app/Dockerfile index abd522857..cd24da75c 100644 --- a/judgels-backends/judgels-grader-app/Dockerfile +++ b/judgels-backends/judgels-grader-app/Dockerfile @@ -19,6 +19,8 @@ ENV RUSTUP_HOME /usr ENV XDG_CACHE_HOME /tmp ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64 ENV PATH $JAVA_HOME/bin:$PATH +ENV NODE_VERSION=18.0.0 +ENV NVM_DIR=/root/.nvm RUN apt-get update \ && apt-get -y --no-install-recommends install software-properties-common gpg-agent \ @@ -40,6 +42,9 @@ RUN apt-get update \ && ln -s /usr/bin/gcc-11 /usr/bin/gcc \ && ln -s /usr/bin/g++-11 /usr/bin/g++ \ && curl -sSf https://sh.rustup.rs/ | bash -s -- -y -q --default-toolchain=1.57.0 \ + && curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \ + && . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION} \ + && cp $NVM_DIR/versions/node/v${NODE_VERSION}/bin/node /usr/bin/ \ && rm -rf /var/lib/apt/lists/* WORKDIR /judgels/grader @@ -53,7 +58,7 @@ LABEL org.opencontainers.image.revision $VCS_REF COPY --from=0 /isolate/isolate /judgels/isolate/bin/ COPY --from=0 /usr/local/etc/isolate /usr/local/etc/ COPY --from=0 /moe/eval/iwrapper /judgels/isolate/bin/ -COPY build/distributions . +#COPY build/distributions . ENTRYPOINT ["./init.sh"] CMD ["server"] diff --git a/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/languages/GradingLanguageRegistry.java b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/languages/GradingLanguageRegistry.java index c59896674..22de1c3cc 100644 --- a/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/languages/GradingLanguageRegistry.java +++ b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/languages/GradingLanguageRegistry.java @@ -13,6 +13,7 @@ import judgels.gabriel.languages.cpp.CppGradingLanguage; import judgels.gabriel.languages.go.GoGradingLanguage; import judgels.gabriel.languages.java.JavaGradingLanguage; +import judgels.gabriel.languages.javascript.JavascriptNode18GradingLanguage; import judgels.gabriel.languages.pascal.PascalGradingLanguage; import judgels.gabriel.languages.python.PyPy3GradingLanguage; import judgels.gabriel.languages.python.Python3GradingLanguage; @@ -33,6 +34,7 @@ public class GradingLanguageRegistry { new PyPy3GradingLanguage(), new Python3GradingLanguage(), new Rust2021GradingLanguage(), + new JavascriptNode18GradingLanguage(), new OutputOnlyGradingLanguage()); private static final List VISIBLE_LANGUAGES = LANGUAGES.stream() diff --git a/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/languages/javascript/JavascriptNode18GradingLanguage.java b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/languages/javascript/JavascriptNode18GradingLanguage.java new file mode 100644 index 000000000..642532b84 --- /dev/null +++ b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/languages/javascript/JavascriptNode18GradingLanguage.java @@ -0,0 +1,37 @@ +package judgels.gabriel.languages.javascript; + +import com.google.common.collect.ImmutableList; +import java.util.List; +import judgels.gabriel.api.GradingLanguage; + +public class JavascriptNode18GradingLanguage implements GradingLanguage { + @Override + public String getName() { + return "Javascript (Node.js 18)"; + } + + @Override + public boolean isVisible() { + return true; + } + + @Override + public List getAllowedExtensions() { + return ImmutableList.of("js"); + } + + @Override + public List getCompilationCommand(String sourceFilename, String... sourceFilenames) { + return ImmutableList.of("/bin/true"); + } + + @Override + public String getExecutableFilename(String sourceFilename) { + return sourceFilename; + } + + @Override + public List getExecutionCommand(String sourceFilename) { + return ImmutableList.of("/usr/bin/node", sourceFilename); + } +} diff --git a/judgels-client/src/modules/api/gabriel/language.js b/judgels-client/src/modules/api/gabriel/language.js index 5bde72288..b3a9d4b20 100644 --- a/judgels-client/src/modules/api/gabriel/language.js +++ b/judgels-client/src/modules/api/gabriel/language.js @@ -14,6 +14,7 @@ export const gradingLanguageNamesMap = { Python3: 'Python 3', PyPy3: 'PyPy 3', Rust2021: 'Rust 2021', + JavascriptNode18: 'Javascript (Node.js 18)', OutputOnly: '-', }; @@ -28,6 +29,7 @@ export const gradingLanguageFamiliesMap = { Python3: 'Python', PyPy3: 'Python', Rust2021: 'Rust', + JavascriptNode18: 'Javascript', }; export const gradingLanguageFilenameExtensionsMap = { @@ -41,6 +43,7 @@ export const gradingLanguageFilenameExtensionsMap = { Python3: ['py'], PyPy3: ['py'], Rust2021: ['rs'], + JavascriptNode18: ['js'], OutputOnly: ['zip'], }; @@ -55,6 +58,7 @@ export const gradingLanguageSyntaxHighlighterValueMap = { Python3: 'python', PyPy3: 'python', Rust2021: 'rust', + JavascriptNode18: 'javascript', OutputOnly: '', }; @@ -69,6 +73,7 @@ export const gradingLanguageEditorSubmissionFilenamesMap = { Python3: 'solution.py', PyPy3: 'solution.py', Rust2021: 'solution.rs', + JavascriptNode18: 'solution.js', }; export const gradingLanguageEditorSubmissionHintsMap = { From f0d41ca7472f8aec3cc014a085b25c53de32ca71 Mon Sep 17 00:00:00 2001 From: Kadek Surya Mahardika Date: Sun, 22 Oct 2023 09:34:17 +0800 Subject: [PATCH 2/7] chore: uncomment build/distributions --- judgels-backends/judgels-grader-app/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/judgels-backends/judgels-grader-app/Dockerfile b/judgels-backends/judgels-grader-app/Dockerfile index cd24da75c..8d61f7387 100644 --- a/judgels-backends/judgels-grader-app/Dockerfile +++ b/judgels-backends/judgels-grader-app/Dockerfile @@ -58,7 +58,7 @@ LABEL org.opencontainers.image.revision $VCS_REF COPY --from=0 /isolate/isolate /judgels/isolate/bin/ COPY --from=0 /usr/local/etc/isolate /usr/local/etc/ COPY --from=0 /moe/eval/iwrapper /judgels/isolate/bin/ -#COPY build/distributions . +COPY build/distributions . ENTRYPOINT ["./init.sh"] CMD ["server"] From eb813d4fe2638d777bb928fb619a598808898ad0 Mon Sep 17 00:00:00 2001 From: Kadek Surya Mahardika Date: Sun, 22 Oct 2023 13:17:41 +0800 Subject: [PATCH 3/7] fix: dockerfile and javascript name --- judgels-backends/judgels-grader-app/Dockerfile | 17 ++++++++++------- .../languages/GradingLanguageRegistry.java | 4 ++-- ...ava => JavaScriptNode18GradingLanguage.java} | 4 ++-- .../src/modules/api/gabriel/language.js | 10 +++++----- 4 files changed, 19 insertions(+), 16 deletions(-) rename judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/languages/javascript/{JavascriptNode18GradingLanguage.java => JavaScriptNode18GradingLanguage.java} (88%) diff --git a/judgels-backends/judgels-grader-app/Dockerfile b/judgels-backends/judgels-grader-app/Dockerfile index 8d61f7387..b0f36d1b6 100644 --- a/judgels-backends/judgels-grader-app/Dockerfile +++ b/judgels-backends/judgels-grader-app/Dockerfile @@ -19,11 +19,16 @@ ENV RUSTUP_HOME /usr ENV XDG_CACHE_HOME /tmp ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64 ENV PATH $JAVA_HOME/bin:$PATH -ENV NODE_VERSION=18.0.0 -ENV NVM_DIR=/root/.nvm +ENV NODE_MAJOR 18 RUN apt-get update \ - && apt-get -y --no-install-recommends install software-properties-common gpg-agent \ + && apt-get install -y ca-certificates curl gnupg \ + && mkdir -p /etc/apt/keyrings \ + && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ + && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list + +RUN apt-get update \ + && apt-get -y --no-install-recommends install software-properties-common gpg-agent \ && add-apt-repository -y ppa:pypy/ppa \ && add-apt-repository -y ppa:ubuntu-toolchain-r/test \ && apt-get -y --no-install-recommends install \ @@ -39,12 +44,10 @@ RUN apt-get update \ openjdk-11-jre \ pypy3 \ python3 \ + nodejs \ && ln -s /usr/bin/gcc-11 /usr/bin/gcc \ && ln -s /usr/bin/g++-11 /usr/bin/g++ \ && curl -sSf https://sh.rustup.rs/ | bash -s -- -y -q --default-toolchain=1.57.0 \ - && curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \ - && . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION} \ - && cp $NVM_DIR/versions/node/v${NODE_VERSION}/bin/node /usr/bin/ \ && rm -rf /var/lib/apt/lists/* WORKDIR /judgels/grader @@ -58,7 +61,7 @@ LABEL org.opencontainers.image.revision $VCS_REF COPY --from=0 /isolate/isolate /judgels/isolate/bin/ COPY --from=0 /usr/local/etc/isolate /usr/local/etc/ COPY --from=0 /moe/eval/iwrapper /judgels/isolate/bin/ -COPY build/distributions . +#COPY build/distributions . ENTRYPOINT ["./init.sh"] CMD ["server"] diff --git a/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/languages/GradingLanguageRegistry.java b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/languages/GradingLanguageRegistry.java index 22de1c3cc..341e1bcf0 100644 --- a/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/languages/GradingLanguageRegistry.java +++ b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/languages/GradingLanguageRegistry.java @@ -13,7 +13,7 @@ import judgels.gabriel.languages.cpp.CppGradingLanguage; import judgels.gabriel.languages.go.GoGradingLanguage; import judgels.gabriel.languages.java.JavaGradingLanguage; -import judgels.gabriel.languages.javascript.JavascriptNode18GradingLanguage; +import judgels.gabriel.languages.javascript.JavaScriptNode18GradingLanguage; import judgels.gabriel.languages.pascal.PascalGradingLanguage; import judgels.gabriel.languages.python.PyPy3GradingLanguage; import judgels.gabriel.languages.python.Python3GradingLanguage; @@ -34,7 +34,7 @@ public class GradingLanguageRegistry { new PyPy3GradingLanguage(), new Python3GradingLanguage(), new Rust2021GradingLanguage(), - new JavascriptNode18GradingLanguage(), + new JavaScriptNode18GradingLanguage(), new OutputOnlyGradingLanguage()); private static final List VISIBLE_LANGUAGES = LANGUAGES.stream() diff --git a/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/languages/javascript/JavascriptNode18GradingLanguage.java b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/languages/javascript/JavaScriptNode18GradingLanguage.java similarity index 88% rename from judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/languages/javascript/JavascriptNode18GradingLanguage.java rename to judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/languages/javascript/JavaScriptNode18GradingLanguage.java index 642532b84..aea546bde 100644 --- a/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/languages/javascript/JavascriptNode18GradingLanguage.java +++ b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/languages/javascript/JavaScriptNode18GradingLanguage.java @@ -4,10 +4,10 @@ import java.util.List; import judgels.gabriel.api.GradingLanguage; -public class JavascriptNode18GradingLanguage implements GradingLanguage { +public class JavaScriptNode18GradingLanguage implements GradingLanguage { @Override public String getName() { - return "Javascript (Node.js 18)"; + return "JavaScript (Node 18)"; } @Override diff --git a/judgels-client/src/modules/api/gabriel/language.js b/judgels-client/src/modules/api/gabriel/language.js index b3a9d4b20..969239a64 100644 --- a/judgels-client/src/modules/api/gabriel/language.js +++ b/judgels-client/src/modules/api/gabriel/language.js @@ -10,11 +10,11 @@ export const gradingLanguageNamesMap = { Cpp20: 'C++20', Go: 'Go', Java: 'Java 11', + JavaScriptNode18: 'JavaScript (Node 18)', Pascal: 'Pascal', Python3: 'Python 3', PyPy3: 'PyPy 3', Rust2021: 'Rust 2021', - JavascriptNode18: 'Javascript (Node.js 18)', OutputOnly: '-', }; @@ -25,11 +25,11 @@ export const gradingLanguageFamiliesMap = { Cpp20: 'C++', Go: 'Go', Java: 'Java', + JavaScriptNode18: 'JavaScript', Pascal: 'Pascal', Python3: 'Python', PyPy3: 'Python', Rust2021: 'Rust', - JavascriptNode18: 'Javascript', }; export const gradingLanguageFilenameExtensionsMap = { @@ -39,11 +39,11 @@ export const gradingLanguageFilenameExtensionsMap = { Cpp20: ['cc', 'cpp'], Go: ['go'], Java: ['java'], + JavaScriptNode18: ['js'], Pascal: ['pas'], Python3: ['py'], PyPy3: ['py'], Rust2021: ['rs'], - JavascriptNode18: ['js'], OutputOnly: ['zip'], }; @@ -54,11 +54,11 @@ export const gradingLanguageSyntaxHighlighterValueMap = { Cpp20: 'cpp', Go: 'go', Java: 'java', + JavaScriptNode18: 'JavaScript', Pascal: 'pascal', Python3: 'python', PyPy3: 'python', Rust2021: 'rust', - JavascriptNode18: 'javascript', OutputOnly: '', }; @@ -69,11 +69,11 @@ export const gradingLanguageEditorSubmissionFilenamesMap = { Cpp20: 'solution.cpp', Go: 'solution.go', Java: 'Solution.java', + JavaScriptNode18: 'solution.js', Pascal: 'solution.pas', Python3: 'solution.py', PyPy3: 'solution.py', Rust2021: 'solution.rs', - JavascriptNode18: 'solution.js', }; export const gradingLanguageEditorSubmissionHintsMap = { From 34f09da5c43507e8deedd47b89ffd4bc88874c31 Mon Sep 17 00:00:00 2001 From: Kadek Surya Mahardika Date: Sun, 22 Oct 2023 13:23:14 +0800 Subject: [PATCH 4/7] retry ci From 9b73d2658160c8c9dd784ef0076ef621a10451fd Mon Sep 17 00:00:00 2001 From: Kadek Surya Mahardika Date: Sun, 22 Oct 2023 13:26:33 +0800 Subject: [PATCH 5/7] chore: uncomment build/distributions --- judgels-backends/judgels-grader-app/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/judgels-backends/judgels-grader-app/Dockerfile b/judgels-backends/judgels-grader-app/Dockerfile index b0f36d1b6..fa2a3bc06 100644 --- a/judgels-backends/judgels-grader-app/Dockerfile +++ b/judgels-backends/judgels-grader-app/Dockerfile @@ -61,7 +61,7 @@ LABEL org.opencontainers.image.revision $VCS_REF COPY --from=0 /isolate/isolate /judgels/isolate/bin/ COPY --from=0 /usr/local/etc/isolate /usr/local/etc/ COPY --from=0 /moe/eval/iwrapper /judgels/isolate/bin/ -#COPY build/distributions . +COPY build/distributions . ENTRYPOINT ["./init.sh"] CMD ["server"] From 5ad212b7b26aa98d841ad06eb3fb5ead558c372c Mon Sep 17 00:00:00 2001 From: Kadek Surya Mahardika Date: Sun, 22 Oct 2023 13:33:40 +0800 Subject: [PATCH 6/7] retry ci From 13cb54e964e337ca1c94a598a71fa94892178246 Mon Sep 17 00:00:00 2001 From: Kadek Surya Mahardika Date: Sun, 22 Oct 2023 22:27:07 +0800 Subject: [PATCH 7/7] chore: fix javascript ordering --- judgels-backends/judgels-grader-app/Dockerfile | 8 +++----- .../gabriel/languages/GradingLanguageRegistry.java | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/judgels-backends/judgels-grader-app/Dockerfile b/judgels-backends/judgels-grader-app/Dockerfile index fa2a3bc06..7f238a63d 100644 --- a/judgels-backends/judgels-grader-app/Dockerfile +++ b/judgels-backends/judgels-grader-app/Dockerfile @@ -19,20 +19,18 @@ ENV RUSTUP_HOME /usr ENV XDG_CACHE_HOME /tmp ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64 ENV PATH $JAVA_HOME/bin:$PATH -ENV NODE_MAJOR 18 RUN apt-get update \ - && apt-get install -y ca-certificates curl gnupg \ + && apt-get install -y --no-install-recommends ca-certificates curl gnupg \ && mkdir -p /etc/apt/keyrings \ && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ - && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list + && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list RUN apt-get update \ && apt-get -y --no-install-recommends install software-properties-common gpg-agent \ && add-apt-repository -y ppa:pypy/ppa \ && add-apt-repository -y ppa:ubuntu-toolchain-r/test \ && apt-get -y --no-install-recommends install \ - curl \ openssh-client \ rsync \ && apt-get -y --no-install-recommends install \ @@ -40,11 +38,11 @@ RUN apt-get update \ g++-11 \ golang \ libcap-dev \ + nodejs \ openjdk-11-jdk-headless \ openjdk-11-jre \ pypy3 \ python3 \ - nodejs \ && ln -s /usr/bin/gcc-11 /usr/bin/gcc \ && ln -s /usr/bin/g++-11 /usr/bin/g++ \ && curl -sSf https://sh.rustup.rs/ | bash -s -- -y -q --default-toolchain=1.57.0 \ diff --git a/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/languages/GradingLanguageRegistry.java b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/languages/GradingLanguageRegistry.java index 341e1bcf0..f0f176f3e 100644 --- a/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/languages/GradingLanguageRegistry.java +++ b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/languages/GradingLanguageRegistry.java @@ -30,11 +30,11 @@ public class GradingLanguageRegistry { new Cpp20GradingLanguage(), new GoGradingLanguage(), new JavaGradingLanguage(), + new JavaScriptNode18GradingLanguage(), new PascalGradingLanguage(), new PyPy3GradingLanguage(), new Python3GradingLanguage(), new Rust2021GradingLanguage(), - new JavaScriptNode18GradingLanguage(), new OutputOnlyGradingLanguage()); private static final List VISIBLE_LANGUAGES = LANGUAGES.stream()