name: Run tests using packages from older Linux distributions

on:
  workflow_dispatch:
  workflow_call:
  push:
    paths:
      - '**.py'
  pull_request:
    paths:
      - '**.py'

jobs:
  test_python2:
    name: Test with Python 3 on Ubuntu 20.04
    runs-on: ubuntu-20.04

    steps:
      - name: Check out code from GitHub
        uses: actions/checkout@v4
        with:
          path: nanopb
          fetch-depth: "0"

      - name: Install dependencies from apt-get
        run: |
          # Deliberately avoid using new protobuf from pip
          sudo apt-get update
          sudo apt-get install python3-protobuf protobuf-compiler scons python-is-python3

      - name: Run tests with Python 3
        run: |
          cd nanopb/tests
          scons

