Chapter 11 - Testing on Linux fails (possibly outdated dependencies?)

Hello all. I’ve got a weird error when running docker-compose up --abort-on-container-exit. Seems like some dependencies aren’t compatible or something. Could someone please explain what’s going on and maybe suggest a fix?

05

@thedan84 have you updated the Swift version in the Dockerfiles? Could you post the docker file? 5.1 removed OpenSSL so you’d need to add that back in

@0xtim Here are the contents of the Dockerfile:

FROM swift:5.1

WORKDIR /package

COPY . ./

RUN swift package resolve
RUN swift package clean

CMD ["swift", "test"]

Yes, I have updated the Swift version in the Docker file, should I go back to 4.2 to make it work? Or just add OpenSSL to my Swift Package?

I managed to get rid of the errors by changing the Swift version to 4.2.
But now it fails because the Google and/or GitHub callback URLs aren’t set, although I’ve added them to the Environment variables. The tests succeed in Xcode, but I guess because the Xcode project is discarded when running the app in Linux the variables aren’t accessible anymore?

@thedan84 yeah you don’t have any access to the Xcode set environment variables inside Docker. One way I get around it is to hard code some test environment variables when you’re running tests (by looking to see if env == .testing). You can pass environment variables to your container with -e GOOGLE_CALLBACK_URL=http://localhost:8080/ when doing docker run

For the language stuff - you can use FROM swift 5.1.1 you just need to add these lines before you do any building

@0xtim Thanks a lot for the hints. Will try it out.