Verify cross built workflow assets
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"debug/elf"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@@ -11,6 +13,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -78,11 +81,15 @@ func TestMultiModuleWoodpeckerDelivery(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("binary delivery from physical major module", func(t *testing.T) {
|
t.Run("binary delivery from physical major module", func(t *testing.T) {
|
||||||
const tag = "integrations/core/v2.1.0"
|
const tag = "integrations/core/v2.1.0"
|
||||||
|
arch, machine := "arm64", elf.EM_AARCH64
|
||||||
|
if runtime.GOOS == "linux" && runtime.GOARCH == arch {
|
||||||
|
arch, machine = "amd64", elf.EM_X86_64
|
||||||
|
}
|
||||||
delivery := newMappedDeliveryFixture(t, tag)
|
delivery := newMappedDeliveryFixture(t, tag)
|
||||||
repository := newWorkflowRepository(t, example)
|
repository := newWorkflowRepository(t, example)
|
||||||
writeMappedProfile(t, repository, "releasekit-core-v2.json", cli.Settings{
|
writeMappedProfile(t, repository, "releasekit-core-v2.json", cli.Settings{
|
||||||
Product: "Example Consumer Core v2", ModuleDir: "integrations/core/v2",
|
Product: "Example Consumer Core v2", ModuleDir: "integrations/core/v2",
|
||||||
Build: &cli.BuildSettings{MainPackage: ".", BinaryName: "core", Targets: []string{"linux/amd64"}},
|
Build: &cli.BuildSettings{MainPackage: ".", BinaryName: "core", Targets: []string{"linux/" + arch}},
|
||||||
Delivery: workflowDeliverySettings(delivery.snapshot().URL),
|
Delivery: workflowDeliverySettings(delivery.snapshot().URL),
|
||||||
})
|
})
|
||||||
writeRepositoryFile(t, repository, "integrations/core/v2/docs/releases/v2.1.0.md", "# Example Consumer Core v2 v2.1.0\n\nTagged core note.\n")
|
writeRepositoryFile(t, repository, "integrations/core/v2/docs/releases/v2.1.0.md", "# Example Consumer Core v2 v2.1.0\n\nTagged core note.\n")
|
||||||
@@ -98,8 +105,17 @@ func TestMultiModuleWoodpeckerDelivery(t *testing.T) {
|
|||||||
if observed.creates != 1 || observed.uploads != 2 || observed.tag != tag {
|
if observed.creates != 1 || observed.uploads != 2 || observed.tag != tag {
|
||||||
t.Fatalf("binary delivery fixture = %#v", observed)
|
t.Fatalf("binary delivery fixture = %#v", observed)
|
||||||
}
|
}
|
||||||
if _, ok := observed.assets["core-v2.1.0-linux-amd64"]; !ok {
|
name := "core-v2.1.0-linux-" + arch
|
||||||
t.Fatalf("binary asset missing: %#v", observed.assets)
|
asset, ok := observed.assets[name]
|
||||||
|
if !ok {
|
||||||
|
t.Fatalf("binary asset %q missing", name)
|
||||||
|
}
|
||||||
|
binary, err := elf.NewFile(bytes.NewReader(asset))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("read uploaded %s as ELF: %v", name, err)
|
||||||
|
}
|
||||||
|
if binary.Machine != machine {
|
||||||
|
t.Fatalf("uploaded %s machine = %s, want %s", name, binary.Machine, machine)
|
||||||
}
|
}
|
||||||
if _, ok := observed.assets["SHA256SUMS"]; !ok {
|
if _, ok := observed.assets["SHA256SUMS"]; !ok {
|
||||||
t.Fatalf("checksum asset missing: %#v", observed.assets)
|
t.Fatalf("checksum asset missing: %#v", observed.assets)
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ paste the command.
|
|||||||
|
|
||||||
## Exercise a profile target that differs from the launcher host
|
## Exercise a profile target that differs from the launcher host
|
||||||
|
|
||||||
|
**Completed.** The binary delivery fixture selects a non-host Linux target and checks the uploaded ELF machine as well as the filename.
|
||||||
|
|
||||||
**Evidence:** The binary-delivery case in
|
**Evidence:** The binary-delivery case in
|
||||||
[`TestMultiModuleWoodpeckerDelivery`](../../cmd/releasekit/multi_module_woodpecker_test.go)
|
[`TestMultiModuleWoodpeckerDelivery`](../../cmd/releasekit/multi_module_woodpecker_test.go)
|
||||||
supplies a foreign target to the workflow and checks the uploaded
|
supplies a foreign target to the workflow and checks the uploaded
|
||||||
|
|||||||
Reference in New Issue
Block a user