7

I just start with GitHub Actions and I'm trying to configure correctly jobs. Now I have a job - build which set up python and installs dependencies, I have a job with behave test too which needs the dependencies to run. When I have the test and build in the one job, everything works fine. But I want to have build and test in separate jobs. But when I run them in this configuration, I get the error behave: command not found. I install the Behave in requirementx.txt file. What am I doing wrong? Is this configuration generally possible?

name: CI test

on:
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - name: Set up Python 3.8
        uses: actions/setup-python@v2
        with:
          python-version: 3.8
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

  cc_test:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - name: Run cc test
        run: |
          behave --no-capture --no-skipped -t guest -t cc -D driver=BROWSERSTACK features
riQQ
  • 9,878
  • 7
  • 49
  • 66
wrozda
  • 179
  • 2
  • 7
  • Jobs run on separate runners, so they don't share any changes you do in the jobs. You can transfer data or files between jobs with outputs or artifcats respectively. But it looks like installing `behave` also adds the folder of its executable to the path. And there might be more, that `pip install` is doing. – riQQ Oct 15 '20 at 13:24

1 Answers1

1

As riQQ and documentation says

A job is a set of steps that execute on the same runner. By default, a workflow with multiple jobs will run those jobs in parallel. You can also configure a workflow to run jobs sequentially. For example, a workflow can have two sequential jobs that build and test code, where the test job is dependent on the status of the build job. If the build job fails, the test job will not run.

In your case it would be the best to have one job build and test and do both things in this one job. Putting tests in separate jobs can be a good move, but it would require one of two:

  • prepare testable package in previous step and share it (it could still requires to install some dependencies)
  • checkout code, install dependencies, build code and run tests what means that you need to repeat all steps from previous job
Krzysztof Madej
  • 32,704
  • 10
  • 78
  • 107
  • I think this answers your question. https://stackoverflow.com/questions/58457140/dependencies-between-workflows-on-github-actions – Carter Cole Aug 09 '22 at 14:46