Compare commits

...

9 commits

Author SHA1 Message Date
Loïc Dachary 9d9afd2c18
do not run on soft-fork branches 2022-12-11 11:36:29 +01:00
Loïc Dachary 758013b435 [CI] verify the Forgejo binaries can actually run
Signed-off-by: Loïc Dachary <loic@dachary.org>
2022-12-10 08:30:40 +00:00
Loïc Dachary 5f9f5f3c91
implementation: publish container image
* build and publish in https://codeberg.org/forgejo-integration
* pull from https://codeberg.org/forgejo-integration
* build and publish in https://codeberg.org/forgejo
2022-12-10 00:20:24 +01:00
Loïc Dachary e0c205082d
workaround: deactivate test-sqlite because it is too slow
Refs: https://codeberg.org/forgejo/forgejo/issues/31

Signed-off-by: Loïc Dachary <loic@dachary.org>
2022-12-03 10:54:04 +01:00
Loïc Dachary 9a69ea5d2d
workaround: Dockerfile for codeberg.org corrupted container images
https://codeberg.org/forgejo/forgejo/issues/26
https://codeberg.org/Codeberg/Community/issues/800

sed -i -e 's|^FROM.*golang.*|FROM codeberg.org/forgejo/golang:1.19-alpine3.17 AS build-env|' Dockerfile
sed -i -e 's|^FROM.*alpine:.*|FROM codeberg.org/forgejo/alpine:3.17.0|' Dockerfile

Signed-off-by: Loïc Dachary <loic@dachary.org>
2022-12-03 10:53:49 +01:00
Loïc Dachary 7fb4e9c4de
implementation: forgejo container images
Signed-off-by: Loïc Dachary <loic@dachary.org>
2022-12-03 10:51:39 +01:00
Loïc Dachary 41fabe9784
implementation: Woodpecker based CI
Signed-off-by: Loïc Dachary <loic@dachary.org>
2022-12-03 10:49:54 +01:00
Loïc Dachary 19d76aa497
implementation: publish forgejo- binaries instead of gitea-
Signed-off-by: Loïc Dachary <loic@dachary.org>
2022-12-03 10:49:54 +01:00
Loïc Dachary 543535ac0f
upstream: remove unstable test
Fixes: https://codeberg.org/forgejo/forgejo/issues/30

Signed-off-by: Loïc Dachary <loic@dachary.org>
2022-12-03 10:49:51 +01:00
7 changed files with 232 additions and 63 deletions

View file

@ -0,0 +1,35 @@
platform: linux/amd64
branches:
exclude: [ main, release/*, soft-fork/*/*, doc-* ]
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

View file

@ -0,0 +1,47 @@
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-integration:
image: woodpeckerci/plugin-docker-buildx
pull: true
settings:
platforms: linux/amd64
registry:
from_secret: domain
tag: ${CI_COMMIT_TAG##v}
repo: codeberg.org/forgejo-integration/forgejo
password:
from_secret: releaseteamtoken
username:
from_secret: releaseteamuser
when:
event: tag
publish:
image: woodpeckerci/plugin-docker-buildx
commands:
- apk --update --no-cache add coredns
- ( echo ".:53 {" ; echo " forward . /etc/resolv.conf"; echo "}" ) > /etc/coredns/Corefile
- coredns -conf /etc/coredns/Corefile &
- /usr/local/bin/dockerd --data-root /var/lib/docker --host=unix:///var/run/docker.sock --dns 172.17.0.3 &
- for i in $$(seq 60) ; do DOCKER_HOST=unix:///var/run/docker.sock docker version && break ; sleep 1 ; done
- docker pull codeberg.org/forgejo-integration/forgejo':'${CI_COMMIT_TAG##v}
- docker login -p "$RELEASETEAMTOKEN" -u "$RELEASETEAMUSER" $DOMAIN
- docker tag codeberg.org/forgejo-integration/forgejo':'${CI_COMMIT_TAG##v} ${CI_REPO_LINK##https://}':'${CI_COMMIT_TAG##v}
- docker push ${CI_REPO_LINK##https://}':'${CI_COMMIT_TAG##v}
secrets:
- releaseteamtoken
- releaseteamuser
- domain
when:
event: tag

View file

@ -0,0 +1,73 @@
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
verifyruns:
image: golang:1.19
commands:
- ./dist/release/forgejo-*-amd64 --version | grep 'built with'
- apt-get update
- apt-get install -y qemu-user-static wget
- /usr/bin/qemu-aarch64-static ./dist/release/forgejo-*-arm64 --version | grep 'built with'
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

View file

@ -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'

View file

@ -1,5 +1,5 @@
#Build stage
FROM golang:1.19-alpine3.17 AS build-env
FROM codeberg.org/forgejo/golang:1.19-alpine3.17 AS build-env
ARG GOPROXY
ENV GOPROXY ${GOPROXY:-direct}
@ -23,8 +23,8 @@ RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
# Begin env-to-ini build
RUN go build contrib/environment-to-ini/environment-to-ini.go
FROM alpine:3.17
LABEL maintainer="maintainers@gitea.io"
FROM codeberg.org/forgejo/alpine:3.17.0
LABEL maintainer="contact@forgejo.org"
EXPOSE 22 3000
@ -64,5 +64,9 @@ CMD ["/bin/s6-svscan", "/etc/s6"]
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/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/*

View file

@ -83,7 +83,7 @@ ifneq ($(DRONE_TAG),)
GITEA_VERSION ?= $(VERSION)
else
ifneq ($(DRONE_BRANCH),)
VERSION ?= $(subst release/v,,$(DRONE_BRANCH))
VERSION ?= $(shell echo $(DRONE_BRANCH) | sed -e 's|v\([0-9.][0-9.]*\)/.*|\1|')
else
VERSION ?= main
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 $@
.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):
mkdir -p $(DIST_DIRS)
@ -768,7 +768,7 @@ endif
.PHONY: release-linux
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)
cp /build/* $(DIST)/binaries
endif
@ -798,8 +798,8 @@ release-sources: | $(DIST_DIRS)
# bsdtar needs a ^ to prevent matching subdirectories
$(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
$(eval TRANSFORM := $(shell tar --help | grep -q bsdtar && echo "-s '/^./gitea-src-$(VERSION)/'" || echo "--transform 's|^./|gitea-src-$(VERSION)/|'"))
tar $(addprefix $(EXCL),$(TAR_EXCLUDES)) $(TRANSFORM) -czf $(DIST)/release/gitea-src-$(VERSION).tar.gz .
$(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/forgejo-src-$(VERSION).tar.gz .
rm -f $(STORED_VERSION_FILE)
.PHONY: release-docs

View file

@ -1,53 +0,0 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
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(db.DefaultContext, 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)
}