Compare commits

..

1 Commits

Author SHA256 Message Date
Frank Schreiner
9f67f43ac9 t: add Dockerfiles for building in OBS 2026-03-10 17:27:05 +01:00
6 changed files with 16 additions and 97 deletions

View File

@@ -1,8 +1,4 @@
MODULES := devel-importer utils/hujson utils/maintainer-update gitea-events-rabbitmq-publisher gitea_status_proxy group-review obs-forward-bot obs-staging-bot obs-status-service workflow-direct workflow-pr
.PHONY: build $(MODULES)
build: $(MODULES)
$(MODULES):
go build -C $@ -buildmode=pie
build:
for m in $(MODULES); do go build -C $$m -buildmode=pie || exit 1 ; done

View File

@@ -221,14 +221,11 @@ type Gitea interface {
GetPullRequests(org, project string) ([]*models.PullRequest, error)
GetCurrentUser() (*models.User, error)
SetCacheTTL(ttl time.Duration)
GetCacheTTL() time.Duration
}
type GiteaTransport struct {
transport *transport.Runtime
client *apiclient.GiteaAPI
cacheTTL time.Duration
}
func AllocateGiteaTransport(giteaUrl string) Gitea {
@@ -243,19 +240,10 @@ func AllocateGiteaTransport(giteaUrl string) Gitea {
r.transport.DefaultAuthentication = transport.BearerToken(giteaToken)
r.client = apiclient.New(r.transport, nil)
r.cacheTTL = time.Second * 5
return &r
}
func (gitea *GiteaTransport) SetCacheTTL(ttl time.Duration) {
gitea.cacheTTL = ttl
}
func (gitea *GiteaTransport) GetCacheTTL() time.Duration {
return gitea.cacheTTL
}
func (gitea *GiteaTransport) FetchMaintainershipFile(org, repo, branch string) ([]byte, string, error) {
return gitea.GetRepositoryFileContent(org, repo, branch, MaintainershipFile)
}
@@ -880,8 +868,8 @@ func (gitea *GiteaTransport) GetTimeline(org, repo string, idx int64) ([]*models
LastCachedTime = TimelineCache.data[0].Updated
}
// cache data
if TimelineCache.lastCheck.Add(gitea.cacheTTL).Compare(time.Now()) > 0 {
// cache data for 5 seconds
if TimelineCache.lastCheck.Add(time.Second*5).Compare(time.Now()) > 0 {
giteaTimelineCacheMutex.RUnlock()
return TimelineCache.data, nil
}

View File

@@ -2718,44 +2718,6 @@ func (c *MockGiteaFetchMaintainershipFileCall) DoAndReturn(f func(string, string
return c
}
// GetCacheTTL mocks base method.
func (m *MockGitea) GetCacheTTL() time.Duration {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetCacheTTL")
ret0, _ := ret[0].(time.Duration)
return ret0
}
// GetCacheTTL indicates an expected call of GetCacheTTL.
func (mr *MockGiteaMockRecorder) GetCacheTTL() *MockGiteaGetCacheTTLCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCacheTTL", reflect.TypeOf((*MockGitea)(nil).GetCacheTTL))
return &MockGiteaGetCacheTTLCall{Call: call}
}
// MockGiteaGetCacheTTLCall wrap *gomock.Call
type MockGiteaGetCacheTTLCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockGiteaGetCacheTTLCall) Return(arg0 time.Duration) *MockGiteaGetCacheTTLCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockGiteaGetCacheTTLCall) Do(f func() time.Duration) *MockGiteaGetCacheTTLCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockGiteaGetCacheTTLCall) DoAndReturn(f func() time.Duration) *MockGiteaGetCacheTTLCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// GetCommit mocks base method.
func (m *MockGitea) GetCommit(org, repo, sha string) (*models.Commit, error) {
m.ctrl.T.Helper()
@@ -3617,42 +3579,6 @@ func (c *MockGiteaResetTimelineCacheCall) DoAndReturn(f func(string, string, int
return c
}
// SetCacheTTL mocks base method.
func (m *MockGitea) SetCacheTTL(ttl time.Duration) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SetCacheTTL", ttl)
}
// SetCacheTTL indicates an expected call of SetCacheTTL.
func (mr *MockGiteaMockRecorder) SetCacheTTL(ttl any) *MockGiteaSetCacheTTLCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetCacheTTL", reflect.TypeOf((*MockGitea)(nil).SetCacheTTL), ttl)
return &MockGiteaSetCacheTTLCall{Call: call}
}
// MockGiteaSetCacheTTLCall wrap *gomock.Call
type MockGiteaSetCacheTTLCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockGiteaSetCacheTTLCall) Return() *MockGiteaSetCacheTTLCall {
c.Call = c.Call.Return()
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockGiteaSetCacheTTLCall) Do(f func(time.Duration)) *MockGiteaSetCacheTTLCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockGiteaSetCacheTTLCall) DoAndReturn(f func(time.Duration)) *MockGiteaSetCacheTTLCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// SetCommitStatus mocks base method.
func (m *MockGitea) SetCommitStatus(org, repo, hash string, status *models.CommitStatus) (*models.CommitStatus, error) {
m.ctrl.T.Helper()

View File

@@ -0,0 +1,7 @@
#!BuildTag: openbuildservice/gwf-test-basecontainer
#!UseOBSRepositories
FROM registry.suse.com/bci/bci-base:15.7
RUN zypper -n install binutils gawk git git-core git-lfs jq make openssh openssh-clients sqlite3 vim which
RUN zypper -n install autogits-gitea-events-rabbitmq-publisher autogits-obs-staging-bot autogits-workflow-pr gitea

View File

@@ -0,0 +1,5 @@
#!BuildTag: openbuildservice/gwf-client
#!UseOBSRepositories
FROM opensuse/tumbleweed
RUN zypper -n install podman podman-compose vim make python3-pytest python3-requests python3-pytest-dependency python3-pytest-httpserver

View File

@@ -1249,9 +1249,6 @@ func main() {
}
gitea := common.AllocateGiteaTransport(GiteaUrl)
if PollInterval < gitea.GetCacheTTL() {
gitea.SetCacheTTL(PollInterval)
}
user, err := gitea.GetCurrentUser()
if err != nil {