Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tibuild): bump versions for golang and nodejs #35

Merged
merged 3 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
filters: |
cloudevents-server:
- 'cloudevents-server/**'
tibuild:
- 'tibuild/**'

# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
Expand Down Expand Up @@ -70,3 +72,12 @@ jobs:
--platform ${{ matrix.platform }} \
--profile local-docker \
--default-repo ghcr.io/pingcap-qe/ee-apps
- name: Build tibuild image
if: steps.changes.outputs.tibuild == 'true'
working-directory: tibuild
run: |
skaffold build \
--push=false \
--platform ${{ matrix.platform }} \
--profile local-docker \
--default-repo ghcr.io/pingcap-qe/ee-apps
9 changes: 9 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ jobs:
filters: |
cloudevents-server:
- 'cloudevents-server/**'
tibuild:
- 'tibuild/**'

# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
Expand Down Expand Up @@ -74,3 +76,10 @@ jobs:
skaffold build \
--profile local-docker \
--default-repo ghcr.io/pingcap-qe/ee-apps
- name: Publish tibuild image
if: steps.changes.outputs.tibuild == 'true'
working-directory: tibuild
run: |
skaffold build \
--profile local-docker \
--default-repo ghcr.io/pingcap-qe/ee-apps
6 changes: 6 additions & 0 deletions OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
approvers:
- wuhuizuo

reviewers:
- purelind
- lijie0123
26 changes: 26 additions & 0 deletions tibuild/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copy 'website/' contents(not entire folder) into .(/webapp/) and build React
FROM node:20.9.0 as webbuilder
WORKDIR /webapp
COPY website/ .
RUN --mount=type=cache,target=/webapp/node_modules npm install && yarn build

# Copy whole project's contents(not entire folder) into .(/goapp/) and build Golang
FROM golang:1.21.5 as serverbuilder
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOPROXY=https://goproxy.cn,direct
WORKDIR /goapp
COPY . .
RUN --mount=type=cache,target=/go/pkg/mod go test ./... && go build -o ./bin/tibuild ./cmd/tibuild


FROM debian:12
LABEL org.opencontainers.image.licenses="MIT"
LABEL org.opencontainers.image.source="https://github.com/PingCAP-QE/ee-apps"

WORKDIR /app
COPY --from=webbuilder /webapp/build/ ./website/build/
COPY --from=serverbuilder /goapp/bin/tibuild ./bin/tibuild

CMD ["/app/bin/tibuild"]

2 changes: 1 addition & 1 deletion tibuild/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ DOCKER_ADDRESS = hub.pingcap.net
DOCKER_NAME = tibuild/tibuild
DOCKER_TAG ?= $(shell git describe --dirty --always)
DOCKER_IMG ?= ${DOCKER_ADDRESS}/${DOCKER_NAME}:${DOCKER_TAG}
DOCKER_FILE = ./deployments/docker/Dockerfile
DOCKER_FILE = ./Dockerfile
K8S_METADATA_NAME = tibuild
K8S_DEPLOYMENT_FILE = ./deployments/kubernetes/
TIBUILD_MAIN_FILE = ./cmd/tibuild/
Expand Down
15 changes: 8 additions & 7 deletions tibuild/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ package api
import (
"context"
"net/http"
"tibuild/commons/configs"
"tibuild/commons/database"
"tibuild/internalpkg/controller"
controllers "tibuild/pkg/rest/controller"
"tibuild/pkg/rest/service"

_ "tibuild/docs"

"github.com/gin-contrib/requestid"
"github.com/gin-contrib/static"
"github.com/gin-gonic/gin"
swaggerfiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"

"github.com/PingCAP-QE/ee-apps/tibuild/commons/configs"
"github.com/PingCAP-QE/ee-apps/tibuild/commons/database"
"github.com/PingCAP-QE/ee-apps/tibuild/internalpkg/controller"
controllers "github.com/PingCAP-QE/ee-apps/tibuild/pkg/rest/controller"
"github.com/PingCAP-QE/ee-apps/tibuild/pkg/rest/service"

_ "github.com/PingCAP-QE/ee-apps/tibuild/docs"
)

// Create gin-routers
Expand Down
5 changes: 3 additions & 2 deletions tibuild/cmd/branch_create_helper/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package main
import (
"context"
"fmt"
"tibuild/pkg/rest/controller"
"tibuild/pkg/rest/service"

"github.com/PingCAP-QE/ee-apps/tibuild/pkg/rest/controller"
"github.com/PingCAP-QE/ee-apps/tibuild/pkg/rest/service"
)

