如何在功能测试失败时停止 Github 操作步骤(使用 Codeception)

How to stop Github Actions step when functional tests failed (using Codeception)

我是 Github Actions 的新手,我尝试与功能测试进行一些持续集成。

我完美地使用了 Codeception 和我的工作流程 运行,但是当一些测试失败时,该步骤被写为成功。 Github 不要停止操作并继续 运行 下一步。

这是我的工作流程 yml 文件:

name: Run codeception tests

on:
  push:
    branches: [ feature/functional-tests/codeception ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:

    # —— Setup Github Actions  —————————————————————————————————————————————
    - name: Checkout
      uses: actions/checkout@v2

    # —— Setup PHP Version 7.3  —————————————————————————————————————————————
    - name: Setup PHP environment
      uses: shivammathur/setup-php@master
      with:
        php-version: '7.3'

    # —— Setup Docker Environment  ————————————————————————————————————————————— 
    - name: Build containers
      run: docker-compose build

    - name: Start all container
      run: docker-compose up -d

    - name: Execute www container
      run: docker exec -t my_container developer

    - name: Create parameter file
      run: cp app/config/parameters.yml.dist app/config/parameters.yml

    # —— Composer ‍️ —————————————————————————————————————————————————————————
    - name: Install dependancies
      run: composer install

    # —— Check Requirements  —————————————————————————————————————————————
    - name: Check PHP version
      run: php --version

    # —— Setup Database  —————————————————————————————————————————————
    - name: Create database
      run: docker exec -t mysql_container mysql -P 3306 --protocol=tcp -u root --password=**** -e "CREATE DATABASE functional_tests"

    - name: Copy database
      run: cat tests/_data/test.sql | docker exec -i mysql_container mysql -u root --password=**** functional_tests

    - name: Switch database
      run: docker exec -t php /var/www/bin/console app:dev:marketplace:switch functional_tests

    - name: Execute migrations
      run: docker exec -t php /var/www/bin/console --no-interaction doctrine:migrations:migrate

    - name: Populate database
      run: docker exec -t my_container php /var/www/bin/console fos:elastica:populate

    # —— Generate Assets  ———————————————————————————————————————————————————————————
    - name: Install assets
      run: |
        docker exec -t my_container php /var/www/bin/console assets:install
        docker exec -t my_container php /var/www/bin/console assetic:dump

    # —— Tests ✅ ———————————————————————————————————————————————————————————
    - name: Run functional tests
      run: docker exec -t my_container php codeception:functional

    - name: Run Unit Tests
      run: php vendor/phpunit/phpunit/phpunit -c app/

这是操作步骤的日志:

Github Action log

任何人都知道为什么步骤不失败以及如何抛出错误?

可能 codeception:functional 设置退出代码 = 0,即使发生了错误。 docker exec 传递进程的退出代码。 GitHub 如果命令 returns 的退出代码为 != 0.

,则操作将失败