Compare commits
6 Commits
forgejo
...
forgejo-ci
Author | SHA1 | Date |
---|---|---|
Loïc Dachary | d3b008fab9 | |
Loïc Dachary | e2426ca0f2 | |
Loïc Dachary | 0c7a1bf11a | |
Loïc Dachary | 446e235742 | |
Loïc Dachary | 054925327f | |
Loïc Dachary | 6fddbf49f0 |
|
@ -0,0 +1,32 @@
|
||||||
|
platform: linux/amd64
|
||||||
|
|
||||||
|
workspace:
|
||||||
|
base: /go
|
||||||
|
path: src/codeberg/gitea
|
||||||
|
|
||||||
|
pipeline:
|
||||||
|
deps-backend:
|
||||||
|
image: golang:1.19
|
||||||
|
pull: true
|
||||||
|
commands:
|
||||||
|
- make deps-backend
|
||||||
|
|
||||||
|
security-check:
|
||||||
|
image: golang:1.19
|
||||||
|
pull: true
|
||||||
|
commands:
|
||||||
|
- make security-check
|
||||||
|
|
||||||
|
lint-backend:
|
||||||
|
image: gitea/test_env:linux-amd64
|
||||||
|
pull: true
|
||||||
|
environment:
|
||||||
|
- TAGS=bindata sqlite sqlite_unlock_notify
|
||||||
|
- GOSUMDB=sum.golang.org
|
||||||
|
commands:
|
||||||
|
- make lint-backend
|
||||||
|
|
||||||
|
checks-backend:
|
||||||
|
image: golang:1.19
|
||||||
|
commands:
|
||||||
|
- make --always-make checks-backend
|
|
@ -0,0 +1,28 @@
|
||||||
|
platform: linux/amd64
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- testing-amd64
|
||||||
|
|
||||||
|
pipeline:
|
||||||
|
fetch-tags:
|
||||||
|
image: docker:git
|
||||||
|
pull: true
|
||||||
|
commands:
|
||||||
|
- git config --add safe.directory '*'
|
||||||
|
- git fetch --tags --force
|
||||||
|
|
||||||
|
publish:
|
||||||
|
image: woodpeckerci/plugin-docker-buildx
|
||||||
|
pull: true
|
||||||
|
settings:
|
||||||
|
platforms: linux/amd64
|
||||||
|
registry:
|
||||||
|
from_secret: domain
|
||||||
|
tag: ${CI_COMMIT_TAG##v}
|
||||||
|
repo: ${CI_REPO_LINK##https://}
|
||||||
|
password:
|
||||||
|
from_secret: releaseteamtoken
|
||||||
|
username:
|
||||||
|
from_secret: releaseteamuser
|
||||||
|
when:
|
||||||
|
event: tag
|
|
@ -0,0 +1,65 @@
|
||||||
|
platform: linux/amd64
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- testing-amd64
|
||||||
|
|
||||||
|
workspace:
|
||||||
|
base: /source
|
||||||
|
path: /
|
||||||
|
|
||||||
|
pipeline:
|
||||||
|
fetch-tags:
|
||||||
|
image: docker:git
|
||||||
|
pull: true
|
||||||
|
commands:
|
||||||
|
- git config --add safe.directory '*'
|
||||||
|
- git fetch --tags --force
|
||||||
|
|
||||||
|
deps-frontend:
|
||||||
|
image: node:18
|
||||||
|
pull: true
|
||||||
|
commands:
|
||||||
|
- make deps-frontend
|
||||||
|
|
||||||
|
deps-backend:
|
||||||
|
image: golang:1.19
|
||||||
|
pull: true
|
||||||
|
commands:
|
||||||
|
- make deps-backend
|
||||||
|
|
||||||
|
static:
|
||||||
|
image: techknowlogick/xgo:go-1.19.x
|
||||||
|
pull: true
|
||||||
|
commands:
|
||||||
|
- curl -sL https://deb.nodesource.com/setup_16.x | bash - && apt-get -qqy install nodejs
|
||||||
|
- export PATH=$PATH:$GOPATH/bin
|
||||||
|
- make CI=true LINUX_ARCHS=linux/amd64,linux/arm64 release
|
||||||
|
environment:
|
||||||
|
TAGS: bindata sqlite sqlite_unlock_notify
|
||||||
|
DEBIAN_FRONTEND: noninteractive
|
||||||
|
|
||||||
|
gpg-sign:
|
||||||
|
image: plugins/gpgsign:1
|
||||||
|
pull: true
|
||||||
|
settings:
|
||||||
|
detach_sign: true
|
||||||
|
excludes:
|
||||||
|
- "dist/release/*.sha256"
|
||||||
|
files:
|
||||||
|
- "dist/release/*"
|
||||||
|
key:
|
||||||
|
from_secret: releaseteamgpg
|
||||||
|
|
||||||
|
release:
|
||||||
|
image: golang:1.19
|
||||||
|
commands:
|
||||||
|
- curl -sL https://dl.gitea.io/tea/0.9.0/tea-0.9.0-linux-amd64 > /bin/tea && chmod +x /bin/tea
|
||||||
|
- REMOTE=$(echo $CI_REPO_LINK | sed -e 's|.*://||' -e 's|/.*||')
|
||||||
|
- GITEA_SERVER_URL=$CI_REPO_LINK GITEA_SERVER_TOKEN=$RELEASETEAMTOKEN tea login add --name $RELEASETEAMUSER --url $REMOTE
|
||||||
|
- ASSETS=$(ls dist/release/* | sed -e 's/^/-a /')
|
||||||
|
- tea release create $ASSETS --tag $CI_COMMIT_TAG --title $CI_COMMIT_TAG
|
||||||
|
when:
|
||||||
|
event: tag
|
||||||
|
secrets:
|
||||||
|
- releaseteamtoken
|
||||||
|
- releaseteamuser
|
|
@ -0,0 +1,63 @@
|
||||||
|
platform: linux/amd64
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- compliance
|
||||||
|
|
||||||
|
workspace:
|
||||||
|
base: /go
|
||||||
|
path: src/codeberg/gitea
|
||||||
|
|
||||||
|
pipeline:
|
||||||
|
fetch-tags:
|
||||||
|
image: docker:git
|
||||||
|
pull: true
|
||||||
|
commands:
|
||||||
|
- git config --add safe.directory '*'
|
||||||
|
- git fetch --tags --force
|
||||||
|
|
||||||
|
deps-backend:
|
||||||
|
image: golang:1.19
|
||||||
|
pull: true
|
||||||
|
commands:
|
||||||
|
- make deps-backend
|
||||||
|
|
||||||
|
tag-pre-condition:
|
||||||
|
image: drone/git
|
||||||
|
pull: true
|
||||||
|
commands:
|
||||||
|
- git update-ref refs/heads/tag_test ${CI_COMMIT_SHA}
|
||||||
|
|
||||||
|
prepare-test-env:
|
||||||
|
image: gitea/test_env:linux-amd64
|
||||||
|
pull: true
|
||||||
|
commands:
|
||||||
|
- ./build/test-env-prepare.sh
|
||||||
|
|
||||||
|
build:
|
||||||
|
image: gitea/test_env:linux-amd64
|
||||||
|
environment:
|
||||||
|
- GOSUMDB=sum.golang.org
|
||||||
|
- TAGS=bindata sqlite sqlite_unlock_notify
|
||||||
|
commands:
|
||||||
|
- su gitea -c './build/test-env-check.sh'
|
||||||
|
- su gitea -c 'make backend'
|
||||||
|
|
||||||
|
unit-test:
|
||||||
|
image: gitea/test_env:linux-amd64
|
||||||
|
environment:
|
||||||
|
- TAGS=bindata sqlite sqlite_unlock_notify
|
||||||
|
- RACE_ENABLED=true
|
||||||
|
secrets:
|
||||||
|
- github_read_token
|
||||||
|
commands:
|
||||||
|
- su gitea -c 'make unit-test-coverage test-check'
|
||||||
|
|
||||||
|
# test-sqlite:
|
||||||
|
# image: gitea/test_env:linux-amd64
|
||||||
|
# environment:
|
||||||
|
# - USE_REPO_TEST_DIR=1
|
||||||
|
# - GOPROXY=off
|
||||||
|
# - TAGS=bindata gogit sqlite sqlite_unlock_notify
|
||||||
|
# - TEST_TAGS=bindata gogit sqlite sqlite_unlock_notify
|
||||||
|
# commands:
|
||||||
|
# - su gitea -c 'timeout -s ABRT 120m make test-sqlite-migration test-sqlite'
|
14
Dockerfile
14
Dockerfile
|
@ -1,5 +1,5 @@
|
||||||
#Build stage
|
#Build stage
|
||||||
FROM golang:1.19-alpine3.16 AS build-env
|
FROM codeberg.org/forgejo/golang:1.19-alpine3.16 AS build-env
|
||||||
|
|
||||||
ARG GOPROXY
|
ARG GOPROXY
|
||||||
ENV GOPROXY ${GOPROXY:-direct}
|
ENV GOPROXY ${GOPROXY:-direct}
|
||||||
|
@ -23,8 +23,8 @@ RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
|
||||||
# Begin env-to-ini build
|
# Begin env-to-ini build
|
||||||
RUN go build contrib/environment-to-ini/environment-to-ini.go
|
RUN go build contrib/environment-to-ini/environment-to-ini.go
|
||||||
|
|
||||||
FROM alpine:3.16
|
FROM codeberg.org/forgejo/alpine:3.16.3
|
||||||
LABEL maintainer="maintainers@gitea.io"
|
LABEL maintainer="contact@forgejo.org"
|
||||||
|
|
||||||
EXPOSE 22 3000
|
EXPOSE 22 3000
|
||||||
|
|
||||||
|
@ -64,5 +64,9 @@ CMD ["/bin/s6-svscan", "/etc/s6"]
|
||||||
COPY docker/root /
|
COPY docker/root /
|
||||||
COPY --from=build-env /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea
|
COPY --from=build-env /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea
|
||||||
COPY --from=build-env /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini
|
COPY --from=build-env /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini
|
||||||
RUN chmod 755 /usr/bin/entrypoint /app/gitea/gitea /usr/local/bin/gitea /usr/local/bin/environment-to-ini
|
#
|
||||||
RUN chmod 755 /etc/s6/gitea/* /etc/s6/openssh/* /etc/s6/.s6-svscan/*
|
# s/755/775/ in the following is to avoid the corrupted layer 4f4fb700ef54
|
||||||
|
# https://codeberg.org/Codeberg/Community/issues/800#issue-210309
|
||||||
|
#
|
||||||
|
RUN chmod 775 /usr/bin/entrypoint /app/gitea/gitea /usr/local/bin/gitea /usr/local/bin/environment-to-ini
|
||||||
|
RUN chmod 775 /etc/s6/gitea/* /etc/s6/openssh/* /etc/s6/.s6-svscan/*
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
FROM golang:1.19-alpine3.16
|
||||||
|
|
||||||
|
RUN pwd
|
||||||
|
|
10
Makefile
10
Makefile
|
@ -83,7 +83,7 @@ ifneq ($(DRONE_TAG),)
|
||||||
GITEA_VERSION ?= $(VERSION)
|
GITEA_VERSION ?= $(VERSION)
|
||||||
else
|
else
|
||||||
ifneq ($(DRONE_BRANCH),)
|
ifneq ($(DRONE_BRANCH),)
|
||||||
VERSION ?= $(subst release/v,,$(DRONE_BRANCH))
|
VERSION ?= $(shell echo $(DRONE_BRANCH) | sed -e 's|v\([0-9.][0-9.]*\)/.*|\1|')
|
||||||
else
|
else
|
||||||
VERSION ?= main
|
VERSION ?= main
|
||||||
endif
|
endif
|
||||||
|
@ -751,7 +751,7 @@ $(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ)
|
||||||
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
|
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
|
||||||
|
|
||||||
.PHONY: release
|
.PHONY: release
|
||||||
release: frontend generate release-windows release-linux release-darwin release-copy release-compress vendor release-sources release-docs release-check
|
release: frontend generate release-linux release-copy release-compress vendor release-sources release-check
|
||||||
|
|
||||||
$(DIST_DIRS):
|
$(DIST_DIRS):
|
||||||
mkdir -p $(DIST_DIRS)
|
mkdir -p $(DIST_DIRS)
|
||||||
|
@ -768,7 +768,7 @@ endif
|
||||||
|
|
||||||
.PHONY: release-linux
|
.PHONY: release-linux
|
||||||
release-linux: | $(DIST_DIRS)
|
release-linux: | $(DIST_DIRS)
|
||||||
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets '$(LINUX_ARCHS)' -out gitea-$(VERSION) .
|
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets '$(LINUX_ARCHS)' -out forgejo-$(VERSION) .
|
||||||
ifeq ($(CI),true)
|
ifeq ($(CI),true)
|
||||||
cp /build/* $(DIST)/binaries
|
cp /build/* $(DIST)/binaries
|
||||||
endif
|
endif
|
||||||
|
@ -798,8 +798,8 @@ release-sources: | $(DIST_DIRS)
|
||||||
# bsdtar needs a ^ to prevent matching subdirectories
|
# bsdtar needs a ^ to prevent matching subdirectories
|
||||||
$(eval EXCL := --exclude=$(shell tar --help | grep -q bsdtar && echo "^")./)
|
$(eval EXCL := --exclude=$(shell tar --help | grep -q bsdtar && echo "^")./)
|
||||||
# use transform to a add a release-folder prefix; in bsdtar the transform parameter equivalent is -s
|
# use transform to a add a release-folder prefix; in bsdtar the transform parameter equivalent is -s
|
||||||
$(eval TRANSFORM := $(shell tar --help | grep -q bsdtar && echo "-s '/^./gitea-src-$(VERSION)/'" || echo "--transform 's|^./|gitea-src-$(VERSION)/|'"))
|
$(eval TRANSFORM := $(shell tar --help | grep -q bsdtar && echo "-s '/^./forgejo-src-$(VERSION)/'" || echo "--transform 's|^./|forgejo-src-$(VERSION)/|'"))
|
||||||
tar $(addprefix $(EXCL),$(TAR_EXCLUDES)) $(TRANSFORM) -czf $(DIST)/release/gitea-src-$(VERSION).tar.gz .
|
tar $(addprefix $(EXCL),$(TAR_EXCLUDES)) $(TRANSFORM) -czf $(DIST)/release/forgejo-src-$(VERSION).tar.gz .
|
||||||
rm -f $(STORED_VERSION_FILE)
|
rm -f $(STORED_VERSION_FILE)
|
||||||
|
|
||||||
.PHONY: release-docs
|
.PHONY: release-docs
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a MIT-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package stats
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"path/filepath"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"code.gitea.io/gitea/models/db"
|
|
||||||
repo_model "code.gitea.io/gitea/models/repo"
|
|
||||||
"code.gitea.io/gitea/models/unittest"
|
|
||||||
"code.gitea.io/gitea/modules/queue"
|
|
||||||
"code.gitea.io/gitea/modules/setting"
|
|
||||||
|
|
||||||
_ "code.gitea.io/gitea/models"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"gopkg.in/ini.v1"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
|
||||||
unittest.MainTest(m, &unittest.TestOptions{
|
|
||||||
GiteaRootPath: filepath.Join("..", "..", ".."),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRepoStatsIndex(t *testing.T) {
|
|
||||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
|
||||||
setting.Cfg = ini.Empty()
|
|
||||||
|
|
||||||
setting.NewQueueService()
|
|
||||||
|
|
||||||
err := Init()
|
|
||||||
assert.NoError(t, err)
|
|
||||||
|
|
||||||
repo, err := repo_model.GetRepositoryByID(1)
|
|
||||||
assert.NoError(t, err)
|
|
||||||
|
|
||||||
err = UpdateRepoIndexer(repo)
|
|
||||||
assert.NoError(t, err)
|
|
||||||
|
|
||||||
queue.GetManager().FlushAll(context.Background(), 5*time.Second)
|
|
||||||
|
|
||||||
status, err := repo_model.GetIndexerStatus(db.DefaultContext, repo, repo_model.RepoIndexerTypeStats)
|
|
||||||
assert.NoError(t, err)
|
|
||||||
assert.Equal(t, "65f1bf27bc3bf70f64657658635e66094edbcb4d", status.CommitSha)
|
|
||||||
langs, err := repo_model.GetTopLanguageStats(repo, 5)
|
|
||||||
assert.NoError(t, err)
|
|
||||||
assert.Empty(t, langs)
|
|
||||||
}
|
|
Loading…
Reference in New Issue