From d589182a0e7421a1bea4b6f2b36c66339e8a3aea Mon Sep 17 00:00:00 2001 From: lj Date: Thu, 23 Jul 2026 15:32:58 +0800 Subject: [PATCH] test --- .gitea/workflows/go-ci.yaml | 33 ++++++++++++++++++++++++--------- ci.sh | 17 +++++++++++++++++ 2 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 ci.sh diff --git a/.gitea/workflows/go-ci.yaml b/.gitea/workflows/go-ci.yaml index 38284be..770b705 100644 --- a/.gitea/workflows/go-ci.yaml +++ b/.gitea/workflows/go-ci.yaml @@ -1,17 +1,32 @@ -name: Go Build with Cache +name: Pure Run Build on: [push] jobs: build: runs-on: ubuntu-latest steps: - - name: 检出代码 - uses: actions/checkout@v4 + - name: 安装基础工具 + run: | + apt-get update + apt-get install -y git golang-go - - name: 设置 Go 并缓存 - uses: magnetikonline/action-golang-cache@v4 - with: - go-version-file: go.mod + - name: 克隆当前仓库 + run: | + git clone ${{ gitea.server_url }}/${{ gitea.repository }}.git . + git checkout ${{ gitea.sha }} - - name: 编译 - run: go build -o myapp . \ No newline at end of file + - name: 编译 Go 项目 + run: | + go mod tidy + go build -o myapp . + + - name: 运行测试 + run: | + go test ./... + + - name: 打印完成 + run: echo "构建完成 ✅" + + - name: 运行应用程序 + run: | + ./myapp \ No newline at end of file diff --git a/ci.sh b/ci.sh new file mode 100644 index 0000000..2e605cd --- /dev/null +++ b/ci.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -e + +apt-get update +apt-get install -y golang-go git + +git clone "${GITEA_SERVER_URL}/${GITEA_REPOSITORY}.git" /tmp/build +cd /tmp/build +git checkout "${GITEA_SHA}" + +go mod tidy +go test ./... +go build -o myapp . + +echo "构建完成 ✅" + +./myapp \ No newline at end of file