mirror of
https://github.com/andwati/zitadel.git
synced 2026-12-04 18:08:50 +00:00
chore(ci): improving CI reliability when caching (#11501)
This fixes a case where potentially some static files get not properly treated as inputs in the hash for nx cache calculation. Also it fixes a problem where the assets.mdx get sorted randomly each generation. Factors in some overlap from https://github.com/zitadel/zitadel/pull/11447 --------- Co-authored-by: Copilot <[email protected]>
This commit is contained in:
co-authored by
Copilot
parent
0999e44821
commit
04c58c5b3f
@@ -68,6 +68,8 @@ jobs:
|
|||||||
NX_DAEMON: "false"
|
NX_DAEMON: "false"
|
||||||
NX_DISABLE_DB: "true"
|
NX_DISABLE_DB: "true"
|
||||||
run: pnpm nx affected --nxBail --targets lint test build --exclude @zitadel/docs
|
run: pnpm nx affected --nxBail --targets lint test build --exclude @zitadel/docs
|
||||||
|
- name: Check for uncommitted changes (Codegen mismatch)
|
||||||
|
run: git diff --exit-code
|
||||||
- name: Suggest Pipeline Fix By Nx Cloud AI
|
- name: Suggest Pipeline Fix By Nx Cloud AI
|
||||||
if: failure() || cancelled()
|
if: failure() || cancelled()
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -342,9 +342,12 @@
|
|||||||
"runtime": "go env GOARCH"
|
"runtime": "go env GOARCH"
|
||||||
},
|
},
|
||||||
"{workspaceRoot}/internal/statik/generate.go",
|
"{workspaceRoot}/internal/statik/generate.go",
|
||||||
|
"{workspaceRoot}/internal/static/**/*",
|
||||||
"{workspaceRoot}/internal/notification/statik/generate.go",
|
"{workspaceRoot}/internal/notification/statik/generate.go",
|
||||||
|
"{workspaceRoot}/internal/notification/static/**/*",
|
||||||
"{workspaceRoot}/internal/api/ui/login/static/resources/generate.go",
|
"{workspaceRoot}/internal/api/ui/login/static/resources/generate.go",
|
||||||
"{workspaceRoot}/internal/api/ui/login/statik/generate.go"
|
"{workspaceRoot}/internal/api/ui/login/statik/generate.go",
|
||||||
|
"{workspaceRoot}/internal/api/ui/login/static/**/*"
|
||||||
],
|
],
|
||||||
"outputs": [
|
"outputs": [
|
||||||
"{workspaceRoot}/internal/statik/statik.go",
|
"{workspaceRoot}/internal/statik/statik.go",
|
||||||
@@ -361,7 +364,7 @@
|
|||||||
"command": "mkdir -p apps/docs/content/apis/assets && go run internal/api/assets/generator/asset_generator.go -directory=internal/api/assets/generator/ -assets=apps/docs/content/apis/assets/assets.mdx",
|
"command": "mkdir -p apps/docs/content/apis/assets && go run internal/api/assets/generator/asset_generator.go -directory=internal/api/assets/generator/ -assets=apps/docs/content/apis/assets/assets.mdx",
|
||||||
"cache": true,
|
"cache": true,
|
||||||
"inputs": [
|
"inputs": [
|
||||||
"{workspaceRoot}/internal/api/assets/generator/asset_generator.go"
|
"{workspaceRoot}/internal/api/assets/generator/**/*"
|
||||||
],
|
],
|
||||||
"outputs": [
|
"outputs": [
|
||||||
"{workspaceRoot}/internal/api/assets/authz.go",
|
"{workspaceRoot}/internal/api/assets/authz.go",
|
||||||
|
|||||||
@@ -2,26 +2,43 @@
|
|||||||
title: zitadel/assets
|
title: zitadel/assets
|
||||||
---
|
---
|
||||||
|
|
||||||
|
{/*
|
||||||
|
Code generated by assets generator. DO NOT EDIT.
|
||||||
|
This file is checked in to support building docs without a Go environment.
|
||||||
|
*/}
|
||||||
|
|
||||||
## AssetsService
|
## AssetsService
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### UploadDefaultLabelPolicyFont()
|
### UploadDefaultLabelPolicyFont()
|
||||||
|
|
||||||
> UploadDefaultLabelPolicyFont()
|
> UploadDefaultLabelPolicyFont()
|
||||||
|
|
||||||
POST: /instance/policy/label/font
|
POST: /instance/policy/label/font
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### GetDefaultLabelPolicyFont()
|
### GetDefaultLabelPolicyFont()
|
||||||
|
|
||||||
> GetDefaultLabelPolicyFont()
|
> GetDefaultLabelPolicyFont()
|
||||||
|
|
||||||
GET: /instance/policy/label/font
|
GET: /instance/policy/label/font
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### GetPreviewDefaultLabelPolicyFont()
|
### GetPreviewDefaultLabelPolicyFont()
|
||||||
|
|
||||||
> GetPreviewDefaultLabelPolicyFont()
|
> GetPreviewDefaultLabelPolicyFont()
|
||||||
|
|
||||||
GET: /instance/policy/label/font/_preview
|
GET: /instance/policy/label/font/_preview
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### UploadDefaultLabelPolicyIcon()
|
### UploadDefaultLabelPolicyIcon()
|
||||||
|
|
||||||
> UploadDefaultLabelPolicyIcon()
|
> UploadDefaultLabelPolicyIcon()
|
||||||
@@ -34,6 +51,8 @@ POST: /instance/policy/label/icon
|
|||||||
|
|
||||||
POST: /instance/policy/label/icon/dark
|
POST: /instance/policy/label/icon/dark
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### GetDefaultLabelPolicyIcon()
|
### GetDefaultLabelPolicyIcon()
|
||||||
|
|
||||||
> GetDefaultLabelPolicyIcon()
|
> GetDefaultLabelPolicyIcon()
|
||||||
@@ -46,6 +65,8 @@ GET: /instance/policy/label/icon
|
|||||||
|
|
||||||
GET: /instance/policy/label/icon/dark
|
GET: /instance/policy/label/icon/dark
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### GetPreviewDefaultLabelPolicyIcon()
|
### GetPreviewDefaultLabelPolicyIcon()
|
||||||
|
|
||||||
> GetPreviewDefaultLabelPolicyIcon()
|
> GetPreviewDefaultLabelPolicyIcon()
|
||||||
@@ -58,6 +79,10 @@ GET: /instance/policy/label/icon/_preview
|
|||||||
|
|
||||||
GET: /instance/policy/label/icon/dark/_preview
|
GET: /instance/policy/label/icon/dark/_preview
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### UploadDefaultLabelPolicyLogo()
|
### UploadDefaultLabelPolicyLogo()
|
||||||
|
|
||||||
> UploadDefaultLabelPolicyLogo()
|
> UploadDefaultLabelPolicyLogo()
|
||||||
@@ -70,6 +95,8 @@ POST: /instance/policy/label/logo
|
|||||||
|
|
||||||
POST: /instance/policy/label/logo/dark
|
POST: /instance/policy/label/logo/dark
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### GetDefaultLabelPolicyLogo()
|
### GetDefaultLabelPolicyLogo()
|
||||||
|
|
||||||
> GetDefaultLabelPolicyLogo()
|
> GetDefaultLabelPolicyLogo()
|
||||||
@@ -82,6 +109,8 @@ GET: /instance/policy/label/logo
|
|||||||
|
|
||||||
GET: /instance/policy/label/logo/dark
|
GET: /instance/policy/label/logo/dark
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### GetPreviewDefaultLabelPolicyLogo()
|
### GetPreviewDefaultLabelPolicyLogo()
|
||||||
|
|
||||||
> GetPreviewDefaultLabelPolicyLogo()
|
> GetPreviewDefaultLabelPolicyLogo()
|
||||||
@@ -94,24 +123,38 @@ GET: /instance/policy/label/logo/_preview
|
|||||||
|
|
||||||
GET: /instance/policy/label/logo/dark/_preview
|
GET: /instance/policy/label/logo/dark/_preview
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### UploadOrgLabelPolicyFont()
|
### UploadOrgLabelPolicyFont()
|
||||||
|
|
||||||
> UploadOrgLabelPolicyFont()
|
> UploadOrgLabelPolicyFont()
|
||||||
|
|
||||||
POST: /org/policy/label/font
|
POST: /org/policy/label/font
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### GetOrgLabelPolicyFont()
|
### GetOrgLabelPolicyFont()
|
||||||
|
|
||||||
> GetOrgLabelPolicyFont()
|
> GetOrgLabelPolicyFont()
|
||||||
|
|
||||||
GET: /org/policy/label/font
|
GET: /org/policy/label/font
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### GetPreviewOrgLabelPolicyFont()
|
### GetPreviewOrgLabelPolicyFont()
|
||||||
|
|
||||||
> GetPreviewOrgLabelPolicyFont()
|
> GetPreviewOrgLabelPolicyFont()
|
||||||
|
|
||||||
GET: /org/policy/label/font/_preview
|
GET: /org/policy/label/font/_preview
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### UploadOrgLabelPolicyIcon()
|
### UploadOrgLabelPolicyIcon()
|
||||||
|
|
||||||
> UploadOrgLabelPolicyIcon()
|
> UploadOrgLabelPolicyIcon()
|
||||||
@@ -124,6 +167,8 @@ POST: /org/policy/label/icon
|
|||||||
|
|
||||||
POST: /org/policy/label/icon/dark
|
POST: /org/policy/label/icon/dark
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### GetOrgLabelPolicyIcon()
|
### GetOrgLabelPolicyIcon()
|
||||||
|
|
||||||
> GetOrgLabelPolicyIcon()
|
> GetOrgLabelPolicyIcon()
|
||||||
@@ -136,6 +181,8 @@ GET: /org/policy/label/icon
|
|||||||
|
|
||||||
GET: /org/policy/label/icon/dark
|
GET: /org/policy/label/icon/dark
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### GetPreviewOrgLabelPolicyIcon()
|
### GetPreviewOrgLabelPolicyIcon()
|
||||||
|
|
||||||
> GetPreviewOrgLabelPolicyIcon()
|
> GetPreviewOrgLabelPolicyIcon()
|
||||||
@@ -148,6 +195,10 @@ GET: /org/policy/label/icon/_preview
|
|||||||
|
|
||||||
GET: /org/policy/label/icon/dark/_preview
|
GET: /org/policy/label/icon/dark/_preview
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### UploadOrgLabelPolicyLogo()
|
### UploadOrgLabelPolicyLogo()
|
||||||
|
|
||||||
> UploadOrgLabelPolicyLogo()
|
> UploadOrgLabelPolicyLogo()
|
||||||
@@ -160,6 +211,8 @@ POST: /org/policy/label/logo
|
|||||||
|
|
||||||
POST: /org/policy/label/logo/dark
|
POST: /org/policy/label/logo/dark
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### GetOrgLabelPolicyLogo()
|
### GetOrgLabelPolicyLogo()
|
||||||
|
|
||||||
> GetOrgLabelPolicyLogo()
|
> GetOrgLabelPolicyLogo()
|
||||||
@@ -172,6 +225,8 @@ GET: /org/policy/label/logo
|
|||||||
|
|
||||||
GET: /org/policy/label/logo/dark
|
GET: /org/policy/label/logo/dark
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### GetPreviewOrgLabelPolicyLogo()
|
### GetPreviewOrgLabelPolicyLogo()
|
||||||
|
|
||||||
> GetPreviewOrgLabelPolicyLogo()
|
> GetPreviewOrgLabelPolicyLogo()
|
||||||
@@ -184,14 +239,26 @@ GET: /org/policy/label/logo/_preview
|
|||||||
|
|
||||||
GET: /org/policy/label/logo/dark/_preview
|
GET: /org/policy/label/logo/dark/_preview
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### UploadMyUserAvatar()
|
### UploadMyUserAvatar()
|
||||||
|
|
||||||
> UploadMyUserAvatar()
|
> UploadMyUserAvatar()
|
||||||
|
|
||||||
POST: /users/me/avatar
|
POST: /users/me/avatar
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### GetMyUserAvatar()
|
### GetMyUserAvatar()
|
||||||
|
|
||||||
> GetMyUserAvatar()
|
> GetMyUserAvatar()
|
||||||
|
|
||||||
GET: /users/me/avatar
|
GET: /users/me/avatar
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/zitadel/logging"
|
"github.com/zitadel/logging"
|
||||||
@@ -97,6 +98,48 @@ type Service struct {
|
|||||||
Methods map[string]Method
|
Methods map[string]Method
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SortedService struct {
|
||||||
|
Prefix string
|
||||||
|
Methods []SortedMethod
|
||||||
|
}
|
||||||
|
|
||||||
|
type SortedMethod struct {
|
||||||
|
Name string
|
||||||
|
Method
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Services) toSorted() []SortedService {
|
||||||
|
keys := make([]string, 0, len(s))
|
||||||
|
for k := range s {
|
||||||
|
keys = append(keys, k)
|
||||||
|
}
|
||||||
|
sort.Strings(keys)
|
||||||
|
sorted := make([]SortedService, len(keys))
|
||||||
|
for i, k := range keys {
|
||||||
|
sorted[i] = SortedService{
|
||||||
|
Prefix: s[k].Prefix,
|
||||||
|
Methods: s[k].toSortedMethods(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sorted
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Service) toSortedMethods() []SortedMethod {
|
||||||
|
keys := make([]string, 0, len(s.Methods))
|
||||||
|
for k := range s.Methods {
|
||||||
|
keys = append(keys, k)
|
||||||
|
}
|
||||||
|
sort.Strings(keys)
|
||||||
|
sorted := make([]SortedMethod, len(keys))
|
||||||
|
for i, k := range keys {
|
||||||
|
sorted[i] = SortedMethod{
|
||||||
|
Name: k,
|
||||||
|
Method: s.Methods[k],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sorted
|
||||||
|
}
|
||||||
|
|
||||||
func GenerateAssetHandler(configFilePath, handlerPrefix string, authz, router, docs io.Writer) {
|
func GenerateAssetHandler(configFilePath, handlerPrefix string, authz, router, docs io.Writer) {
|
||||||
conf := new(struct {
|
conf := new(struct {
|
||||||
Services Services
|
Services Services
|
||||||
@@ -113,12 +156,12 @@ func GenerateAssetHandler(configFilePath, handlerPrefix string, authz, router, d
|
|||||||
GoPkgName string
|
GoPkgName string
|
||||||
Name string
|
Name string
|
||||||
Prefix string
|
Prefix string
|
||||||
Services Services
|
Services []SortedService
|
||||||
}{
|
}{
|
||||||
GoPkgName: "assets",
|
GoPkgName: "assets",
|
||||||
Name: "AssetsService",
|
Name: "AssetsService",
|
||||||
Prefix: handlerPrefix,
|
Prefix: handlerPrefix,
|
||||||
Services: conf.Services,
|
Services: conf.Services.toSorted(),
|
||||||
}
|
}
|
||||||
err = tmplAuthz.Execute(authz, data)
|
err = tmplAuthz.Execute(authz, data)
|
||||||
logging.Log("ASSETS-BHngj").OnError(err).Fatal("cannot generate authz")
|
logging.Log("ASSETS-BHngj").OnError(err).Fatal("cannot generate authz")
|
||||||
@@ -180,11 +223,11 @@ type {{.Name}} interface {
|
|||||||
Storage() static.Storage
|
Storage() static.Storage
|
||||||
|
|
||||||
{{ range $service := .Services}}
|
{{ range $service := .Services}}
|
||||||
{{ range $methodName, $method := .Methods}}
|
{{ range $method := .Methods}}
|
||||||
{{ range $handler := .Handlers}}
|
{{ range $handler := .Handlers}}
|
||||||
{{$handler.Name}}{{$methodName}}() {{if $handler.MethodReturn}}{{$handler.MethodReturn}}{{end}}
|
{{$handler.Name}}{{$method.Name}}() {{if $handler.MethodReturn}}{{$handler.MethodReturn}}{{end}}
|
||||||
{{ if $method.HasDarkMode }}
|
{{ if $method.HasDarkMode }}
|
||||||
{{$handler.Name}}{{$methodName}}Dark() {{if $handler.MethodReturn}}{{$handler.MethodReturn}}{{end}}
|
{{$handler.Name}}{{$method.Name}}Dark() {{if $handler.MethodReturn}}{{$handler.MethodReturn}}{{end}}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
@@ -196,11 +239,11 @@ func RegisterRoutes(router *mux.Router, s {{.Name}}) {
|
|||||||
router.Use(s.AuthInterceptor().Handler)
|
router.Use(s.AuthInterceptor().Handler)
|
||||||
|
|
||||||
{{ range $service := .Services}}
|
{{ range $service := .Services}}
|
||||||
{{ range $methodName, $method := .Methods}}
|
{{ range $method := .Methods}}
|
||||||
{{ range $handler := .Handlers}}
|
{{ range $handler := .Handlers}}
|
||||||
router.Path("{{$service.Prefix}}{{$method.Path}}{{$handler.PathSuffix}}").Methods("{{$handler.Method}}").HandlerFunc({{if $handler.HandlerType}}{{$handler.HandlerType}}(s, {{end}}s.{{$handler.Name}}{{$methodName}}(){{if $handler.HandlerType}}){{end}})
|
router.Path("{{$service.Prefix}}{{$method.Path}}{{$handler.PathSuffix}}").Methods("{{$handler.Method}}").HandlerFunc({{if $handler.HandlerType}}{{$handler.HandlerType}}(s, {{end}}s.{{$handler.Name}}{{$method.Name}}(){{if $handler.HandlerType}}){{end}})
|
||||||
{{ if $method.HasDarkMode }}
|
{{ if $method.HasDarkMode }}
|
||||||
router.Path("{{$service.Prefix}}{{$method.Path}}/dark{{$handler.PathSuffix}}").Methods("{{$handler.Method}}").HandlerFunc({{if $handler.HandlerType}}{{$handler.HandlerType}}(s, {{end}}s.{{$handler.Name}}{{$methodName}}Dark(){{if $handler.HandlerType}}){{end}})
|
router.Path("{{$service.Prefix}}{{$method.Path}}/dark{{$handler.PathSuffix}}").Methods("{{$handler.Method}}").HandlerFunc({{if $handler.HandlerType}}{{$handler.HandlerType}}(s, {{end}}s.{{$handler.Name}}{{$method.Name}}Dark(){{if $handler.HandlerType}}){{end}})
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
@@ -212,21 +255,26 @@ const docsTmpl = `---
|
|||||||
title: zitadel/assets
|
title: zitadel/assets
|
||||||
---
|
---
|
||||||
|
|
||||||
|
{/*
|
||||||
|
Code generated by assets generator. DO NOT EDIT.
|
||||||
|
This file is checked in to support building docs without a Go environment.
|
||||||
|
*/}
|
||||||
|
|
||||||
## {{.Name}}
|
## {{.Name}}
|
||||||
|
|
||||||
{{ range $service := .Services}}
|
{{ range $service := .Services}}
|
||||||
{{ range $methodName, $method := .Methods}}
|
{{ range $method := .Methods}}
|
||||||
{{ range $handler := .Handlers}}
|
{{ range $handler := .Handlers}}
|
||||||
|
|
||||||
### {{$handler.Name}}{{$methodName}}()
|
### {{$handler.Name}}{{$method.Name}}()
|
||||||
|
|
||||||
> {{$handler.Name}}{{$methodName}}()
|
> {{$handler.Name}}{{$method.Name}}()
|
||||||
|
|
||||||
{{$handler.Method}}: {{$service.Prefix}}{{$method.Path}}{{$handler.PathSuffix}}
|
{{$handler.Method}}: {{$service.Prefix}}{{$method.Path}}{{$handler.PathSuffix}}
|
||||||
{{ if $method.HasDarkMode }}
|
{{ if $method.HasDarkMode }}
|
||||||
### {{$handler.Name}}{{$methodName}}()
|
### {{$handler.Name}}{{$method.Name}}Dark()
|
||||||
|
|
||||||
> {{$handler.Name}}{{$methodName}}Dark()
|
> {{$handler.Name}}{{$method.Name}}Dark()
|
||||||
|
|
||||||
{{$handler.Method}}: {{$service.Prefix}}{{$method.Path}}/dark{{$handler.PathSuffix}}
|
{{$handler.Method}}: {{$service.Prefix}}{{$method.Path}}/dark{{$handler.PathSuffix}}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|||||||
Reference in New Issue
Block a user