Generate go-licenses during tidy again (#21108)
We can not have the `frontend` target depend on golang because of they way drone is set up. Move the `go-licenses` generation back into `tidy` where it will now also be checked for consistency during `tidy-check`. (I assume all `main` branch builds should currently fail [like this](https://drone.gitea.io/go-gitea/gitea/60244/1/11)). The reasony why it shouldn't be treated the same as for example `go generate` is because output files are checked in. tidy is imho the optimal target to run this after. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
parent
86ed47e622
commit
b5d21c0adf
4 changed files with 32 additions and 18 deletions
18
.drone.yml
18
.drone.yml
|
@ -102,11 +102,16 @@ steps:
|
||||||
- make test-frontend
|
- make test-frontend
|
||||||
depends_on: [lint-frontend]
|
depends_on: [lint-frontend]
|
||||||
|
|
||||||
|
- name: generate-frontend
|
||||||
|
image: golang:1.19
|
||||||
|
commands:
|
||||||
|
- make generate-frontend
|
||||||
|
|
||||||
- name: build-frontend
|
- name: build-frontend
|
||||||
image: node:18
|
image: node:18
|
||||||
commands:
|
commands:
|
||||||
- make frontend
|
- make frontend
|
||||||
depends_on: [test-frontend]
|
depends_on: [deps-frontend, generate-frontend]
|
||||||
|
|
||||||
- name: build-backend-no-gcc
|
- name: build-backend-no-gcc
|
||||||
image: golang:1.18 # this step is kept as the lowest version of golang that we support
|
image: golang:1.18 # this step is kept as the lowest version of golang that we support
|
||||||
|
@ -529,16 +534,21 @@ services:
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: deps-frontend
|
- name: deps-frontend
|
||||||
image: node:16
|
image: node:18
|
||||||
pull: always
|
pull: always
|
||||||
commands:
|
commands:
|
||||||
- make deps-frontend
|
- make deps-frontend
|
||||||
|
|
||||||
|
- name: generate-frontend
|
||||||
|
image: golang:1.18
|
||||||
|
commands:
|
||||||
|
- make generate-frontend
|
||||||
|
|
||||||
- name: build-frontend
|
- name: build-frontend
|
||||||
image: node:16
|
image: node:18
|
||||||
commands:
|
commands:
|
||||||
- make frontend
|
- make frontend
|
||||||
depends_on: [deps-frontend]
|
depends_on: [deps-frontend, generate-frontend]
|
||||||
|
|
||||||
- name: deps-backend
|
- name: deps-backend
|
||||||
image: golang:1.18
|
image: golang:1.18
|
||||||
|
|
17
Makefile
17
Makefile
|
@ -210,7 +210,7 @@ help:
|
||||||
@echo " - golangci-lint run golangci-lint linter"
|
@echo " - golangci-lint run golangci-lint linter"
|
||||||
@echo " - go-licenses regenerate go licenses"
|
@echo " - go-licenses regenerate go licenses"
|
||||||
@echo " - vet examines Go source code and reports suspicious constructs"
|
@echo " - vet examines Go source code and reports suspicious constructs"
|
||||||
@echo " - tidy run go mod tidy and regenerate go licenses"
|
@echo " - tidy run go mod tidy"
|
||||||
@echo " - test[\#TestSpecificName] run unit test"
|
@echo " - test[\#TestSpecificName] run unit test"
|
||||||
@echo " - test-sqlite[\#TestSpecificName] run integration test for sqlite"
|
@echo " - test-sqlite[\#TestSpecificName] run integration test for sqlite"
|
||||||
@echo " - pr#<index> build and start gitea from a PR with integration test data loaded"
|
@echo " - pr#<index> build and start gitea from a PR with integration test data loaded"
|
||||||
|
@ -406,9 +406,9 @@ tidy:
|
||||||
$(eval MIN_GO_VERSION := $(shell grep -Eo '^go\s+[0-9]+\.[0-9.]+' go.mod | cut -d' ' -f2))
|
$(eval MIN_GO_VERSION := $(shell grep -Eo '^go\s+[0-9]+\.[0-9.]+' go.mod | cut -d' ' -f2))
|
||||||
$(GO) mod tidy -compat=$(MIN_GO_VERSION)
|
$(GO) mod tidy -compat=$(MIN_GO_VERSION)
|
||||||
|
|
||||||
.PHONY: vendor
|
vendor: go.mod go.sum
|
||||||
vendor: tidy
|
|
||||||
$(GO) mod vendor
|
$(GO) mod vendor
|
||||||
|
@touch vendor
|
||||||
|
|
||||||
.PHONY: tidy-check
|
.PHONY: tidy-check
|
||||||
tidy-check: tidy
|
tidy-check: tidy
|
||||||
|
@ -420,9 +420,9 @@ tidy-check: tidy
|
||||||
fi
|
fi
|
||||||
|
|
||||||
.PHONY: go-licenses
|
.PHONY: go-licenses
|
||||||
go-licenses: assets/go-licenses.json
|
go-licenses: $(GO_LICENSE_FILE)
|
||||||
|
|
||||||
assets/go-licenses.json: go.mod go.sum
|
$(GO_LICENSE_FILE): go.mod go.sum
|
||||||
-$(GO) run $(GO_LICENSES_PACKAGE) save . --force --save_path=$(GO_LICENSE_TMP_DIR) 2>/dev/null
|
-$(GO) run $(GO_LICENSES_PACKAGE) save . --force --save_path=$(GO_LICENSE_TMP_DIR) 2>/dev/null
|
||||||
$(GO) run build/generate-go-licenses.go $(GO_LICENSE_TMP_DIR) $(GO_LICENSE_FILE)
|
$(GO) run build/generate-go-licenses.go $(GO_LICENSE_TMP_DIR) $(GO_LICENSE_FILE)
|
||||||
@rm -rf $(GO_LICENSE_TMP_DIR)
|
@rm -rf $(GO_LICENSE_TMP_DIR)
|
||||||
|
@ -717,16 +717,17 @@ backend: go-check generate-backend $(EXECUTABLE)
|
||||||
.PHONY: generate
|
.PHONY: generate
|
||||||
generate: generate-backend generate-frontend
|
generate: generate-backend generate-frontend
|
||||||
|
|
||||||
|
.PHONY: generate-frontend
|
||||||
|
generate-frontend: $(GO_LICENSE_FILE)
|
||||||
|
|
||||||
.PHONY: generate-backend
|
.PHONY: generate-backend
|
||||||
generate-backend: $(TAGS_PREREQ) generate-go
|
generate-backend: $(TAGS_PREREQ) generate-go
|
||||||
|
|
||||||
|
.PHONY: generate-go
|
||||||
generate-go: $(TAGS_PREREQ)
|
generate-go: $(TAGS_PREREQ)
|
||||||
@echo "Running go generate..."
|
@echo "Running go generate..."
|
||||||
@CC= GOOS= GOARCH= $(GO) generate -tags '$(TAGS)' $(GO_PACKAGES)
|
@CC= GOOS= GOARCH= $(GO) generate -tags '$(TAGS)' $(GO_PACKAGES)
|
||||||
|
|
||||||
.PHONY: generate-frontend
|
|
||||||
generate-frontend: $(TAGS_PREREQ) go-licenses
|
|
||||||
|
|
||||||
$(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ)
|
$(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 $@
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -54,9 +54,17 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
path := strings.Replace(path, base+string(os.PathSeparator), "", 1)
|
path := strings.Replace(path, base+string(os.PathSeparator), "", 1)
|
||||||
|
name := filepath.Dir(path)
|
||||||
|
|
||||||
|
// There might be a bug somewhere in go-licenses that sometimes interprets the
|
||||||
|
// root package as "." and sometimes as "code.gitea.io/gitea". Workaround by
|
||||||
|
// removing both of them for the sake of stable output.
|
||||||
|
if name == "." || name == "code.gitea.io/gitea" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
entries = append(entries, LicenseEntry{
|
entries = append(entries, LicenseEntry{
|
||||||
Name: filepath.Dir(path),
|
Name: name,
|
||||||
Path: path,
|
Path: path,
|
||||||
LicenseText: string(licenseText),
|
LicenseText: string(licenseText),
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue