In collaborative coding, code quality is paramount.
Discover the power of GitHub Actions for seamless automated testing on each pull request. This concise guide equips developers with the technical know-how to effortlessly integrate and receive quick feedback on their code changes.
Concepts
- Desired prior knowledge: YAML, Git versioning
What are GitHub actions?
GitHub Actions is a powerful automation feature integrated into the GitHub platform, enabling developers to define custom workflows directly within their repositories.
Why use GitHub actions?
GitHub Actions facilitates a streamlined and customizable continuous integration and delivery (CI/CD) process, automating repetitive tasks and enhancing collaboration among the development team.



Let’s talk. Cloudnonic is here to help you harness the power of custom software solutions to not only catch your audience’s eye but keep it. Pick a time for a free software audit here: Schedule a call with me
Implementing GitHub Actions
Let’s say you’re working on a React project and use Jest to test your App. Now, you want to implement GitHub Actions to automatically run tests when a Pull Request (PR) is created. In this use case, you would create a workflow in your repository’s YAML file. This workflow would trigger each time a PR is opened, executing tests to ensure the integrity of the proposed code.
The YAML file looks like this:
name: Running Test...
on:
pull_request:
branches: [develop]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm install
- name: Run Tests
run: npm run test
- Note: Put this file in the right folder (.github/workflows) to allow GitHub access to your workflow.
Understanding the YAML file:
- Name the workflow and specify the event/branches that trigger it.
name: Running Test...
on:
pull_request:
branches: [develop]
- A job named ‘test’ is defined in the list, which runs on Ubuntu.
jobs:
test:
runs-on: ubuntu-latest
- Check out your repository’s code and ensure that the full commit history is fetched.
- uses: actions/checkout@v3
with:
fetch-depth: 0
- Set up the Node.js environment and specify the version to use (in this case, version 18).
- uses: actions/setup-node@v3
with:
node-version: 18
- Install the project dependencies using NPM package manager.
- name: Install dependencies
run: npm install
- Execute the command to run your tests.
- name: Run Tests
run: npm run test
Finally
If everything was ok:

If something went wrong:

You can dive into this by reading the official documentation
In short, GitHub Actions is a powerful tool for automating workflows within a GitHub repository. It enhances development efficiency, boosts code quality, and fosters collaboration among team members.
Leave a Reply