This commit is contained in:
parent
1104f6467a
commit
67a9247b4e
1 changed files with 47 additions and 1 deletions
|
|
@ -8,17 +8,26 @@ import (
|
||||||
|
|
||||||
type Quintodrome struct{}
|
type Quintodrome struct{}
|
||||||
|
|
||||||
// Ci runs the full Linux CI: Go build + test and JS build + test.
|
// Ci runs the full Linux CI: lint, build, and test for both Go and JS.
|
||||||
func (m *Quintodrome) Ci(ctx context.Context,
|
func (m *Quintodrome) Ci(ctx context.Context,
|
||||||
// +defaultPath="."
|
// +defaultPath="."
|
||||||
src *dagger.Directory,
|
src *dagger.Directory,
|
||||||
) error {
|
) error {
|
||||||
|
if err := m.LintGo(ctx, src); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := m.FmtGo(ctx, src); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if err := m.BuildGo(ctx, src); err != nil {
|
if err := m.BuildGo(ctx, src); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := m.TestGo(ctx, src); err != nil {
|
if err := m.TestGo(ctx, src); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := m.LintJS(ctx, src); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if err := m.BuildJS(ctx, src); err != nil {
|
if err := m.BuildJS(ctx, src); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -28,6 +37,31 @@ func (m *Quintodrome) Ci(ctx context.Context,
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LintGo runs golangci-lint with the repo's .golangci.yml.
|
||||||
|
func (m *Quintodrome) LintGo(ctx context.Context, src *dagger.Directory) error {
|
||||||
|
_, err := goContainer().
|
||||||
|
WithDirectory("/repo", src).
|
||||||
|
WithWorkdir("/repo").
|
||||||
|
WithExec([]string{"sh", "-c", "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /usr/local/bin v2.12.0"}).
|
||||||
|
WithExec([]string{"golangci-lint", "run", "--timeout", "2m"}).
|
||||||
|
Sync(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// FmtGo checks that goimports and go mod tidy leave the tree clean.
|
||||||
|
func (m *Quintodrome) FmtGo(ctx context.Context, src *dagger.Directory) error {
|
||||||
|
_, err := goContainer().
|
||||||
|
WithDirectory("/repo", src).
|
||||||
|
WithWorkdir("/repo").
|
||||||
|
WithExec([]string{"sh", "-c", `
|
||||||
|
go run golang.org/x/tools/cmd/goimports@latest -w $(find . -name '*.go' | grep -v '_gen.go$' | grep -v '.pb.go$')
|
||||||
|
go mod tidy
|
||||||
|
test -z "$(git status --porcelain)"
|
||||||
|
`}).
|
||||||
|
Sync(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// BuildGo compiles the Navidrome server and all packages.
|
// BuildGo compiles the Navidrome server and all packages.
|
||||||
func (m *Quintodrome) BuildGo(ctx context.Context, src *dagger.Directory) error {
|
func (m *Quintodrome) BuildGo(ctx context.Context, src *dagger.Directory) error {
|
||||||
_, err := goContainer().
|
_, err := goContainer().
|
||||||
|
|
@ -48,6 +82,18 @@ func (m *Quintodrome) TestGo(ctx context.Context, src *dagger.Directory) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LintJS runs prettier and eslint in the web UI.
|
||||||
|
func (m *Quintodrome) LintJS(ctx context.Context, src *dagger.Directory) error {
|
||||||
|
_, err := jsContainer().
|
||||||
|
WithDirectory("/repo", src).
|
||||||
|
WithWorkdir("/repo/ui").
|
||||||
|
WithExec([]string{"npm", "ci", "--ignore-scripts"}).
|
||||||
|
WithExec([]string{"npm", "run", "check-formatting"}).
|
||||||
|
WithExec([]string{"npm", "run", "lint"}).
|
||||||
|
Sync(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// BuildJS builds the Navidrome web UI.
|
// BuildJS builds the Navidrome web UI.
|
||||||
func (m *Quintodrome) BuildJS(ctx context.Context, src *dagger.Directory) error {
|
func (m *Quintodrome) BuildJS(ctx context.Context, src *dagger.Directory) error {
|
||||||
_, err := jsContainer().
|
_, err := jsContainer().
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue