diff --git a/demo/README.md b/demo/README.md deleted file mode 100644 index 22bc887d..00000000 --- a/demo/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# Demo - -Welcome to the interactive demo showcasing the versatility of `gale` in various scenarios. - -## Demos: - -Explore `gale` through the following scenarios: - -| Demo | Flag to run | Description | -|-----------------|---------------------|-------------------------------------------------------------------------------------------------| -| List | `--list` | List all workflows and jobs under it for current repositories `main` branch | -| Run | `--run` | Run golangci-lint job from ci/workflows/lint workflow for aweris/gale repository default branch | -| Lint GoReleaser | `--lint-goreleaser` | Run golangci job from golangci-lint workflow for goreleaser/goreleaser repository tag v1.19.2 | -| Shell run | `--shell-run` | Run example workflow contains steps with different shells | -| Test Dagger | `--test-dagger` | Run sdk-go job from test workflow for dagger/dagger repository branch main | -| Test Cache | `--test-cache` | Use actions/cache in the workflow | - -## Getting Started - -Execute the demo using the following command from the root of the gale repository: - -```bash -go run ./demo/ --auto --auto-timeout 1s -``` - -Replace with the desired flag corresponding to the demo you want to explore. - -## How It Works - -Upon execution, the chosen demo will perform the following steps: - -- Downloading Binaries: The demo will automatically download `dagger` and `gale` binaries with predefined versions into the `./bin` directory. -- Running Demo: The demo will run the chosen demo using the `dagger` and `gale` binaries. -- Cleaning Up: The demo will clean up the `./bin` directory. - - -This demo uses [saschagrunert/demo](https://github.com/saschagrunert/demo) library to create the interactive demo. Please refer to the [documentation](https://github.com/saschagrunert/demo#usage) for more information on demo running options. \ No newline at end of file diff --git a/demo/const.go b/demo/const.go deleted file mode 100644 index 6e935820..00000000 --- a/demo/const.go +++ /dev/null @@ -1,7 +0,0 @@ -package main - -const ( - BinDir = "./bin" - DaggerVersion = "0.8.4" - GaleVersion = "v0.0.6" -) diff --git a/demo/env.go b/demo/env.go deleted file mode 100644 index fd951b5d..00000000 --- a/demo/env.go +++ /dev/null @@ -1,92 +0,0 @@ -package main - -import ( - "fmt" - - "github.com/saschagrunert/demo" - "github.com/urfave/cli/v2" -) - -// env is the environment for the demo to run. It contains helper functions to setup and cleanup the environment and -// build commands to run gale and dagger. -var env = newEnv(BinDir, DaggerVersion, GaleVersion) - -// environment contains helper functions to setup and cleanup the environment and build commands to run gale and dagger. -type environment struct { - dagger dagger // dagger installation information - gale gale // gale installation information -} - -// newEnv creates a new environment with the given dagger and gale versions and the directory to install them. -func newEnv(binDir, daggerVersion, galeVersion string) environment { - return environment{ - dagger: dagger{ - version: daggerVersion, - dir: binDir, - }, - gale: gale{ - version: galeVersion, - dir: binDir, - }, - } -} - -// Setup installs dagger and gale -func (e environment) Setup(_ *cli.Context) error { - fmt.Printf("Installing dagger %s and gale %s...\n", e.dagger.version, e.gale.version) - - return demo.Ensure(e.dagger.Setup(), e.gale.Setup()) -} - -// RunGaleWithDagger returns a command slice as `dagger run gale run ` with correct paths to dagger and gale -func (e environment) RunGaleWithDagger(command string) []string { - return demo.S(e.dagger.Run(e.gale.Run(command))) -} - -// Cleanup removes dagger and gale from the environment -func (e environment) Cleanup(_ *cli.Context) error { - fmt.Println("Cleaning downloaded binaries...") - return demo.Ensure(e.dagger.Cleanup(), e.gale.Cleanup()) -} - -// dagger is a helper struct to configure dagger setup and cleanup commands -type dagger struct { - version string // version of dagger to install - dir string // directory to install dagger -} - -// Setup returns the command to install dagger -func (d dagger) Setup() string { - return "curl -sfLo install_dagger.sh https://releases.dagger.io/dagger/install.sh; DAGGER_VERSION=" + d.version + " BIN_DIR=" + d.dir + " sh ./install_dagger.sh" -} - -// Run returns a command as `dagger run ` with correct paths to dagger -func (d dagger) Run(command string) string { - return fmt.Sprintf("%s/dagger run %s", d.dir, command) -} - -// Cleanup returns the command to remove dagger -func (d dagger) Cleanup() string { - return "rm -f ./install_dagger.sh" + d.dir + "/dagger" -} - -// gale is a helper struct to configure gale setup and cleanup commands -type gale struct { - version string // version of gale to install - dir string // directory to install gale -} - -// Setup returns the command to install gale -func (g gale) Setup() string { - return "curl -sfLo install_gale.sh https://raw.githubusercontent.com/aweris/gale/main/hack/install.sh; GALE_VERSION=" + g.version + " BIN_DIR=" + g.dir + " sh ./install_gale.sh" -} - -// Run returns a command as `gale ` with correct paths to gale -func (g gale) Run(command string) string { - return fmt.Sprintf("%s/gale %s", g.dir, command) -} - -// Cleanup returns the command to remove gale -func (g gale) Cleanup() string { - return "rm -f ./install_gale.sh" + g.dir + "/gale" -} diff --git a/demo/go.mod b/demo/go.mod deleted file mode 100644 index 6dcdd572..00000000 --- a/demo/go.mod +++ /dev/null @@ -1,18 +0,0 @@ -module github.com/aweris/gale/demo - -go 1.20 - -require ( - github.com/saschagrunert/demo v0.0.0-20230724143501-6e07fb7f828c - github.com/urfave/cli/v2 v2.25.7 -) - -require ( - github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect - github.com/gookit/color v1.5.4 // indirect - github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect - github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect - golang.org/x/sys v0.12.0 // indirect - golang.org/x/tools v0.11.1 // indirect -) diff --git a/demo/go.sum b/demo/go.sum deleted file mode 100644 index e0f22ef8..00000000 --- a/demo/go.sum +++ /dev/null @@ -1,28 +0,0 @@ -github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= -github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE= -github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0= -github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w= -github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU= -github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= -github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/saschagrunert/demo v0.0.0-20230724143501-6e07fb7f828c h1:JaTaTIgX32K3f0geha8wm4ZqD2yYIDXSORk+UJyEGkI= -github.com/saschagrunert/demo v0.0.0-20230724143501-6e07fb7f828c/go.mod h1:eRbdzsafrf/YVYdeiQi5FPGPed19jxV390GkP05Uysc= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= -github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= -github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8= -github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= -golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= -golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= -golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= -golang.org/x/tools v0.11.1 h1:ojD5zOW8+7dOGzdnNgersm8aPfcDjhMp12UfG93NIMc= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/demo/main.go b/demo/main.go deleted file mode 100644 index 77175e89..00000000 --- a/demo/main.go +++ /dev/null @@ -1,83 +0,0 @@ -package main - -import ( - "github.com/saschagrunert/demo" -) - -func main() { - d := demo.New() - - d.Setup(env.Setup) - - d.Add(list(), "list", "List all workflows and jobs under it for current repositories `main` branch") - d.Add(run(), "run", "Run golangci-lint job from ci/workflows/lint workflow for aweris/gale repository default branch") - d.Add(lintGoreleaser(), "lint-goreleaser", "Run golangci job from golangci-lint workflow for goreleaser/goreleaser repository tag v1.19.2") - d.Add(shellRun(), "shell-run", "Run example workflow contains steps with different shells") - d.Add(testDagger(), "test-dagger", "Run sdk-go job from test workflow for dagger/dagger repository branch main") - d.Add(testCache(), "test-cache", "Use cache in the workflow") - - d.Cleanup(env.Cleanup) - - d.Run() -} - -// list returns a demo run for the list command for current repository -func list() *demo.Run { - r := demo.NewRun("List Workflows") - - r.Step([]string{"List all available workflows under ci/workflows directory"}, env.RunGaleWithDagger("list --branch main")) - - return r -} - -func run() *demo.Run { - r := demo.NewRun("Run Workflow") - - r.Step([]string{"Contents of the workflow file"}, demo.S("curl https://raw.githubusercontent.com/aweris/gale/main/ci/workflows/lint.yaml")) - - r.Step([]string{"Run the workflow from custom directory for current repository"}, env.RunGaleWithDagger("run --repo aweris/gale --workflows-dir ci/workflows ci/workflows/lint.yaml golangci-lint")) - - return r -} - -func lintGoreleaser() *demo.Run { - r := demo.NewRun("Run golangci job from golangci-lint workflow for goreleaser v1.19.2") - - r.Step([]string{"Contents of the workflow file"}, demo.S("curl https://raw.githubusercontent.com/goreleaser/goreleaser/v1.19.2/.github/workflows/lint.yml")) - - r.Step([]string{"Run the workflow from custom directory for goreleaser/goreleaser repository"}, env.RunGaleWithDagger("run --repo goreleaser/goreleaser --tag v1.19.2 golangci-lint golangci")) - - return r -} - -func shellRun() *demo.Run { - r := demo.NewRun("Run example workflow contains steps with different shells") - - r.Step([]string{"Contents of the workflow file"}, demo.S("curl https://raw.githubusercontent.com/aweris/gale/main/ci/workflows/step-run.yaml")) - - r.Step([]string{"Run the workflow from custom directory for current repository"}, env.RunGaleWithDagger("run --repo aweris/gale --workflows-dir ci/workflows shell run")) - - return r -} - -func testDagger() *demo.Run { - r := demo.NewRun("Run sdk-go job from test workflow for dagger main") - - r.Step([]string{"Contents of the workflow file"}, demo.S("curl https://raw.githubusercontent.com/dagger/dagger/main/.github/workflows/test.yml")) - - r.Step([]string{"Run the workflow from custom directory for dagger/dagger repository"}, env.RunGaleWithDagger("run --repo dagger/dagger --branch main test sdk-go")) - - return r -} - -func testCache() *demo.Run { - r := demo.NewRun("Use cache") - - r.Step([]string{"Contents of the workflow file"}, demo.S("curl https://raw.githubusercontent.com/aweris/gale/main/ci/workflows/artifact-cache.yaml")) - - r.Step([]string{"What we expect to see here", "if cache exist, it'll print contents of the cache file", "if cache doesn't exist, it'll generate a new file, use it then upload it to cache"}, nil) - - r.Step([]string{"Run the workflow"}, env.RunGaleWithDagger("run --repo aweris/gale --workflows-dir ci/workflows ci/workflows/artifact-cache.yaml test")) - - return r -} diff --git a/go.work b/go.work index e4c587f2..296fddf9 100644 --- a/go.work +++ b/go.work @@ -2,6 +2,5 @@ go 1.20 use ( . - ./demo ./internal/mage ) diff --git a/go.work.sum b/go.work.sum index 550a9ebc..de0fe280 100644 --- a/go.work.sum +++ b/go.work.sum @@ -45,6 +45,7 @@ github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmf github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+UbP35JkH8yB7MYb4q/qhBarqZE6g= github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E= @@ -151,6 +152,7 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/sftp v1.13.1 h1:I2qBYMChEhIjOgazfJmV3/mZM256btk6wkCDRmW7JYs= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/sagikazarmark/crypt v0.10.0 h1:96E1qrToLBU6fGzo+PRRz7KGOc9FkYFiPnR3/zf8Smg= github.com/sagikazarmark/crypt v0.10.0/go.mod h1:gwTNHQVoOS3xp9Xvz5LLR+1AauC5M6880z5NWzdhOyQ= github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= @@ -167,6 +169,7 @@ github.com/urfave/cli/v2 v2.25.5 h1:d0NIAyhh5shGscroL7ek/Ya9QYQE0KNabJgiUinIQkc= github.com/urfave/cli/v2 v2.25.5/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= github.com/vektah/gqlparser/v2 v2.5.3/go.mod h1:z8xXUff237NntSuH8mLFijZ+1tjV1swDbpDqjJmk6ME= github.com/vektah/gqlparser/v2 v2.5.6/go.mod h1:z8xXUff237NntSuH8mLFijZ+1tjV1swDbpDqjJmk6ME= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= @@ -196,7 +199,10 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= +golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6 h1:QE6XYQK6naiK1EPAe1g/ILLxN5RBoH5xkJk3CqlMI/Y= +golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E= golang.org/x/image v0.0.0-20190802002840-cff245a6509b h1:+qEpEAPhDZ1o0x3tHzZTQDArnOixOzGD9HUJfcg0mb4= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 h1:2M3HP5CCK1Si9FQhwnzYhXdG6DXeebvUHFpre8QvbyI= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028 h1:4+4C/Iv2U4fMZBiMCc98MG1In4gJY5YRhtpDNeDeHWs= @@ -222,6 +228,7 @@ golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -236,9 +243,11 @@ golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4= +golang.org/x/tools v0.9.3 h1:Gn1I8+64MsuTb/HpH+LmQtNas23LhUVr3rYZ0eKuaMM= golang.org/x/tools v0.9.3/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= golang.org/x/tools v0.11.0/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8= golang.org/x/tools v0.11.1/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8= +golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=