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

Refactor repo structure #132

Merged
merged 1 commit into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions .github/workflows/docker-publish-server.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docker
name: Docker Publish Server

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
Expand All @@ -17,7 +17,7 @@ env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}/judge-server
IMAGE_NAME: ${{ github.repository }}/judger-server


jobs:
Expand Down Expand Up @@ -66,12 +66,12 @@ jobs:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
file: docker/judge-server.dockerfile
file: docker/judger-server.dockerfile
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: Rust Check

on:
push:
Expand Down
7 changes: 6 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@
"judge-service": "helper",
"judge-server": "server",
"postman": "api"
}
},
"rust-analyzer.linkedProjects": [
"./judger/Cargo.toml",
"./judger/Cargo.toml",
"./judger/Cargo.toml"
]
}
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[workspace]
members = ["judge-core", "judge-service", "judge-server", "judge-cli"]
members = ["judge-core", "judger"]
resolver = "2"
2 changes: 1 addition & 1 deletion docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
Run the following command under project root instead.

```sh
docker build --pull --rm -f "docker/judge-server.dockerfile" -t oj-lab/judge-server:latest .
docker build --pull --rm -f "docker/judger-server.dockerfile" -t oj-lab/judger-server:latest .
```
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
FROM rust:latest as build

COPY judge-core /usr/src/judge-core
COPY judge-server /usr/src/judge-server
WORKDIR /usr/src/judge-server
COPY judger /usr/src/judger
WORKDIR /usr/src/judger

RUN apt update && apt install -y libseccomp-dev gcc
RUN cargo build --bin judge-server --release
RUN cargo build --bin judger-server --release


FROM ubuntu:latest

RUN apt update && apt install -y libseccomp-dev gcc g++
COPY --from=build /usr/src/judge-server/target/release/judge-server /usr/local/bin/judge-server
COPY --from=build /usr/src/judger/target/release/judger-server /usr/local/bin/judger-server
RUN mkdir /workspace
WORKDIR /workspace
COPY dev-problem-package /workspace/dev-problem-package
Expand Down
12 changes: 0 additions & 12 deletions judge-cli/Cargo.toml

This file was deleted.

5 changes: 0 additions & 5 deletions judge-server/README.md

This file was deleted.

68 changes: 0 additions & 68 deletions judge-server/postman/Judge Server.postman_collection.json

This file was deleted.

21 changes: 0 additions & 21 deletions judge-server/postman/OJ Lab Environment.postman_environment.json

This file was deleted.

17 changes: 0 additions & 17 deletions judge-service/Cargo.toml

This file was deleted.

1 change: 0 additions & 1 deletion judge-service/src/utils/mod.rs

This file was deleted.

18 changes: 15 additions & 3 deletions judge-server/Cargo.toml → judger/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
[package]
name = "judge-server"
name = "judger"
version = "0.1.0"
edition = "2018"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
judge-core = { path = "../judge-core" }

# CLI
clap = { version = "4.0", features = ["derive"] }

# Async runtime
tokio = { version = "1", features = ["full"] }

Expand Down Expand Up @@ -37,4 +42,11 @@ thiserror = "1"

uuid = { version = "1.4", features = ["serde", "v4"] }

judge-core = { path = "../judge-core" }
[[bin]]
name ="judger-cli"
path ="src/cli/main.rs"

[[bin]]
name ="judger-server"
path ="src/server/main.rs"

24 changes: 18 additions & 6 deletions judge-cli/README.md → judger/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
# Judge Cli
# Judger

## Cli

This will be the easiest and closest way to try out the basic feature of Judger.

## Develop Usage
### Develop Usage

To run from the source code, try:

``` shell
cargo run --bin judge-cli -- [COMMAND]
cargo run --bin judger-cli -- [COMMAND]
```

``` shell
cargo run --bin judge-cli -- batch-judge --help
cargo run --bin judger-cli -- batch-judge --help
```

For an example usage of the lastest batch judge feature:

``` shell
cargo run --bin judge-cli -- batch-judge \
cargo run --bin judger-cli -- batch-judge \
-s test-collection/src/programs/read_and_write.cpp \
-p test-collection/packages/icpc/hello_world \
-l cpp \
-t icpc \
-r tmp/icpc
```
```

## Server

### How to run

`cargo run --bin judger-server -- --env-path ./judge-server/src/environment/.env.development`

### How to visit OpenAPI

visit `{HOST}/swagger-ui/`
File renamed without changes.
2 changes: 2 additions & 0 deletions judger/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#[allow(dead_code)]
pub mod service;
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub struct JudgeServerOpt {
pub env_path: Option<String>,

/// Port to listen to
#[structopt(env = "PORT", default_value = "8000")]
#[structopt(env = "PORT", default_value = "8080")]
pub port: u16,

#[structopt(long, default_value = "dev-problem-package")]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion judge-service/src/lib.rs → judger/src/service/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
pub mod error;
pub mod package_manager;
mod utils;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{
use judge_core::{error::JudgeCoreError, package::PackageType};
use serde_derive::{Deserialize, Serialize};

use crate::error::JudgeServiceError;
use crate::service::error::JudgeServiceError;

pub const PACKAGES_DISCRIPTION_FILE_NAME: &str = "judge-pd.json";

Expand Down Expand Up @@ -98,52 +98,3 @@ fn update_package_discription_file(
)?;
Ok(())
}

#[cfg(test)]
pub mod package_discription_test {
use judge_core::package::PackageType;

#[test]
fn test_storaged_package_discription_map() {
use super::StoragedPackageDiscriptionMap;
use std::path::PathBuf;

let folder = PathBuf::from("../judge-core/tests/temp");
let mut package_discription_map =
StoragedPackageDiscriptionMap::init(folder.clone()).unwrap();

let package_discription = super::PackageDiscription {
name: "test".to_string(),
revision: 1,
package_type: PackageType::ICPC,
};
package_discription_map.insert(package_discription).unwrap();

let package_discription_map = StoragedPackageDiscriptionMap::load(folder).unwrap();
assert_eq!(package_discription_map.package_discription_map.len(), 1);
assert_eq!(
package_discription_map
.package_discription_map
.get("test")
.unwrap()
.name,
"test"
);
assert_eq!(
package_discription_map
.package_discription_map
.get("test")
.unwrap()
.revision,
1
);
assert_eq!(
package_discription_map
.package_discription_map
.get("test")
.unwrap()
.package_type,
PackageType::ICPC
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::path::PathBuf;

use judge_core::package::PackageType;

use crate::error::JudgeServiceError;
use crate::service::error::JudgeServiceError;

use self::discription::StoragedPackageDiscriptionMap;

Expand Down
Loading
Loading