<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Em Floc&#39;h on Medium]]></title>
        <description><![CDATA[Stories by Em Floc&#39;h on Medium]]></description>
        <link>https://medium.com/@emeline-floch?source=rss-e56d3a5f15dd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*IxcbG16WAGKzUPPrgX2TeA.jpeg</url>
            <title>Stories by Em Floc&amp;#39;h on Medium</title>
            <link>https://medium.com/@emeline-floch?source=rss-e56d3a5f15dd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 17:31:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@emeline-floch/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Speed up your pytest GitHub Actions with Docker]]></title>
            <link>https://medium.com/data-science/speed-up-your-pytest-github-actions-with-docker-6b3a85b943f?source=rss-e56d3a5f15dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b3a85b943f</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[pytest]]></category>
            <category><![CDATA[yaml]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Em Floc'h]]></dc:creator>
            <pubDate>Wed, 18 Nov 2020 00:14:00 GMT</pubDate>
            <atom:updated>2021-01-06T16:55:55.188Z</atom:updated>
            <content:encoded><![CDATA[<h4>A simple guide to running GitHub Actions in Docker containers and save some precious minutes (and dollars) on your pytest runtime</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ni9jdXubXezGnZH_eFPgnw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@victoire_jonch?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Victoire Joncheray</a> on <a href="https://unsplash.com/s/photos/container?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>GitHub introduced Actions in 2018 as a fast and easy to set up CI/CD solution. Because of its recent release date, documentation on the topic is sometimes hard to find and I couldn’t put my hands on something that explained how to set up your Actions that run pytest in a pipenv environment into a Docker container. Here is a quick summary of the method I used on a Mac.</p><h3>1. Install Docker.</h3><p>To install Docker, download Docker Desktop <a href="https://www.docker.com/products/docker-desktop">from the homepage</a>, and follow the instructions on the desktop app. You’ll need to create a Docker Hub account to publish your Docker image and be able to use it in your GitHub Actions.</p><h3>2. Create a Docker image with Pipenv.</h3><p>To create a Docker image, create a file called <em>Dockerfile</em> in your python project root folder, at the same level as your Pipfile.</p><p>In <em>Dockerfile</em> copy the following lines.</p><pre># Get the python 3.8 base docker image<br>FROM python:3.8</pre><pre># Install pipenv<br>RUN pip install pipenv</pre><pre># Copy your Pipfile and Pipfile.lock in your container<br>COPY Pipfile .<br>COPY Pipfile.lock .</pre><pre># Install all the dependencies from your lock file directly into the # container<br>RUN pipenv install — system — deploy</pre><p>Once you’ve saved the Dockerfile, run the following commands to update your Pipfile.lock file, build your docker container using your Docker Hub username then push your Docker image to Docker Hub.</p><pre>&gt;&gt; pipenv lock<br>&gt;&gt; docker build -t &lt;hub-username&gt;/&lt;repo-name&gt;<br>&gt;&gt; docker push &lt;hub-username&gt;/&lt;repo-name&gt;</pre><p>You now have a docker image pushed to Docker Hub and it should appear in your account. You are now ready to use it within your Github Actions workflow.</p><h3>3. Setup your GitHub Actions to run within your docker container.</h3><p>The last step is creating a workflow that runs pytest in your container. Follow the following template and copy these lines in a YAML file.</p><pre>name: Pytest with Pipenv &amp; Docker</pre><pre># workflow triggered by any push on any branch<br>on: [push]</pre><pre>jobs:<br>  build:<br>    name: Pytest in Pipenv</pre><pre>    # runs on the latest Ubuntu<br>    runs-on: ubuntu-latest </pre><pre>    # runs within your Docker container<br>    container:<br>      image: docker://&lt;hub-username&gt;/&lt;repo-name&gt;:latest</pre><pre>    # checkout your code from your repository<br>    # and runs pytest in your pipenv environment<br>    steps:<br>    - uses: actions/checkout@v2<br>    - name: Test with pytest<br>      run: |<br>          pipenv run pytest tests/<br>      </pre><p>Save this file in your .github/workflows/ folder. Once all these steps are done and you push code to your repository with tests in your tests/ folder, you should see on the GitHub Actions page that your container has been initialized and that your tests have been run in the container. You should also see that the setup of the local environment was much faster than by simply installing the dependencies from the pipfile in your workflow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KV8Rpe0bIhNTh_gDtcqzSg.png" /><figcaption>Screenshot from the Actions page on Github once the workflow has been run.</figcaption></figure><p>And there you have it, the easiest way to speed up your pytest in Github Actions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b3a85b943f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/speed-up-your-pytest-github-actions-with-docker-6b3a85b943f">Speed up your pytest GitHub Actions with Docker</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>