A Developer's Dive into GitHub Actions CI
Published: 2023-11-17 03:52:53

### Introduction

In the developer's toolkit, Continuous Integration (CI) is an essential asset, and GitHub Actions represents a modern approach to this practice. My recent exploration into setting up a GitHub Actions CI workflow for my `tml` project, and contributing tests to a fellow developer's project, was a journey worth sharing. From YAML configurations to different project structures, here's how it unfolded.


### Setting Up GitHub Actions CI

#### Crafting the Workflow
My project, a text-to-HTML converter named `tml`, needed a robust way to ensure code quality. Enter GitHub Actions. The setup involved creating a YAML file in the `.github/workflows` directory, defining the conditions under which the CI pipeline would trigger.

#### Inside the YAML
The YAML file, named `main.yml`, was the blueprint. Here’s a peek at its structure:

```yaml
name: Python application test

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - 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 pytest tomli requests
    - name: Run tests
      run: |
        pytest
```

This script essentially sets up the environment, installs dependencies, and runs `pytest` to check the integrity of the codebase.


### Experience with a Partner’s Repository

#### Observing Variations
My partner, also working on a Python project, adopted a different CI strategy. Their setup was tailored to their specific project needs, employing Python's latest versions and its native testing frameworks. This divergence highlighted the flexibility of GitHub Actions, accommodating various workflows and testing strategies.

#### Writing Tests for Different Setups
Contributing tests to a project I didn't initially create was both challenging and rewarding. It demanded a deep dive into understanding another developer's logic and code structure. This process emphasized the importance of writing clear, maintainable code and tests in collaborative environments.


### Reflecting on CI in Development

#### CI as a Unifying Force
Despite the differences in our CI setups, the essence of CI remained consistent – automating the testing process to maintain high code quality. My experience highlighted CI's role as a unifying force in software development, adaptable to different environments yet consistently ensuring reliability.


#### The Learning Curve and Benefits
The initial setup of CI was a learning curve, involving understanding YAML configurations and troubleshooting workflow issues. However, the benefits became quickly apparent – CI acts as a safeguard, catching issues early and providing peace of mind with each new code integration.


### Conclusion

Setting up and experiencing GitHub Actions CI in my own project and observing a different approach in my partner's project was an enlightening experience. It underscored the versatility of CI tools and the importance of automated testing in modern software development. As I continue my development journey, the lessons learned from this experience will undoubtedly shape my approach to coding and collaboration.