Skip to content

Commit

Permalink
Merge pull request #4 from W2Wizard/openapi
Browse files Browse the repository at this point in the history
Use OpenAPI instead
  • Loading branch information
W2Wizard authored Apr 18, 2024
2 parents 9436f44 + 846919f commit 8ba9f22
Show file tree
Hide file tree
Showing 48 changed files with 12,660 additions and 2,130 deletions.
28 changes: 13 additions & 15 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
# EditorConfig is awesome: https://EditorConfig.org

[*.{js,jsx,ts,tsx,vue,html,css,scss,json}]
indent_style = tab
indent_size = 2
# top-most EditorConfig file
root = true

[*.md]
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false

[*.{yml,yaml}]
[*.{js,jsx,ts,tsx,css,scss,html,svelte,postcss,glsl}]
indent_size = 2

[docker-compose.yml]
indent_size = 4
indent_style = tab
trim_trailing_whitespace = true
insert_final_newline = true
1 change: 0 additions & 1 deletion .env.example

This file was deleted.

3 changes: 3 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PORT="3001"
SERVER_NAME="api"
DOCKER_API_VERSION="1.44"
4 changes: 2 additions & 2 deletions .github/workflows/bun.sh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
bun-version: [0.7.1, 0.7.2]
bun-version: [1.1.4]
steps:
- uses: actions/checkout@v3
- name: Use Bun.sh ${{ matrix.bun-version }}
uses: oven-sh/setup-bun@v1
with:
bun-version: ${{ matrix.bun-version }}
- run: bun install
- run: bun build ./src/main.ts --compile --outfile grader
- run: bun run compile
# - run: bun run test # TODO: Add unit tests
6 changes: 3 additions & 3 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Build Git Runner
run: docker build ./docker/git/ --tag w2wizard/git_runner:$(date +%s)
- name: Build Single Runner
run: docker build ./docker/single/ --tag w2wizard/single_runner:$(date +%s)
run: docker build ./docker/git/ --tag w2wizard/git:$(date +%s)
# - name: Build Single Runner
# run: docker build ./docker/single/ --tag w2wizard/code:$(date +%s)
68 changes: 54 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,137 +1,177 @@
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore

# Logs

logs
*.log
npm-debug.log*
_.log
npm-debug.log_
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Caches

.cache

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

# Runtime data

pids
*.pid
*.seed
_.pid
_.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover

lib-cov

# Coverage directory used by tools like istanbul

coverage
*.lcov

# nyc test coverage

.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)

.grunt

# Bower dependency directory (https://bower.io/)

bower_components

# node-waf configuration

.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)

build/Release

# Dependency directories

node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)

web_modules/

# TypeScript cache

*.tsbuildinfo

# Optional npm cache directory

.npm

# Optional eslint cache

.eslintcache

# Optional stylelint cache

.stylelintcache

# Microbundle cache

.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history

.node_repl_history

# Output of 'npm pack'

*.tgz

# Yarn Integrity file

.yarn-integrity

# dotenv environment variable files

.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache

.parcel-cache

# Next.js build output

.next
out

# Nuxt.js build / generate output

.nuxt
dist

# Gatsby files
.cache/

# Comment in the public line in if your project uses Gatsby and not Next.js

# https://nextjs.org/blog/next-9-1#public-directory-support

# public

# vuepress build output

.vuepress/dist

# vuepress v2.x temp and cache directory

.temp
.cache

# Docusaurus cache and generated files

.docusaurus

# Serverless directories

.serverless/

# FuseBox cache

.fusebox/

# DynamoDB Local files

.dynamodb/

# TernJS port file

.tern-port

# Stores VSCode versions used for testing VSCode extensions

.vscode-test

# yarn v2

.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
.sqlite

# IntelliJ based IDEs
.idea

# Finder (MacOS) folder config
.DS_Store
tmp
*.so
*.o
*.a
*.dylib

build
7 changes: 6 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License (modified)

Copyright (c) 2023 W2Wizard
Copyright (c) 2023-24 W2Wizard

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -23,3 +23,8 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

