ci: use gitea actions instead of drone (#40)

Reviewed-on: FOCS-dev/JOJ3#40
This commit is contained in:
张泊明518370910136 2024-09-20 08:03:01 +08:00 committed by Boming Zhang
parent 2291264df0
commit 61dada5c40
GPG Key ID: D47306D7062CDA9D
4 changed files with 57 additions and 37 deletions

View File

@ -1,31 +0,0 @@
---
kind: pipeline
type: ssh
name: CI
server:
host: 111.186.59.59
user: drone
ssh_key:
from_secret: joj3-test
steps:
- name: prepare
commands:
- go env -w GOPROXY=https://goproxy.cn,direct
- whoami
- pwd
- env
- go version
- go env
- git status -v
- git log -1
- name: build
commands:
- make
- name: test
commands:
- make prepare-test
- make test
- name: store
commands:
- cp build/joj3 /home/drone/.local/bin/joj3

View File

@ -0,0 +1,44 @@
---
name: checks
on:
- push
- pull_request
jobs:
build:
container:
image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:ubuntu-latest
volumes:
- /home/actions/.ssh:/root/.ssh
steps:
- name: Check out repository code
uses: https://gitea.com/BoYanZh/checkout@focs
- name: Setup Go 1.23.1
run: |
wget -q https://studygolang.com/dl/golang/go1.23.1.linux-amd64.tar.gz
rm -rf /usr/local/go
tar -C /usr/local -xzf go1.23.1.linux-amd64.tar.gz
rm -rf go1.23.1.linux-amd64.tar.gz
echo "PATH=$PATH:/usr/local/go/bin:/root/go/bin" >> $GITHUB_ENV
- name: Display Go version
run: go version
- name: Prepare
run: |
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.io,direct
chown -R root:root /root/.ssh
- name: Setup golangci-lint
run: |
wget -q https://ghp.ci/https://github.com/golangci/golangci-lint/releases/download/v1.61.0/golangci-lint-1.61.0-linux-amd64.tar.gz
tar -C /tmp -xzf golangci-lint-1.61.0-linux-amd64.tar.gz
rm -rf golangci-lint-1.61.0-linux-amd64.tar.gz
mkdir -p /root/go/bin
mv /tmp/golangci-lint-1.61.0-linux-amd64/golangci-lint /root/go/bin
- name: Lint
run: make lint
- name: Build
run: make build
- name: Test
run: |
make prepare-test
make ci-test

View File

@ -1,4 +1,4 @@
.PHONY: all build clean prepare-test test
.PHONY: all build clean lint prepare-test test ci-test
BUILD_DIR = ./build
TMP_DIR = ./tmp
@ -15,9 +15,17 @@ clean:
rm -rf $(TMP_DIR)/*
rm -rf *.out
lint:
golangci-lint run
prepare-test:
git submodule update --init --remote
test:
./scripts/prepare_test_repos.sh $(TMP_DIR)
go test -coverprofile cover.out -v ./...
ci-test:
./scripts/prepare_test_repos.sh $(TMP_DIR)
./scripts/run_foreach_test_repos.sh $(TMP_DIR) "sed -i '2i \ \ \"sandboxExecServer\": \"172.17.0.1:5051\",' conf.json"
go test -coverprofile cover.out -v ./...

View File

@ -3,7 +3,6 @@ package stage
import (
"fmt"
"strconv"
"time"
"github.com/criyle/go-judge/envexec"
)
@ -126,8 +125,8 @@ func (r ExecutorResult) String() string {
Status Status
ExitStatus int
Error string
Time time.Duration
RunTime time.Duration
Time uint64
RunTime uint64
Memory envexec.Size
Files map[string]string
FileIDs map[string]string
@ -137,8 +136,8 @@ func (r ExecutorResult) String() string {
Status: r.Status,
ExitStatus: r.ExitStatus,
Error: r.Error,
Time: time.Duration(r.Time),
RunTime: time.Duration(r.RunTime),
Time: r.Time,
RunTime: r.RunTime,
Memory: envexec.Size(r.Memory),
Files: make(map[string]string),
FileIDs: r.FileIDs,