DEV Community

Vishnu Das Puthukudi
Vishnu Das Puthukudi

Posted on

Setting up GitHub Actions CI Workflow for Text2page project

In the project root, I made a file called.github/workflows/ci.yml to configure GitHub Actions for Continuous Integration. This is how the YAML workflow file appeared:

name: CI

on:
  push:
    branches:
      - main

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout repository
      uses: actions/checkout@v2

    - name: Set up Python
      uses: actions/setup-python@v2
      with:
        python-version: 3.8

    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install -r requirements.txt

    - name: Run tests
      run: |
        python -m unittest discover -s tests -p 'test_*.py'

Enter fullscreen mode Exit fullscreen mode

This process checks out the repository, installs dependencies, installs Python, and runs the unit tests using unittest. It is triggered by each push to the main branch.

I provided tests for the processDirectory function in my partner's code as part of our collaborative testing experience. I became acquainted with their project structure by navigating their repository and looking through the README and CONTRIBUTING files. This partnership required me to adjust to their testing environment and any potential language or framework incompatibilities, unlike my original codebase. Understanding testing conventions and procedures required reading their documentation. Carefully examining the foreign codebase, identifying places lacking appropriate test coverage, and aligning with the project's objectives were necessary before adding tests. Clarity in communication was crucial, and prior to submitting the pull request, local tests were conducted to guarantee smooth integration and compliance with their continuous integration (CI) procedure. Overall, the experience highlighted flexibility, good communication, and the common objective of improving the codebase.

CI setup has proven to be a useful experience. It ensures that code updates don't create new defects and that the project stays in a deployable condition by automating the testing process. Any faults may be promptly identified with the aid of the visual feedback that CI pipelines in the GitHub Actions interface give.

Top comments (0)