PyBites: The Benefits of Using GitHub Actions


If you’re not using GitHub Actions you’re missing out!

This tool is a great way to catch any errors in the central place of the GitHub repo.

Catch errors early

Of course this is always second best, developers should do their due diligence locally first before pushing code:

Graph of cost of bugs as you go down further down the release pipeline.The sooner you catch bugs the better!

Some of my favorites in that regard are:

  • Set up syntax checking in your editor or IDE. As I am a Vim addict, I use this one.
  • Make it easy to run your tests, I use a combination of a Makefile (example) and a .vimrc shortcut (nmap <leader>y :w<CR>:!pytest<CR>) – we will cover Makefiles soon in another article. For some common Vim tricks, check out this article.
  • Use a pre-commit hook, for example to run black on your code before committing.

Some use cases

But then after pushing, having an automated workflow is awesome and saves a lot of time / resources:

Cost saving graph of automated workflows.Running your tests and quality checks in an automated way will save you a lot of time and thus money.

Not only to run flake8 and pytest against your code, you can also set up further automations all based on certain events:

  • Deploy your code to a cloud provider.
  • Push your package to PyPI.
  • Publish a docker image.
  • Send an SMS.
  • GitHub repo related things.

Here is a curated list of awesome things related to GitHub Actions.

How to set it up?

It’s really easy to set up:

  1. Create a .github/workflows folder structure (tip: use mkdir -p).
  2. Add one or more workflow yaml files – see the quick start guide.

Examples

To wrap this article up I show you 3 examples on our open source repos:

  1. Git stats > workflow file
  2. PyBites Books > workflow file
  3. Karmabot > workflow files (example multiple workflows)

Further resources:



Source link

Latest articles

Related articles

Leave a reply

Please enter your comment!
Please enter your name here