| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package main
- import (
- "flag"
- "fmt"
- "io"
- "os"
- )
- func run(proj string, out io.Writer) error {
- if proj == "" {
- return fmt.Errorf("project directory is required: %w", ErrValidation)
- }
- pipeline := make([]step, 2)
- pipeline[0] = newStep(
- "go build",
- "Go Build: SUCCESS",
- proj,
- "go",
- []string{"build", ".", "errors"},
- )
- pipeline[1] = newStep(
- "go test",
- "Go Test: SUCCESS",
- proj,
- "go",
- []string{"test", "-v"},
- )
- for _, s := range pipeline {
- msg, err := s.execute()
- if err != nil {
- return err
- }
- _, err = fmt.Fprintln(out, msg)
- if err != nil {
- return err
- }
- }
- return nil
- }
- func main() {
- proj := flag.String("p", "", "Project directory")
- flag.Parse()
- if err := run(*proj, os.Stdout); err != nil {
- _, _ = fmt.Fprintln(os.Stderr, err)
- os.Exit(1)
- }
- }
|