How to create a 3 Stage Deployment Pipeline With Github Actions

In this post I will show you how to setup a nice 3 stage deployment pipeline that will lint and test your code before deploying to a specific stage, using Github Actions

I will be simulating a Python application for this post, so you should modify the Python related stuff according to your project.

🔧 Build And Test Workflow

This workflow will lint, type check, and test the project before deploying to any stage. Create a .github/workflows/build-and-test.yml file:

github actions

Python Transactional Tests Using SQL Alchemy, Pytest, and Factory Boy

Knowing how to integrate SQLAlchemy for your automated tests can be a bit tricky. Even after reading several blog posts on how to implement transactional tests with SQLAlchemy and Pytest, it took me a bit of time to make it all play nicely with Factory Boy.

Another key concept that several blog posts out there fail to cover is how SQLAlchemy sessions are handled both in the application and in the test suite.

In this blog post I will teach you how you that is achieved.

python sqlalchemy pytest factoryboy

Django: Adding Context Data to Class Based Views Using Properties

When using Class-Based Views in Django, we normally add additional context data to the view by implementing the get_context_data() method:

class MyDetailView(DetailView):

    def get_context_data(self, *args, **kwargs):
        context = super().get_context_data(*args, **kwargs)
        context['foo'] = 'bar'

        return context

This works well. But I am very fond of using another approach, so as to not pollute the get_context_data method. We can achieve this using properties:

Older Posts →