fix: locate run module before build
This commit is contained in:
@@ -484,15 +484,21 @@ if [ "$COMPONENT_KIND" = "run" ]; then
|
|||||||
rm -rf /workspace/build/run-source
|
rm -rf /workspace/build/run-source
|
||||||
mkdir -p /workspace/build/run-source
|
mkdir -p /workspace/build/run-source
|
||||||
find /workspace/source -mindepth 1 -maxdepth 1 ! -name pax_global_header -exec cp -R {} /workspace/build/run-source/ \;
|
find /workspace/source -mindepth 1 -maxdepth 1 ! -name pax_global_header -exec cp -R {} /workspace/build/run-source/ \;
|
||||||
|
run_command_dir="$(find /workspace/build/run-source -type d -path '*/cmd/run' -print -quit)"
|
||||||
|
run_module_dir="${run_command_dir%/cmd/run}"
|
||||||
|
if [ -z "$run_command_dir" ] || [ ! -f "$run_module_dir/go.mod" ]; then
|
||||||
|
printf 'Run source snapshot must contain a Go module with cmd/run\n' >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
progress 34 'env_check: injecting run build metadata'
|
progress 34 'env_check: injecting run build metadata'
|
||||||
seed_b64="$(base64 /workspace/input/workspace-seed.json | tr -d '\n')"
|
seed_b64="$(base64 /workspace/input/workspace-seed.json | tr -d '\n')"
|
||||||
mkdir -p /workspace/build/run-source/config
|
mkdir -p "$run_module_dir/config"
|
||||||
cat > /workspace/build/run-source/config/workspace_seed_generated.go <<EOF
|
cat > "$run_module_dir/config/workspace_seed_generated.go" <<EOF
|
||||||
package config
|
package config
|
||||||
|
|
||||||
func init() { BuildWorkspaceSeed = "$seed_b64" }
|
func init() { BuildWorkspaceSeed = "$seed_b64" }
|
||||||
EOF
|
EOF
|
||||||
cd /workspace/build/run-source
|
cd "$run_module_dir"
|
||||||
ldflags="-s -w"
|
ldflags="-s -w"
|
||||||
ldflags="$ldflags -X browser.local/run/config.BuildMode=worker"
|
ldflags="$ldflags -X browser.local/run/config.BuildMode=worker"
|
||||||
ldflags="$ldflags -X browser.local/run/config.BuildPlatformURL=$PLATFORM_URL"
|
ldflags="$ldflags -X browser.local/run/config.BuildPlatformURL=$PLATFORM_URL"
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ func TestDockerDistributionBuilderKeepsSecretInIsolatedInput(t *testing.T) {
|
|||||||
if bytes.Contains(script, []byte(secret)) {
|
if bytes.Contains(script, []byte(secret)) {
|
||||||
t.Fatal("build script must not embed the component auth key")
|
t.Fatal("build script must not embed the component auth key")
|
||||||
}
|
}
|
||||||
for _, ordered := range [][2]string{{"find /workspace/source -mindepth 1 -maxdepth 1 ! -name pax_global_header", "mkdir -p /workspace/build/run-source/config"}, {"mkdir -p /workspace/build/run-source/config", "workspace_seed_generated.go"}, {"workspace_seed_generated.go", "go build -trimpath -ldflags"}} {
|
for _, ordered := range [][2]string{{"find /workspace/source -mindepth 1 -maxdepth 1 ! -name pax_global_header", "run_command_dir=\"$(find /workspace/build/run-source -type d -path '*/cmd/run' -print -quit)\""}, {"run_command_dir=\"$(find /workspace/build/run-source -type d -path '*/cmd/run' -print -quit)\"", "run_module_dir=\"${run_command_dir%/cmd/run}\""}, {"run_module_dir=\"${run_command_dir%/cmd/run}\"", "mkdir -p \"$run_module_dir/config\""}, {"mkdir -p \"$run_module_dir/config\"", "workspace_seed_generated.go"}, {"workspace_seed_generated.go", "cd \"$run_module_dir\""}, {"cd \"$run_module_dir\"", "go build -trimpath -ldflags"}} {
|
||||||
if bytes.Index(script, []byte(ordered[0])) >= bytes.Index(script, []byte(ordered[1])) {
|
if bytes.Index(script, []byte(ordered[0])) >= bytes.Index(script, []byte(ordered[1])) {
|
||||||
t.Fatalf("Run build script must prepare source before injecting config and compiling: %q before %q", ordered[0], ordered[1])
|
t.Fatalf("Run build script must prepare source before injecting config and compiling: %q before %q", ordered[0], ordered[1])
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user