Could not open requirements file in github actions

Advertisements

I am trying to setup a github workflow (first time)

but keep getting this error

/opt/hostedtoolcache/Python/3.10.12/x64/bin/python -m pip install -r requirements.txt
ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'
Error: ERROR: Action failed during dependency installation attempt with error: The process '/opt/hostedtoolcache/Python/3.10.12/x64/bin/python' failed with exit code 1

you can view my director structure here
and github workflow file

name: testing
on: [push,pull_request]
run-name: running tests for searchenginepy
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: setup python
        uses: actions/setup-python@v4
        with:
          python-version: '3.10' # install the python version needed
          
      - name: Install dependencies
        uses: py-actions/py-dependency-install@v4
        with:
              path: "requirements.txt"
          
      - name: run tests # run main.py
        working-directory: tests
        run: python -m unittest discover
          

I have tried

pip install .
pip install -r .github/workflows/requirements.txt

I am also not sure about the unittest directory because that needs to be run in the tests folder

>Solution :

Please just add checkout step - uses: actions/checkout@v3

name: testing
on: [push,pull_request]
run-name: running tests for searchenginepy
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: setup python
        uses: actions/setup-python@v4
        with:
          python-version: '3.10' # install the python version needed
          
      - name: Install dependencies
        uses: py-actions/py-dependency-install@v4
        with:
              path: "requirements.txt"
          
      - name: run tests # run main.py
        working-directory: tests
        run: python -m unittest discover

Leave a ReplyCancel reply