55 lines
994 B
Go
55 lines
994 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"fmt"
|
||
|
"log"
|
||
|
"os"
|
||
|
"path/filepath"
|
||
|
|
||
|
"dagger.io/dagger"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
if err := run(context.Background()); err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// run creates the Dagger client and runs the pipeline.
|
||
|
func run(ctx context.Context) error {
|
||
|
log.Println("Building with Dagger")
|
||
|
|
||
|
client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stdout))
|
||
|
if err != nil {
|
||
|
return fmt.Errorf("unable to initiate the Dagger client, %w", err)
|
||
|
}
|
||
|
defer client.Close()
|
||
|
|
||
|
projectRoot, err := filepath.Abs("../..")
|
||
|
if err != nil {
|
||
|
return fmt.Errorf("unable to get the project's root directory, %w", err)
|
||
|
}
|
||
|
|
||
|
stages := [2]stage{
|
||
|
{
|
||
|
name: "Mage Test",
|
||
|
projectRoot: projectRoot,
|
||
|
stageFunc: test,
|
||
|
},
|
||
|
{
|
||
|
name: "Mage Lint",
|
||
|
projectRoot: projectRoot,
|
||
|
stageFunc: lint,
|
||
|
},
|
||
|
}
|
||
|
|
||
|
for i := range stages {
|
||
|
if err := stages[i].run(ctx, client); err != nil {
|
||
|
return fmt.Errorf("error running pipeline; %w", err)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|