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

use go1.18 to build gitea #19099

Merged
merged 14 commits into from
Mar 16, 2022
28 changes: 14 additions & 14 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ steps:
- make deps-frontend

- name: deps-backend
image: golang:1.17
image: golang:1.18
pull: always
commands:
- make deps-backend
Expand Down Expand Up @@ -79,7 +79,7 @@ steps:
depends_on: [deps-frontend]

- name: checks-backend
image: golang:1.17
image: golang:1.18
commands:
- make checks-backend
depends_on: [deps-backend]
Expand All @@ -100,7 +100,7 @@ steps:
depends_on: [test-frontend]

- name: build-backend-no-gcc
image: golang:1.16 # this step is kept as the lowest version of golang that we support
image: golang:1.17 # this step is kept as the lowest version of golang that we support
pull: always
environment:
GO111MODULE: on
Expand All @@ -113,7 +113,7 @@ steps:
path: /go

- name: build-backend-arm64
image: golang:1.17
image: golang:1.18
environment:
GO111MODULE: on
GOPROXY: https://goproxy.cn
Expand All @@ -129,7 +129,7 @@ steps:
path: /go

- name: build-backend-windows
image: golang:1.17
image: golang:1.18
environment:
GO111MODULE: on
GOPROXY: https://goproxy.cn
Expand All @@ -144,7 +144,7 @@ steps:
path: /go

- name: build-backend-386
image: golang:1.17
image: golang:1.18
environment:
GO111MODULE: on
GOPROXY: https://goproxy.cn
Expand Down Expand Up @@ -233,7 +233,7 @@ steps:
- pull_request

- name: deps-backend
image: golang:1.17
image: golang:1.18
pull: always
commands:
- make deps-backend
Expand Down Expand Up @@ -350,7 +350,7 @@ steps:
path: /go

- name: generate-coverage
image: golang:1.17
image: golang:1.18
commands:
- make coverage
environment:
Expand Down Expand Up @@ -425,7 +425,7 @@ steps:
- pull_request

- name: deps-backend
image: golang:1.17
image: golang:1.18
pull: always
commands:
- make deps-backend
Expand Down Expand Up @@ -567,7 +567,7 @@ trigger:

steps:
- name: download
image: golang:1.17
image: golang:1.18
pull: always
commands:
- timeout -s ABRT 40m make generate-license generate-gitignore
Expand Down Expand Up @@ -628,7 +628,7 @@ steps:
- make deps-frontend

- name: deps-backend
image: golang:1.17
image: golang:1.18
pull: always
commands:
- make deps-backend
Expand All @@ -637,7 +637,7 @@ steps:
path: /go

- name: static
image: techknowlogick/xgo:go-1.17.x
image: techknowlogick/xgo:go-1.18.x
pull: always
commands:
- curl -sL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs
Expand Down Expand Up @@ -746,7 +746,7 @@ steps:
- make deps-frontend

- name: deps-backend
image: golang:1.17
image: golang:1.18
pull: always
commands:
- make deps-backend
Expand All @@ -755,7 +755,7 @@ steps:
path: /go

- name: static
image: techknowlogick/xgo:go-1.17.x
image: techknowlogick/xgo:go-1.18.x
pull: always
commands:
- curl -sL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Build stage
FROM golang:1.17-alpine3.15 AS build-env
FROM golang:1.18-alpine3.15 AS build-env

ARG GOPROXY
ENV GOPROXY ${GOPROXY:-direct}
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.rootless
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Build stage
FROM golang:1.17-alpine3.15 AS build-env
FROM golang:1.18-alpine3.15 AS build-env

ARG GOPROXY
ENV GOPROXY ${GOPROXY:-direct}
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ SHASUM ?= shasum -a 256
HAS_GO = $(shell hash $(GO) > /dev/null 2>&1 && echo "GO" || echo "NOGO" )
COMMA := ,

XGO_VERSION := go-1.17.x
MIN_GO_VERSION := 001016000
XGO_VERSION := go-1.18.x
MIN_GO_VERSION := 001017000
MIN_NODE_VERSION := 012017000
MIN_GOLANGCI_LINT_VERSION := 001044000

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ or if SQLite support is required:

The `build` target is split into two sub-targets:

- `make backend` which requires [Go 1.16](https://golang.org/dl/) or greater.
- `make backend` which requires [Go 1.17](https://golang.org/dl/) or greater.
- `make frontend` which requires [Node.js LTS](https://nodejs.org/en/download/) or greater and Internet connectivity to download npm dependencies.

When building from the official source tarballs which include pre-built frontend files, the `frontend` target will not be triggered, making it possible to build without Node.js and Internet connectivity.
Expand Down
4 changes: 2 additions & 2 deletions docs/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ params:
author: The Gitea Authors
website: https://docs.gitea.io
version: 1.16.4
minGoVersion: 1.16
goVersion: 1.17
minGoVersion: 1.17
goVersion: 1.18
minNodeVersion: 12.17

outputs:
Expand Down
8 changes: 1 addition & 7 deletions modules/util/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ import (
"net"
)

// IsIPPrivate for net.IP.IsPrivate. TODO: replace with `ip.IsPrivate()` if min go version is bumped to 1.17
func IsIPPrivate(ip net.IP) bool {
if ip4 := ip.To4(); ip4 != nil {
return ip4[0] == 10 ||
(ip4[0] == 172 && ip4[1]&0xf0 == 16) ||
(ip4[0] == 192 && ip4[1] == 168)
}
return len(ip) == net.IPv6len && ip[0]&0xfe == 0xfc
return ip.IsPrivate()
}
56 changes: 56 additions & 0 deletions modules/util/net_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright 2022 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 util

import (
"net"
"testing"

"github.com/stretchr/testify/assert"
)

func TestIsIPPPrivate(t *testing.T) {
cases := []struct {
ip string
isPrivate bool
}{
// case 0
{
ip: "127.0.0.1",
isPrivate: true,
},
// case 1
{
ip: "127.1.2.3",
isPrivate: true,
},
// case 2
{
ip: "10.255.255.0",
isPrivate: true,
},
// case 3
{
ip: "8.8.8.8",
isPrivate: false,
},
// case 4
{
ip: "::1",
isPrivate: true,
},
// case 4
{
ip: "2a12:7c40::f00d",
isPrivate: false,
},
}

for n, c := range cases {
i, _ := net.ParseIP(c.ip)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that we already should include go1.18 code, even for tests.

Copy link
Member Author

@techknowlogick techknowlogick Mar 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is go1.17 code: https://cs.opensource.google/go/go/+/refs/tags/go1.17:src/net/ip.go;l=704

Edit: This just adds tests for logic we already had

p := IsIPPrivate(i)
assert.Equal(t, c.isPrivate, p, "case %d: should be equal", n)
}
}