func main() {
Expand Down
5 changes: 3 additions & 2 deletions tibuild/cmd/tag_create_helper/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package main
import (
"context"
"fmt"
"tibuild/pkg/rest/controller"
"tibuild/pkg/rest/service"

"github.com/PingCAP-QE/ee-apps/tibuild/pkg/rest/controller"
"github.com/PingCAP-QE/ee-apps/tibuild/pkg/rest/service"
)

func main() {
Expand Down
6 changes: 3 additions & 3 deletions tibuild/cmd/tibuild/main.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package main

import (
"tibuild/api"
"tibuild/commons/configs"
"tibuild/commons/database"
"github.com/PingCAP-QE/ee-apps/tibuild/api"
"github.com/PingCAP-QE/ee-apps/tibuild/commons/configs"
"github.com/PingCAP-QE/ee-apps/tibuild/commons/database"
)

func main() {
Expand Down
6 changes: 4 additions & 2 deletions tibuild/commons/database/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ package database

import (
"fmt"
"time"

"gorm.io/driver/mysql"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"tibuild/commons/configs"
"time"

"github.com/PingCAP-QE/ee-apps/tibuild/commons/configs"
)

// Mysql handler infomation
Expand Down
31 changes: 0 additions & 31 deletions tibuild/deployments/docker/Dockerfile

This file was deleted.

4 changes: 2 additions & 2 deletions tibuild/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module tibuild
module github.com/PingCAP-QE/ee-apps/tibuild

go 1.17
go 1.21

require (
github.com/DATA-DOG/go-sqlmock v1.5.0
Expand Down
10 changes: 0 additions & 10 deletions tibuild/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/goccy/go-json v0.10.0 h1:mXKd9Qw4NuzShiRlOXKews24ufknHO7gx30lsDyokKA=
github.com/goccy/go-json v0.10.0/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
Expand Down Expand Up @@ -100,7 +99,6 @@ github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down Expand Up @@ -148,7 +146,6 @@ github.com/swaggo/swag v1.8.1/go.mod h1:ugemnJsPZm/kRwFUnzBlbHRd0JY9zE1M4F+uy2pA
github.com/swaggo/swag v1.8.9 h1:kHtaBe/Ob9AZzAANfcn5c6RyCke9gG9QpH0jky0I/sA=
github.com/swaggo/swag v1.8.9/go.mod h1:ezQVUUhly8dludpVk+/PuwJWvLLanB13ygV5Pr9enSk=
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo=
github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
Expand Down Expand Up @@ -178,13 +175,11 @@ golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qx
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw=
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand All @@ -200,22 +195,17 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA=
golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k=
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand Down
3 changes: 1 addition & 2 deletions tibuild/gojenkins/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"os"
"path"
)
Expand Down Expand Up @@ -62,7 +61,7 @@ func (a Artifact) Save(ctx context.Context, path string) (bool, error) {
Warning.Println("Local Copy already exists, Overwriting...")
}

err = ioutil.WriteFile(path, data, 0644)
err = os.WriteFile(path, data, 0644)
a.validateDownload(ctx, path)

if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions tibuild/gojenkins/jenkins.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,7 @@ func (j *Jenkins) Poll(ctx context.Context) (int, error) {
// After creating an instance call init method.
func CreateJenkins(client *http.Client, base string, auth ...interface{}) *Jenkins {
j := &Jenkins{}
if strings.HasSuffix(base, "/") {
base = base[:len(base)-1]
}
base = strings.TrimSuffix(base, "/")
j.Server = base
j.Requester = &Requester{Base: base, SslVerify: true, Client: client}
if j.Requester.Client == nil {
Expand Down
3 changes: 1 addition & 2 deletions tibuild/gojenkins/jenkins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package gojenkins

import (
"context"
"io/ioutil"
"os"
"testing"
"time"
Expand Down Expand Up @@ -377,7 +376,7 @@ func TestConcurrentRequests(t *testing.T) {
}

func getFileAsString(path string) string {
buf, err := ioutil.ReadFile("_tests/" + path)
buf, err := os.ReadFile("_tests/" + path)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion tibuild/gojenkins/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (j *Job) GetLastCompletedBuild(ctx context.Context) (*Build, error) {
}

func (j *Job) GetBuildsFields(ctx context.Context, fields []string, custom interface{}) error {
if fields == nil || len(fields) == 0 {
if len(fields) == 0 {
return fmt.Errorf("one or more field value needs to be specified")
}
// limit overhead using builds instead of allBuilds, which returns the last 100 build
Expand Down
6 changes: 3 additions & 3 deletions tibuild/gojenkins/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ type Label struct {
Base string
}

type MODE string
type Mode string

const (
NORMAL MODE = "NORMAL"
EXCLUSIVE = "EXCLUSIVE"
NORMAL Mode = "NORMAL"
EXCLUSIVE Mode = "EXCLUSIVE"
)

type LabelNode struct {
Expand Down
2 changes: 1 addition & 1 deletion tibuild/gojenkins/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (pr *PipelineRun) GetPendingInputActions(ctx context.Context) (PIAs []Pipel
}

func (pr *PipelineRun) GetArtifacts(ctx context.Context) (artifacts []PipelineArtifact, err error) {
artifacts = make([]PipelineArtifact, 0, 0)
artifacts = make([]PipelineArtifact, 0)
href := pr.Base + "/wfapi/artifacts"
_, err = pr.Job.Jenkins.Requester.GetJSON(ctx, href, artifacts, nil)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions tibuild/gojenkins/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"log"
"mime/multipart"
"net/http"
Expand Down Expand Up @@ -255,7 +254,7 @@ func (r *Requester) Do(ctx context.Context, ar *APIRequest, responseStruct inter
func (r *Requester) ReadRawResponse(response *http.Response, responseStruct interface{}) (*http.Response, error) {
defer response.Body.Close()

content, err := ioutil.ReadAll(response.Body)
content, err := io.ReadAll(response.Body)
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package controller

import (
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"net/http"
"strings"
"tibuild/commons/database"

"github.com/PingCAP-QE/ee-apps/tibuild/commons/database"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
)

type ParamsAvailableForPipelineStruct struct {
Expand Down
6 changes: 4 additions & 2 deletions tibuild/internalpkg/controller/pipeline_for_build_type.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package controller

import (
"net/http"

"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"net/http"
"tibuild/commons/database"

"github.com/PingCAP-QE/ee-apps/tibuild/commons/database"
)

type PipelineForBuildTypeStruct struct {
Expand Down
Loading