Compare commits

..

1 Commits

Author SHA1 Message Date
dd6b22258b
Merge f39eef51e6 into d627490c67 2023-12-14 23:41:32 +08:00
3 changed files with 142 additions and 25 deletions

123
.drone.yml Normal file
View File

@ -0,0 +1,123 @@
---
kind: pipeline
type: docker
name: Build Docker Image (s2oj-db)
trigger:
branch:
- master
steps:
- name: tags
image: alpine
commands:
- echo -n "latest, $DRONE_BRANCH, ${DRONE_COMMIT_SHA:0:8}" > .tags
- name: docker
image: plugins/docker
settings:
registry: git.m.ac
repo: git.m.ac/baoshuo/s2oj-db
context: db
dockerfile: db/Dockerfile
username: baoshuo
password:
from_secret: GITMAC_SECRET
cache_from: git.m.ac/baoshuo/s2oj-db:latest
when:
event: push
branch: master
---
kind: pipeline
type: docker
name: Build Docker Image (s2oj-judger)
trigger:
branch:
- master
steps:
- name: tags
image: alpine
commands:
- echo -n "latest, $DRONE_BRANCH, ${DRONE_COMMIT_SHA:0:8}" > .tags
- name: docker
image: plugins/docker
settings:
registry: git.m.ac
repo: git.m.ac/baoshuo/s2oj-judger
context: judger
dockerfile: judger/Dockerfile
username: baoshuo
password:
from_secret: GITMAC_SECRET
cache_from: git.m.ac/baoshuo/s2oj-judger:latest
when:
event: push
branch: master
---
kind: pipeline
type: docker
name: Build Docker Image (s2oj-remote-judger)
trigger:
branch:
- master
steps:
- name: tags
image: alpine
commands:
- echo -n "latest, $DRONE_BRANCH, ${DRONE_COMMIT_SHA:0:8}" > .tags
- name: docker
image: plugins/docker
settings:
registry: git.m.ac
repo: git.m.ac/baoshuo/s2oj-remote-judger
context: remote_judger
dockerfile: remote_judger/Dockerfile
username: baoshuo
password:
from_secret: GITMAC_SECRET
cache_from: git.m.ac/baoshuo/s2oj-remote-judger:latest
when:
event: push
branch: master
---
kind: pipeline
type: docker
name: Build Docker Image (s2oj-web)
trigger:
branch:
- master
steps:
- name: tags
image: alpine
commands:
- echo -n "latest, $DRONE_BRANCH, ${DRONE_COMMIT_SHA:0:7}" > .tags
- name: version
image: alpine
commands:
- sed -i "s/'s2oj-version' => 'dev'/'s2oj-version' => '${DRONE_COMMIT_SHA:0:7}'/g" web/app/.default-config.php
- name: docker
image: plugins/docker
settings:
registry: git.m.ac
repo: git.m.ac/baoshuo/s2oj-web
dockerfile: web/Dockerfile
username: baoshuo
password:
from_secret: GITMAC_SECRET
cache_from: git.m.ac/baoshuo/s2oj-web:latest
when:
event: push
branch: master

View File

@ -10,12 +10,9 @@ on:
workflow_dispatch: workflow_dispatch:
env: env:
REGISTRY: ${{ startsWith(github.server_url, 'https://github.com') && 'ghcr.io' || 'git.m.ac' }} REGISTRY: ghcr.io
IMAGE_BASENAME: ${{ github.repository }} IMAGE_BASENAME: ${{ github.repository }}
permissions:
packages: write
jobs: jobs:
build: build:
name: Build Image name: Build Image

View File

@ -10,23 +10,23 @@ const logger = new Logger('remote/atcoder');
const LANGS_MAP = { const LANGS_MAP = {
C: { C: {
name: 'C (GCC 12.2.0)', name: 'C (GCC 9.2.1)',
id: 5017, id: 4001,
comment: '//', comment: '//',
}, },
'C++': { 'C++': {
name: 'C++ 20 (GCC 12.2.0)', name: 'C++ (GCC 9.2.1)',
id: 5001, id: 4003,
comment: '//', comment: '//',
}, },
Pascal: { Pascal: {
name: 'Pascal (FPC 3.2.2)', name: 'Pascal (FPC 3.0.4)',
id: 5041, id: 4041,
comment: '//', comment: '//',
}, },
Python3: { Python3: {
name: 'Python (CPython 3.11.4)', name: 'Python (3.8.2)',
id: 5055, id: 4006,
comment: '#', comment: '#',
}, },
}; };
@ -193,8 +193,9 @@ export default class AtcoderProvider implements IBasicProvider {
} }
const [contestId, problemId] = parseProblemId(id); const [contestId, problemId] = parseProblemId(id);
const referer = `/contests/${contestId}/tasks/${problemId}`; const csrf = await this.getCsrfToken(
const csrf = await this.getCsrfToken(referer); `/contests/${contestId}/tasks/${problemId}`
);
logger.debug( logger.debug(
'Submitting', 'Submitting',
@ -207,14 +208,12 @@ export default class AtcoderProvider implements IBasicProvider {
await next({ status: 'Submitting to AtCoder...' }); await next({ status: 'Submitting to AtCoder...' });
// TODO: check submit time to ensure submission // TODO: check submit time to ensure submission
const res = await this.post(`/contests/${contestId}/submit`) const res = await this.post(`/contests/${contestId}/submit`).send({
.set('Referer', referer) csrf_token: csrf,
.send({ 'data.TaskScreenName': problemId,
'data.TaskScreenName': problemId, 'data.LanguageId': programType.id,
'data.LanguageId': programType.id, sourceCode: code,
sourceCode: code, });
csrf_token: csrf,
});
if (res.error) { if (res.error) {
await end({ await end({
@ -234,9 +233,7 @@ export default class AtcoderProvider implements IBasicProvider {
const { text: status, header: status_header } = await this.get( const { text: status, header: status_header } = await this.get(
`/contests/${contestId}/submissions/me` `/contests/${contestId}/submissions/me`
) ).retry(3);
.set('Referer', referer)
.retry(3);
if (status_header['set-cookie']) { if (status_header['set-cookie']) {
this.cookie = status_header['set-cookie']; this.cookie = status_header['set-cookie'];