Files
MrixsCraft-server/.gitea/workflows/ci.yml
Vladimir Zagainov 08aaa7a3c8
Some checks failed
CI / lint (push) Failing after 7s
CI / test (push) Has been skipped
CI / build (push) Has been skipped
CI / docker (push) Has been skipped
fix: enable Go module cache in CI workflow
- Add cache: true to actions/setup-go@v5 so modules persist between steps
- Fixes "missing go.sum entry" error on go vet step
2026-05-30 19:45:52 +03:00

94 lines
2.0 KiB
YAML

name: CI
on:
push:
branches: ["**"]
pull_request:
branches: ["main"]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.25"
cache: true
- name: go vet
run: go vet ./...
- name: gofmt check
run: |
fmt=$(gofmt -l .)
if [ -n "$fmt" ]; then
echo "Files needing formatting:"
echo "$fmt"
exit 1
fi
test:
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.25"
cache: true
- name: Run tests
run: go test ./... -v -race -cover
build:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.25"
cache: true
- name: Build binary
run: go build -o mrixscraft-server ./cmd/server
- name: Upload artifact
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
with:
name: mrixscraft-server
path: mrixscraft-server
docker:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Gitea Registry
uses: docker/login-action@v3
with:
registry: gitea.mrixs.me
username: ${{ secrets.GITEA_USERNAME }}
password: ${{ secrets.GITEA_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
gitea.mrixs.me/Mrixs/MrixsCraft-server:latest
gitea.mrixs.me/Mrixs/MrixsCraft-server:${{ github.sha }}
cache-from: type=registry,ref=gitea.mrixs.me/Mrixs/MrixsCraft-server:latest
cache-to: type=inline