Automate Your Testing with GitHub Actions: A Simple CI/CD Workflow for Your App
Kaleab Endrias
Backend Developer | Node.js & Python Enthusiast | ALX Software Engineering Graduate | Building Scalable Systems & Real-Time Applications
Why Testing Workflows Important Before Merging Pull Requests
I decided to add a GitHub workflow to check tests for every push and pull request. This helps catch bugs early and ensures that new code doesn't break existing features. It also simplifies code reviews by showing if new code works correctly. Setting up a workflow to test code keeps our project healthy and strong. Let’s make our code better and more reliable!
To set up a GitHub workflow to check tests, follow these steps:
to setup a github workflow to check tests:
// .github/workflows/test.yaml
name: Run Tests
on:
push:
branches:
- '**'
pull_request:
branches:
- '**'
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm install
- name: Run tests
run: npm run test
This workflow will run your tests automatically on every push and pull request, helping ensure code quality and stability.
you can also use this method to check for the likes of linting with adding:
- name: Run linting
run: npm run lint
Co-Founder & Product Owner at Latenode.com & Debexpert.com. Revolutionizing automation with low-code and AI
5 个月Automating your testing with GitHub Actions simplifies your CI/CD workflow and keeps your app running smoothly. Latenode.com can be a great complement, offering a flexible and cost-effective automation platform with advanced features and AI support. ??