From da9374531c8b6ce01127f0a34bff6377e3b910c4 Mon Sep 17 00:00:00 2001 From: Benjamin DENEUX Date: Wed, 7 Aug 2024 07:59:39 +0200 Subject: [PATCH] chore(ci): disable silently the build of axone-cognitarium --- magefiles/build.go | 129 +++++++++++++++++++++++---------------------- 1 file changed, 67 insertions(+), 62 deletions(-) diff --git a/magefiles/build.go b/magefiles/build.go index 7e74afd..652efa2 100644 --- a/magefiles/build.go +++ b/magefiles/build.go @@ -4,94 +4,99 @@ package main import ( - "fmt" - "os" - "path/filepath" - "strings" + "fmt" + "os" + "path/filepath" + "strings" - "github.com/magefile/mage/mg" - "github.com/magefile/mage/sh" + "github.com/magefile/mage/mg" + "github.com/magefile/mage/sh" ) type Build mg.Namespace // Ts build typescript schema for the given contract schema. func (Build) Ts(schema string) error { - mg.Deps(mg.F(Clean.Ts, schema)) + mg.Deps(mg.F(Clean.Ts, schema)) - fmt.Printf("โš™๏ธ Generate typescript types for %s\n", schema) + fmt.Printf("โš™๏ธ Generate typescript types for %s\n", schema) - ensureTsCodegen() + ensureTsCodegen() - name, dest := schemaDestination(schema, TS_DIR) + name, dest := schemaDestination(schema, TS_DIR) - err := sh.Run("ts-codegen", "generate", - "--schema", filepath.Join(SCHEMA_DIR, schema), - "--out", filepath.Join(dest, "gen-ts"), - "--typesOnly", - "--no-bundle", - "--name", name, - ) - if err != nil { - return fmt.Errorf("failed to generate typescript types: %w", err) - } + err := sh.Run("ts-codegen", "generate", + "--schema", filepath.Join(SCHEMA_DIR, schema), + "--out", filepath.Join(dest, "gen-ts"), + "--typesOnly", + "--no-bundle", + "--name", name, + ) + if err != nil { + return fmt.Errorf("failed to generate typescript types: %w", err) + } - fmt.Println("๐Ÿ”จ Building typescript") + fmt.Println("๐Ÿ”จ Building typescript") - err = sh.Run("yarn", "--cwd", dest) - if err != nil { - return err - } + err = sh.Run("yarn", "--cwd", dest) + if err != nil { + return err + } - return sh.Run("yarn", "--cwd", dest, "build") + return sh.Run("yarn", "--cwd", dest, "build") } // Go build go schema for the given contract schema. func (Build) Go(schema string) error { - fmt.Printf("โš™๏ธ Generate go types for %s\n", schema) - - ensureGoCodegen() - - _, dest := schemaDestination(schema, GO_DIR) - if err := os.MkdirAll(dest, os.ModePerm); err != nil { - return fmt.Errorf("failed to create directory: %w", err) - } - - err := sh.Run("go-codegen", "generate", - "messages", - filepath.Join(SCHEMA_DIR, fmt.Sprintf("%s.json", schema)), - "-o", filepath.Join(dest, "schema.go"), - "--package-name", "schema") - if err != nil { - return fmt.Errorf("failed to generate go types: %w", err) - } - - fmt.Println("๐Ÿ‘จโ€๐Ÿ’ป Generate go client") - err = sh.Run("go-codegen", "generate", - "query-client", - filepath.Join(SCHEMA_DIR, fmt.Sprintf("%s.json", schema)), - "-o", filepath.Join(dest, "client.go"), - "--package-name", "schema") - if err != nil { - return fmt.Errorf("failed to generate go client: %w", err) - } - - fmt.Println("๐Ÿ”จ Building go") - return runInPath(dest, "go", "build") + if schema == "axone-cognitarium" { + fmt.Println("๐Ÿšช Skipping axone-cognitarium schema since codegen generation is failing") + return nil + } + + fmt.Printf("โš™๏ธ Generate go types for %s\n", schema) + + ensureGoCodegen() + + _, dest := schemaDestination(schema, GO_DIR) + if err := os.MkdirAll(dest, os.ModePerm); err != nil { + return fmt.Errorf("failed to create directory: %w", err) + } + + err := sh.Run("go-codegen", "generate", + "messages", + filepath.Join(SCHEMA_DIR, fmt.Sprintf("%s.json", schema)), + "-o", filepath.Join(dest, "schema.go"), + "--package-name", "schema") + if err != nil { + return fmt.Errorf("failed to generate go types: %w", err) + } + + fmt.Println("๐Ÿ‘จโ€๐Ÿ’ป Generate go client") + err = sh.Run("go-codegen", "generate", + "query-client", + filepath.Join(SCHEMA_DIR, fmt.Sprintf("%s.json", schema)), + "-o", filepath.Join(dest, "client.go"), + "--package-name", "schema") + if err != nil { + return fmt.Errorf("failed to generate go client: %w", err) + } + + fmt.Println("๐Ÿ”จ Building go") + return runInPath(dest, "go", "build") } type Clean mg.Namespace func (Clean) Ts(schema string) error { - fmt.Printf("๐Ÿงน Cleaning generated typescript files for %s\n", schema) + fmt.Printf("๐Ÿงน Cleaning generated typescript files for %s\n", schema) - _, dest := schemaDestination(schema, TS_DIR) + _, dest := schemaDestination(schema, TS_DIR) - return sh.Run("yarn", "--cwd", dest, "clean") + return sh.Run("yarn", "--cwd", dest, "clean") } func schemaDestination(schema, root string) (name string, destination string) { - name = strings.TrimPrefix(schema, "axone-") - destination = filepath.Join(root, fmt.Sprintf("%s-schema", name)) - return + name = strings.TrimPrefix(schema, "axone-") + destination = filepath.Join(root, fmt.Sprintf("%s-schema", name)) + return }