DEV Community

Freddy Adiv
Freddy Adiv

Posted on

Adding CI for projects

Hi all,
As part of the OSDC course, we were asked to add continues integration (CI) for an open source project.
I chose Penn since it have tests but didn't have any CI configured.
These are the steps to add the CI to the project:
1) Fork the project so you can edit it
2) Add an Action -> Continues integration -> Python project, which contains a good starting point for both installation and testing the repository
3) I changed the file so it would fit the installations requirement and added the pytest command like this:

This workflow will install Python dependencies and run tests with a single version of Python for Penn repository

name: Testing Penn

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
  uses: actions/setup-python@v3
  with:
    python-version: "3.10"
- name: Install dependencies
  run: |
    pip install -r requirements.txt && pip install -e .
    pip install pytest
- name: Test with pytest
  run: |
    pytest
Enter fullscreen mode Exit fullscreen mode

4) To activate the workflow, you need to select it from the Actions menu and run it manually.
That's it..
Cheers,
Freddy

Top comments (0)