EXCEPTIONS: ANY ORGANIZATION REPRESENTING 42 (Central) IS NOT ALLOWED TO USE THIS
UNLESS EXPLICIT PERMISSION IS GIVEN! ANY CODE COPIED, USED, ... FROM BEFORE OR AFTER THIS LICENSE WILL BE MET WITH A LEGAL RESPONSE!

HOWEVER THE ENTITY KNOWN AS CODAM CODING COLLEGE IS ALLOWED TO USE THIS SOFTWARE.
59 changes: 16 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@

RoboPeer is a **webserver** designed to grade your code in a safe environment. It allows you to submit code and have it "graded" without any worries about potential malicious activities.

This project was created using `bun init` in bun v1.1.4. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.

## 🎯 How it Works

The grading process involves comparing the output of the provided git repository (after compiling it) to a series of tests run with `bun:test`. RoboPeer then returns the results of these tests. With an appropriate status code.

RoboPeer can also grade direct code submissions via `/api/grade/git` and `/api/grade/single` respectively.
RoboPeer can also grade direct code submissions via `/evaluate/git`.

- `200` - All tests passed.
- `400` - Tests failed.
Expand All @@ -22,10 +24,23 @@ RoboPeer can also grade direct code submissions via `/api/grade/git` and `/api/g
## 🛠️ Installation
Requires [Bun.sh](https://bun.sh) to install dependencies.

To install dependencies:
```bash
bun install
```

To run:
```bash
bun run api-get # Fetches Dockers OpenAPI spec
bun run dev
```

To build:
```bash
bun run build # Outputs JS
bun run compile # Outputs a 98~mb binary
```

## 🚀 Usage

### Creating a Grading Project
Expand All @@ -35,11 +50,6 @@ To create a new reference project, use the following command:
bun run new < project-name >
```

### Dashboard

To view the dashboard, just visit [localhost](http://localhost:8000/) in your browser.
The dashboard merely displays statistics about the grading server itself and not much else.

### 🐳 Docker Setup

> **Note**: The docker image hasn't been configured properly yet to make sure the code isn't actually doing something stupid (deleting files, cd, ...) atm it uses Kornshell just a basic simple attempt but there are no serious measures whatsoever.
Expand All @@ -51,27 +61,7 @@ Build the Docker image:
#Git Image runner
docker build -t w2wizard/git_runner ./docker/git

#Single Image runner
docker build -t w2wizard/single_runner ./docker/single
```
### 🧰 Running the Server
Use the following command to run the server:
```bash
bun run start
# or
bun run ./src/main.ts
# or
bun build ./src/main.ts --compile --outfile robopeer
```
`Output`:
```
Registering /grade routes.
Connected to docker daemon.
Webserver: http://localhost:8000/
```

---

### 📨 Sending a Grading Request
The server by default run on http://localhost:8080. To send a request to it you can use the following curl command:
```bash
Expand All @@ -93,20 +83,3 @@ curl -XPOST -H "Content-type: application/json" -d '{
"language": "c"
}' 'http://localhost:8000/api/grade/single'
```

`Output`:
```bash
#Client
[+] Cloning git repository...
[+] Checking out commit 67dc80ae6a5d2c56a4305f5194672fe19130e705...
[+] Compiling code...
...
[+] Running tests...
```

```bash
#Server
[03/08/2023 14:33:47] [INFO] 📝 : Received request for: libft
[03/08/2023 14:33:47] [INFO] 📝 : Running tests for: libft => {"gitURL":"https://github.com/fbescodam/libft.git","branch":"master","commit":"67dc80ae6a5d2c56a4305f5194672fe19130e705"}
[03/08/2023 14:33:47] [INFO] 📝 : Container 8c2de65dcd4f exited with: 1
```
Binary file modified bun.lockb
Binary file not shown.
2 changes: 0 additions & 2 deletions docker/git/.dockerignore

This file was deleted.

Loading

0 comments on commit 8ba9f22

Please sign in to comment.