DEV Community 👩‍💻👨‍💻

Cover image for Getting started with GitHub Actions for Rust
Roger Torres (he/him/ele)
Roger Torres (he/him/ele)

Posted on

Getting started with GitHub Actions for Rust

TL;DR: Create an Action on GitHub so your code gets built and tested after every push, and do all this with nothing more than a "next-next-finish".

You never used GitHub Actions and you want do do it with your Rust project; if that's the case, this might help you.

What is and Why GitHub Actions?

GitHub Actions automatize software workflow, which per se is not CI/CD (Continuous Integration/Continuous Delivery), but is used in this method.

So, which workflow are we going to automatize? Test and build. In other words, this:

$ cargo test
$ cargo build
Enter fullscreen mode Exit fullscreen mode

How to do it

First, open your GitHub repository and go to Actions.
GitHub Actions

The example is from this repository that I wrote about here.

This will lead you to this GitHub proposal, which will do exactly what we're set to do here, i.e., build and test:
Workflow proposal

GitHub will preview the .yml file it will create. For this scope, you don't have to change anything (except maybe the name from "Rust" to something else — I used "test").
yml preview

Commit the change clicking on the button that will appear on the right and the file will be created:
After commit

Now, if you go to Actions again, you will see GitHub creating your .yml file. For me, it took around 2 minutes.
Building ymlyml built

And that's it. From now on, every time you push against the repository, GitHub will run the tests for you.
After push

To see the result of the commit above, see the Build log here.

And that's all for today.

See ya 🙃

Cover image by Susan Q Yin

Top comments (0)

🌚 Browsing with dark mode makes you a better developer.

It's a scientific fact.