UCL-COMP0233-2023-2024 / RSE-Classwork

3 stars 65 forks source link

Use CI to run the tests for you #19

Open dpshelio opened 11 months ago

dpshelio commented 11 months 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.8", "3.10"]

steps:
  - uses: actions/checkout@v3
  - name: Set up Python ${{ matrix.python-version }}
    uses: actions/setup-python@v4
    with:
      python-version: ${{ matrix.python-version }}
  - name: Install dependencies
    # This case we are only updating pip, but you could add other dependencies needed.
    run: |
      python -m pip install --upgrade pip
  - 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-23-24/RSE-Classwork#19` 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-23-24/RSE-Classwork/issues/20).