Dan Anglin
c2a1e28773
Summary: Add simple CI pipelines to the greet project. Here we add CI pipelines for both Woodpecker and Dagger CI as we are currently interested in both technologies. Changes: - Add .woodpecker/woodpecker.yml - Updated LICENSE - Updated README.md - Fixed linting issues in greet.go - Created a new internal go module for CI/CD in internal/build - Moved the magefiles to internal/build/magefiles - Add dagger pipeline code
54 lines
994 B
Go
54 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
|
|
}
|