Skip to content

Commit

Permalink
Fix flow docker build (#892)
Browse files Browse the repository at this point in the history
* Fix flow docker build

- add build-essential to system deps; note that this is required for snowflake-connector-python
- forward build errors to user

* Add test for JSONError

* Use apt-install-and-clean

- fix linting issues
  • Loading branch information
feluelle authored and neel-astro committed Nov 22, 2022
1 parent cad3ed0 commit b6c91f5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions sql/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ func displayMessages(r io.Reader) error {
if jsonMessage.Stream == "\n" {
continue
}
if jsonMessage.Error != nil {
return jsonMessage.Error
}
// We only print steps which are actually running, e.g.
// Step 2/4 : ENV ASTRO_CLI Yes
// ---> Running in 0afb2e0c5ad7
Expand Down
2 changes: 1 addition & 1 deletion sql/flow_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func GetBaseDockerImageURI(configURL string) (string, error) {
var resp configResponse
err = json.NewDecoder(res.Body).Decode(&resp)
if err != nil {
return defaultDockerImageURI, fmt.Errorf("error parsing the base docker image from the configuration file: %w", err)
return defaultDockerImageURI, fmt.Errorf("error parsing the base docker image from the configuration file: %w. Using the default", err)
}

return resp.BaseDockerImage, nil
Expand Down
10 changes: 10 additions & 0 deletions sql/flow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ Step 2/4 : ENV ASTRO_CLI Yes
assert.Equal(t, expectedOutput, string(out))
}

func TestDisplayMessagesHasError(t *testing.T) {
jsonMessage := jsonmessage.JSONMessage{Error: &jsonmessage.JSONError{Message: "An error has occurred."}}
data, err := json.Marshal(jsonMessage)
assert.NoError(t, err)

reader := bytes.NewReader(data)
err = DisplayMessages(reader)
assert.Error(t, err)
}

func TestDockerClientInitFailure(t *testing.T) {
DockerClientInit = func() (DockerBind, error) {
return nil, errMock
Expand Down
4 changes: 4 additions & 0 deletions sql/include/dockerfile_content.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ FROM %s
ENV ASTRO_CLI Yes
# build-essential is necessary to be able to build wheels for snowflake-connector-python
RUN apt-install-and-clean \
build-essential
RUN pip install astro-sql-cli==%s
`)

0 comments on commit b6c91f5

Please sign in to comment.