Skip to content

Commit 992a761

Browse files
committed
feat: install redis plugin in CI and skip service tests if plugin missing
1 parent c18e67a commit 992a761

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,7 @@ jobs:
3838
sudo apt-get update -qq
3939
sudo DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true apt-get install -qq -y dokku
4040
sudo dokku plugin:install-dependencies --core
41+
- name: install dokku redis plugin
42+
run: sudo dokku plugin:install https://github.com/dokku/dokku-redis.git redis
4143
- name: run integration tests
4244
run: sudo go test -v -count=1 -run TestIntegration ./tasks/

tasks/integration_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package tasks
33
import (
44
"omakase/subprocess"
55
"os"
6+
"strings"
67
"testing"
78
)
89

@@ -25,6 +26,31 @@ func skipIfNoDokkuT(t *testing.T) {
2526
}
2627
}
2728

29+
func dokkuPluginInstalled(plugin string) bool {
30+
result, err := subprocess.CallExecCommand(subprocess.ExecCommandInput{
31+
Command: "dokku",
32+
Args: []string{"plugin:list"},
33+
})
34+
if err != nil {
35+
return false
36+
}
37+
38+
for _, line := range strings.Split(result.StdoutContents(), "\n") {
39+
fields := strings.Fields(line)
40+
if len(fields) > 0 && fields[0] == plugin {
41+
return true
42+
}
43+
}
44+
return false
45+
}
46+
47+
func skipIfPluginMissingT(t *testing.T, plugin string) {
48+
t.Helper()
49+
if !dokkuPluginInstalled(plugin) {
50+
t.Skipf("skipping integration test: dokku plugin %q not installed", plugin)
51+
}
52+
}
53+
2854
func TestIntegrationAppCreateAndDestroy(t *testing.T) {
2955
skipIfNoDokkuT(t)
3056

@@ -937,6 +963,7 @@ func TestIntegrationMultiTaskWorkflow(t *testing.T) {
937963

938964
func TestIntegrationServiceCreateAndDestroy(t *testing.T) {
939965
skipIfNoDokkuT(t)
966+
skipIfPluginMissingT(t, "redis")
940967

941968
serviceName := "omakase-test-service"
942969
serviceType := "redis"

0 commit comments

Comments
 (0)