Skip to content

Commit

Permalink
WIP test pending
Browse files Browse the repository at this point in the history
  • Loading branch information
fushar committed Oct 28, 2023
1 parent d7e7303 commit b2adbc5
Show file tree
Hide file tree
Showing 17 changed files with 150 additions and 208 deletions.
152 changes: 5 additions & 147 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,92 +3,13 @@ name: ci
on:
push:
branches:
- '*'
- "*"
pull_request:
branches:
- master

jobs:
test:
runs-on: ubuntu-22.04
services:
rabbitmq:
image: rabbitmq
ports:
- 5672:5672
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 50

- id: changed-files
name: Check changed files
run: python3 ci/check-changed-files.py | bash

- name: Set up JDK
if: steps.changed-files.outputs.gradle == '1'
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
cache: 'gradle'

- name: Test judgels-commons
if: steps.changed-files.outputs.judgels-commons == '1'
run: ./judgels-backends/gradlew -p judgels-backends/judgels-commons check

- name: Test judgels-grader-api
if: steps.changed-files.outputs.judgels-grader == '1'
run: ./judgels-backends/gradlew -p judgels-backends/judgels-grader-api check

- name: Test judgels-grader-engines
if: steps.changed-files.outputs.judgels-grader == '1'
run: ./judgels-backends/gradlew -p judgels-backends/judgels-grader-engines check

- name: Test judgels-grader-app
if: steps.changed-files.outputs.judgels-grader == '1'
run: ./judgels-backends/gradlew -p judgels-backends/judgels-grader-app check

- name: Test judgels-server-api
if: steps.changed-files.outputs.judgels-server == '1'
run: ./judgels-backends/gradlew -p judgels-backends/judgels-server-api check

- name: Test judgels-server-app
if: steps.changed-files.outputs.judgels-server == '1'
run: ./judgels-backends/gradlew -p judgels-backends/judgels-server-app check

- name: Set up node
if: steps.changed-files.outputs.yarn == '1'
uses: actions/setup-node@v3
with:
node-version: '16'

- name: Get yarn cache directory path
if: steps.changed-files.outputs.yarn == '1'
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Use yarn cache
if: steps.changed-files.outputs.yarn == '1'
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Test judgels-client
if: steps.changed-files.outputs.judgels-client == '1'
run: |
cd judgels-client
export NODE_OPTIONS="--max-old-space-size=4096"
yarn install
yarn ci
build:
needs: test
if: github.ref == 'refs/heads/master' && github.repository_owner == 'ia-toki'
runs-on: ubuntu-22.04
env:
CONTAINER_REGISTRY_USERNAME: ${{ secrets.CONTAINER_REGISTRY_USERNAME }}
Expand All @@ -111,15 +32,15 @@ jobs:
if: steps.changed-files.outputs.gradle == '1'
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
cache: 'gradle'
distribution: "zulu"
java-version: "11"
cache: "gradle"

- name: Set up node
if: steps.changed-files.outputs.yarn == '1'
uses: actions/setup-node@v3
with:
node-version: '16'
node-version: "16"

- name: Get yarn cache directory path
if: steps.changed-files.outputs.yarn == '1'
Expand All @@ -136,61 +57,12 @@ jobs:
restore-keys: |
${{ runner.os }}-yarn-
- name: Build judgels-server
if: steps.changed-files.outputs.judgels-server == '1'
run: ./deployment/scripts/build_judgels_server.sh

- name: Build judgels-client
if: steps.changed-files.outputs.judgels-client == '1'
run: ./deployment/scripts/build_judgels_client.sh

- name: Build judgels-grader
if: steps.changed-files.outputs.judgels-grader == '1'
run: ./deployment/scripts/build_judgels_grader.sh

deploy-web:
if: github.ref == 'refs/heads/master' && github.repository_owner == 'ia-toki'
runs-on: ubuntu-22.04
env:
WEB_HOST: ${{ secrets.WEB_HOST }}
WEB_KNOWN_HOSTS: ${{ secrets.WEB_KNOWN_HOSTS }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 50

- id: changed-files
name: Check changed files
run: python3 ci/check-changed-files.py | bash

- name: Set up node
if: steps.changed-files.outputs.web == '1'
uses: actions/setup-node@v3
with:
node-version: '16'

- name: Build web
if: steps.changed-files.outputs.web == '1'
run: |
cd web
yarn install
yarn build
- name: Install SSH key
if: steps.changed-files.outputs.web == '1'
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.WEB_PRIVATE_KEY }}
known_hosts: ${{ secrets.WEB_KNOWN_HOSTS }}

- name: Rsync web
if: steps.changed-files.outputs.web == '1'
run: rsync -avzh web/build/ root@${WEB_HOST}:/var/www/html/judgels --delete

deploy-tlx-staging:
needs: build
if: github.ref == 'refs/heads/master' && github.repository_owner == 'ia-toki'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
Expand All @@ -211,23 +83,9 @@ jobs:
name: Check changed files
run: python3 ci/check-changed-files.py | bash

- name: Deploy judgels-server
if: steps.changed-files.outputs.judgels-server == '1'
run: |
eval "$(ssh-agent -s)"
ssh-add deployment/ansible/env/deployment_rsa
./deployment/scripts/deploy_judgels_server.sh
- name: Deploy judgels-client
if: steps.changed-files.outputs.judgels-client == '1'
run: |
eval "$(ssh-agent -s)"
ssh-add deployment/ansible/env/deployment_rsa
./deployment/scripts/deploy_judgels_client.sh
- name: Deploy judgels-grader
if: steps.changed-files.outputs.judgels-grader == '1'
run: |
eval "$(ssh-agent -s)"
ssh-add deployment/ansible/env/deployment_rsa
./deployment/scripts/deploy_judgels_grader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
docker_image:
source: build
force_source: yes
name: ghcr.io/ia-toki/judgels/client
name: "ghcr.io/ia-toki/judgels/client:{{ app_version | default('latest', true) }}"
push: yes
build:
path: "{{ playbook_dir }}/../../../judgels-client/dist"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
docker_image:
source: build
force_source: yes
name: ghcr.io/ia-toki/judgels/server
name: "ghcr.io/ia-toki/judgels/server:{{ app_version | default('latest', true) }}"
push: yes
build:
path: "{{ playbook_dir }}/../../../judgels-backends/judgels-server-app"
Expand Down
2 changes: 1 addition & 1 deletion deployment/scripts/build_judgels_client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ rm -rf dist/build && mv build dist/
cd ../deployment/ansible

ansible --version 0</dev/null |& cat -
ansible-playbook playbooks/build-judgels-client.yml 0</dev/null |& cat -
ansible-playbook -e app_version=test-pending playbooks/build-judgels-client.yml 0</dev/null |& cat -
2 changes: 1 addition & 1 deletion deployment/scripts/build_judgels_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ cp init.sh build/distributions
cd ../../deployment/ansible

ansible --version
ansible-playbook playbooks/build-judgels-server.yml
ansible-playbook -e app_version=test-pending playbooks/build-judgels-server.yml
2 changes: 1 addition & 1 deletion deployment/scripts/deploy_judgels_client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ set -ex
cd deployment/ansible

ansible --version
ansible-playbook -e @env/vars.yml playbooks/deploy-judgels-client.yml
ansible-playbook -e @env/vars.yml -e app_version=test-pending playbooks/deploy-judgels-client.yml
2 changes: 1 addition & 1 deletion deployment/scripts/deploy_judgels_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ set -ex
cd deployment/ansible

