#Exit(1) and exporting directory

1 messages ยท Page 1 of 1 (latest)

clear saffron
#

Hey, we have a e2e test script that sometimes exit's with code 1. We'd like to export a test report directory after that but it doesn't seem to work. Here's a minimal repro of what we found:

package main

import (
    "context"
    "dagger.io/dagger"
    "os"
)

func main() {
    ctx := context.Background()
    client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr))

    if err != nil {
        panic(err)
    }
    dir := client.Directory().WithNewFile("test.py", `
print("exiting")
exit(1)
`)

    ctr := client.Container().From("python").
        WithDirectory("app", dir).
        WithWorkdir("app").
        WithExec([]string{"python3", "test.py"})

    ctr.Directory("").Export(ctx, "test-export")
}

I'd expect the directory export still to work even if the test.py fails. If I do exit(0) the export works.

Is this expected? Am I missing something?

Thanks!

#

If this is a bug in Dagger I'm happy to open issue to Github. But first checking here that it's not a user error ๐Ÿ™‚

edgy rivet
clear saffron
#

Thanks! Has it always been this way. I recall us needing manually check failing execs previously (~year ago when I started using Dagger). Might be that we just didn't know what we were doing back then ๐Ÿ˜„

edgy rivet
#

We used to have a ExitCode() function, so we had a lot of examples that would show something like if ctr.ExitCode() != 0, but that actually didn't work because if the pipeline failed it would never make it to the ExitCode for the same reason it doesn't get to Export ๐Ÿ˜