feat: 支持多APK与渠道变体,增加自动定位的服务管理CLI
This commit is contained in:
1 parent
7984785610
commit
87652364bc
33 files changed
+1110
-42
No files matched your search
@@ -0,0 +1,54 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMultipleChannelAndSignedArtifacts(t *testing.T) {
|
||||
s := testServer(t)
|
||||
p := project(t, s)
|
||||
paths := []string{"app/build/outputs/apk/uiui/debug/app.apk", "app/build/outputs/apk/uiuios/debug/app.apk", "app/build/outputs/apk/uiui/debug/app-signed.apk"}
|
||||
wrapper := "#!/bin/sh\n"
|
||||
name := "gradlew"
|
||||
if runtime.GOOS == "windows" {
|
||||
wrapper = "@echo off\r\n"
|
||||
name = "gradlew.bat"
|
||||
}
|
||||
for i, path := range paths {
|
||||
dir := filepath.ToSlash(filepath.Dir(path))
|
||||
if runtime.GOOS == "windows" {
|
||||
wrapper += "mkdir " + strings.ReplaceAll(dir, "/", `\`) + " 2>nul\r\necho artifact" + string(rune('0'+i)) + ">" + strings.ReplaceAll(path, "/", `\`) + "\r\n"
|
||||
} else {
|
||||
wrapper += "mkdir -p " + dir + "\nprintf artifact" + string(rune('0'+i)) + " > " + path + "\n"
|
||||
}
|
||||
}
|
||||
if runtime.GOOS == "windows" {
|
||||
wrapper += "echo signature>app\\build\\outputs\\apk\\uiui\\debug\\app.apk.idsig\r\nexit /b 0\r\n"
|
||||
} else {
|
||||
wrapper += "printf signature > app/build/outputs/apk/uiui/debug/app.apk.idsig\n"
|
||||
}
|
||||
writeFixture(t, filepath.Join(s.work(p), name), wrapper)
|
||||
b := &Build{ID: id(), Project: p, Status: "queued", Task: ":app:assembleDebug"}
|
||||
s.builds[b.ID] = b
|
||||
s.projects[p].Busy = true
|
||||
s.run(b)
|
||||
if b.Status != "success" || len(b.Artifacts) != 3 {
|
||||
t.Fatalf("%s %v %v", b.Status, b.Artifacts, b.Logs)
|
||||
}
|
||||
seen := map[string]bool{}
|
||||
for _, a := range b.Artifacts {
|
||||
seen[a.SourcePath] = true
|
||||
response := call(t, s, "GET", "/builds/"+b.ID+"/artifacts/"+a.Name, nil)
|
||||
if response.Code != 200 || digest(response.Body.Bytes()) != a.Hash {
|
||||
t.Fatal("artifact content mismatch", a)
|
||||
}
|
||||
}
|
||||
for _, path := range paths {
|
||||
if !seen[path] {
|
||||
t.Fatal("missing artifact provenance", path)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user