ansible --version
ansible-playbook -e @env/vars.yml playbooks/deploy-judgels-server.yml
ansible-playbook -e @env/vars.yml -e app_version=test-pending playbooks/deploy-judgels-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,9 @@ public Response getSubmissionSourceDarkImage(@PathParam("submissionJid") String

@POST
@Consumes(MULTIPART_FORM_DATA)
@Produces(APPLICATION_JSON)
@UnitOfWork
public void createSubmission(@HeaderParam(AUTHORIZATION) AuthHeader authHeader, FormDataMultiPart parts) {
public Submission createSubmission(@HeaderParam(AUTHORIZATION) AuthHeader authHeader, FormDataMultiPart parts) {
actorChecker.check(authHeader);

String containerJid = checkNotNull(parts.getField("containerJid"), "containerJid").getValue();
Expand All @@ -255,6 +256,8 @@ public void createSubmission(@HeaderParam(AUTHORIZATION) AuthHeader authHeader,
Submission submission = submissionClient.submit(data, source, config);

submissionSourceBuilder.storeSubmissionSource(submission.getJid(), source);

return submission;
}

@POST
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ public void requestGrading(String gradingJid, Submission submission, SubmissionS
.submissionSource(source)
.build();

try {
messageClient.sendMessage(
gradingResponseQueueName,
gradingRequestQueueName,
GradingRequest.class.getSimpleName(),
mapper.writeValueAsString(gradingRequest));
} catch (IOException e) {
throw new RuntimeException(e);
}
// try {
// messageClient.sendMessage(
// gradingResponseQueueName,
// gradingRequestQueueName,
// GradingRequest.class.getSimpleName(),
// mapper.writeValueAsString(gradingRequest));
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HTMLTable, Button } from '@blueprintjs/core';
import { HTMLTable, Button, ProgressBar } from '@blueprintjs/core';
import { Download } from '@blueprintjs/icons';
import { Link } from 'react-router-dom';

Expand Down Expand Up @@ -30,6 +30,8 @@ export function SubmissionDetails({
problemUrl,
containerName,
onDownload,
hideSourceFilename,
showLoaderWhenPending,
}) {
const hasSubtasks = latestGrading && latestGrading.details && latestGrading.details.subtaskResults.length > 1;

Expand Down Expand Up @@ -146,6 +148,13 @@ export function SubmissionDetails({
));
};

const renderLoader = () => {
if (showLoaderWhenPending && latestGrading.verdict.code === VerdictCode.PND) {
return <ProgressBar className="pending-loader" />;
}
return null;
};

const renderSampleTestDataResults = () => {
const details = latestGrading.details;
if (details.testDataResults.length < 1) {
Expand Down Expand Up @@ -302,9 +311,11 @@ export function SubmissionDetails({

const sourceFiles = Object.keys(submissionFiles).map(key => (
<ContentCard key={key}>
<h5>
{key === DEFAULT_SOURCE_KEY ? '' : key + ': '} {submissionFiles[key].name}
</h5>
{!hideSourceFilename && (
<h5>
{key === DEFAULT_SOURCE_KEY ? '' : key + ': '} {submissionFiles[key].name}
</h5>
)}
<SourceCode language={getGradingLanguageSyntaxHighlighterValue(gradingLanguage)}>
{decodeBase64(submissionFiles[key].content)}
</SourceCode>
Expand Down Expand Up @@ -343,7 +354,7 @@ export function SubmissionDetails({

const renderSourceFilesHeading = () => {
if (!onDownload) {
return <h4>Source Files</h4>;
return null;
}
return (
<div>
Expand All @@ -359,6 +370,7 @@ export function SubmissionDetails({
return (
<div className="programming-submission-details">
{renderGeneralInfo()}
{renderLoader()}
{renderDetails()}
{renderSourceFiles()}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
float: left;
}

.pending-loader {
margin-bottom: 15px;
}

.submission-details-image {
overflow: auto;
}
Expand Down
2 changes: 2 additions & 0 deletions judgels-client/src/modules/jerahmeel/jerahmeelReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import storage from 'redux-persist/es/storage';
import courseReducer from '../../routes/courses/courses/modules/courseReducer';
import courseChapterReducer from '../../routes/courses/courses/single/chapters/modules/courseChapterReducer';
import courseChaptersReducer from '../../routes/courses/courses/single/chapters/modules/courseChaptersReducer';
import chapterProblemReducer from '../../routes/courses/courses/single/chapters/single/problems/single/modules/chapterProblemReducer';
import problemSetReducer from '../../routes/problems/problemsets/modules/problemSetReducer';
import problemSetProblemReducer from '../../routes/problems/problemsets/single/problems/modules/problemSetProblemReducer';

export default combineReducers({
course: persistReducer({ key: 'jerahmeelCourse', storage }, courseReducer),
courseChapter: persistReducer({ key: 'jerahmeelCourseChapter', storage }, courseChapterReducer),
courseChapters: courseChaptersReducer,
chapterProblem: chapterProblemReducer,
problemSet: persistReducer({ key: 'jerahmeelProblemSet', storage }, problemSetReducer),
problemSetProblem: persistReducer({ key: 'jerahmeelProblemSetProblem', storage }, problemSetProblemReducer),
});
Loading

0 comments on commit b2adbc5

Please sign in to comment.