-
Notifications
You must be signed in to change notification settings - Fork 222
Running Swift Linux Tests on Mac
We have prepared a way for users to run the Swift Linux tests while developing on Mac. To do so the user needs to download Docker and have it installed on their machines. Instructions on how to get started can be found in the Docker documentation.
Our Dockerfile is pretty straight forward.
FROM swiftdocker/swift:4.0
ADD . /SwiftSDK
WORKDIR /SwiftSDK
RUN rm -rf /SwiftSDK/.build/debug && swift package resolve && swift package clean
CMD swift test
FROM
- The first line creates an image from the swiftdocker Swift version 4.0 base image.
ADD
and WORKDIR
- Then it creates a directory called SwiftSDK on the docker image, copies the working directory into the new directory, and starts the image from there.
RUN
- Next it deletes the .build/debug directory so that it's doesn't have any conflicts on the Docker Container while running the tests. Next it resolves any needed dependencies and cleans the project.
CMD
- Finally it runs swift test
that will run the Linux Tests.
The first step is to create a docker image from the Dockerfile
we have in the swift-sdk directory.
- Open your terminal and navigate to the
swift-sdk
directory. - Run
docker build -t swift-sdk-docker-image .
inside that directory. - Run
docker run swift-sdk-docker-image:latest
Step 1 - You have to be in the directory with the Dockerfile in order to create the image
Step 2 - Create the swift-sdk-docker-image
locally on your machine.
Step 3 - Run the swift-sdk-docker-image
.
From there on you can make as many changes as you'd like.
Then to test your changes by running the Linux Tests, you need to run:
docker run -v /Path/to/your/directory/swift-sdk:/SwiftSDK swift-sdk-docker-image:latest
Because we already created the docker image we no longer have to recreate it. Now we can just overwrite the files/directories we have in the image and can run the tests. Note: You need to give the fully qualified path to your swift-sdk
directory. This is due to the way Docker implements the -v option.