UCL-COMP0233-24-25 / RSE-Classwork

6 stars 86 forks source link

Use CI to run the tests for you #14

Open dpshelio opened 3 weeks ago

dpshelio commented 3 weeks ago

Continuous integration (CI) platforms can help us catch failing tests on different operating systems, and different setups than the ones we may have on our local machine. In this exercise, you will use GitHub Actions to do exactly this.

Set up Github Actions to run our tests for every commit we push to our repository.

on: [push]

jobs: build:

runs-on: ubuntu-latest
strategy:
  matrix:
    python-version: ["3.10", "3.13"]

steps:
  - uses: actions/checkout@v4
  - name: Set up Python ${{ matrix.python-version }}
    uses: actions/setup-python@v5
    with:
      python-version: ${{ matrix.python-version }}
  - name: Install dependencies
    # This case we are only updating pip, but you could add other dependencies if needed.
    run: |
      python -m pip install --upgrade pip
      # FIXME Is there anything else that needs to be installed?
  - name: Test with pytest
    run: |
      pytest


- Add `.github/workflows/python-tests.yml` to the repository, commit it and push it to GitHub. Link to this issue on that commit by including `Answers UCL-COMP0233-24-25/RSE-Classwork#14` in the commit message.
- Check whether the tests pass on your remote (_Hint_: check the Actions tab on your GitHub fork).
- Discuss with your group what you think each of the lines in `.github/workflows/python-tests.yml` does.
  - You may want to consult the [GitHub Actions documentation](https://docs.github.com/en/actions).

If you're done with this issue, try [to add test coverage by working on this related issue](https://github.com/UCL-COMP0233-24-25/RSE-Classwork/issues/15).