-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mark Sagi-Kazar <[email protected]>
- Loading branch information
1 parent
7fcf6a6
commit 7dd1ae5
Showing
3 changed files
with
115 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/sagikazarmark/dagx/pipeline" | ||
|
||
"github.com/twirphp/twirp/.dagger/internal/dagger" | ||
) | ||
|
||
// Run e2e tests. | ||
func (m *Tests) Etoe() *Etoe { | ||
return &Etoe{ | ||
Main: m.Main, | ||
PhpVersion: m.PhpVersion, | ||
} | ||
} | ||
|
||
type Etoe struct { | ||
// +private | ||
Main *Twirp | ||
|
||
// +private | ||
PhpVersion string | ||
} | ||
|
||
func (m *Etoe) All(ctx context.Context) error { | ||
p := pipeline.New(ctx) | ||
|
||
pipeline.AddSyncSteps(p, | ||
m.Clientcompat(m.PhpVersion), | ||
m.Complete(m.PhpVersion), | ||
m.NoServices(m.PhpVersion), | ||
) | ||
|
||
if m.PhpVersion != "7.4" { | ||
pipeline.AddSyncStep(p, m.Namespace(m.PhpVersion)) | ||
} | ||
|
||
return pipeline.Run(p) | ||
} | ||
|
||
func (m *Etoe) source(name string) *dagger.Directory { | ||
return m.Main.Source.Directory("tests/" + name) | ||
} | ||
|
||
// TODO: make sure Composer dependencies are installed | ||
func (m *Etoe) fullSourceWithCodegen(name string) *dagger.Directory { | ||
generated := m.Main.generate(m.source(name)) | ||
|
||
return m.Main.Source.WithDirectory("tests/"+name+"/generated", generated) | ||
} | ||
|
||
func (m *Etoe) container(name string, phpVersion string) *dagger.Container { | ||
if phpVersion == "" { | ||
phpVersion = defaultPhpVersion | ||
} | ||
|
||
return phpBase(phpVersion).Container(). | ||
WithFile("/usr/local/bin/clientcompat", m.Main.Clientcompat("")). | ||
WithDirectory("/work", m.fullSourceWithCodegen(name)). | ||
WithWorkdir("/work"). | ||
WithExec([]string{"composer", "install"}). | ||
WithWorkdir("/work/tests/" + name) | ||
} | ||
|
||
func (m *Etoe) Clientcompat( | ||
// +optional | ||
phpVersion string, | ||
) *dagger.Container { | ||
return m.container("clientcompat", phpVersion). | ||
WithExec([]string{"clientcompat", "-client", "./compat.sh"}) | ||
} | ||
|
||
func (m *Etoe) Complete( | ||
// +optional | ||
phpVersion string, | ||
) *dagger.Container { | ||
return m.container("complete", phpVersion). | ||
WithExec([]string{"../../lib/vendor/bin/phpunit", "-v"}) | ||
} | ||
|
||
func (m *Etoe) Namespace( | ||
// +optional | ||
phpVersion string, | ||
) *dagger.Container { | ||
return m.container("namespace", phpVersion). | ||
WithExec([]string{"php", "test.php"}) | ||
} | ||
|
||
func (m *Etoe) NoServices( | ||
// +optional | ||
phpVersion string, | ||
) *dagger.Container { | ||
return m.container("no_services", phpVersion). | ||
WithExec([]string{"bash", "-c", `test ! -f generated/Twirp/Tests/No_services/Proto/TwirpError.php || (echo "TwirpError.php should not be generated when there are no services defined in any of the proto files"; exit 1)`}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters