dotherightthing / wpdtrt-npm-scripts

NPM build scripts.
0 stars 0 forks source link

wpdtrt-gallery/anchorlinks - test shows green but fails on env.WPUNIT_DB_USER #24

Closed dotherightthing closed 4 years ago

dotherightthing commented 4 years ago
> wpdtrt-npm-scripts@0.2.1 pretest /home/runner/work/wpdtrt-gallery/wpdtrt-gallery/node_modules/wpdtrt-npm-scripts
> node ./scripts/pretest/create-wp-test-environment.js

--------------------------------------------------------------------------------
4/23/2020, 6:24:18 AM
wpdtrt-npm-scripts: test: create wp test environment (install wp test suite and
create database)
--------------------------------------------------------------------------------

error Error: Command failed with exit code 1: bash ./scripts/pretest/install-wp-tests.sh wpdtrt_npm_scripts_wpunit_1587623058930 latest
WPUNIT_DB_USER not found. Please add export statement to your ~/.bash_profile
    at makeError (/home/runner/work/wpdtrt-gallery/wpdtrt-gallery/node_modules/execa/lib/error.js:58:11)
    at Function.module.exports.sync (/home/runner/work/wpdtrt-gallery/wpdtrt-gallery/node_modules/execa/index.js:188:17)
    at Function.module.exports.commandSync (/home/runner/work/wpdtrt-gallery/wpdtrt-gallery/node_modules/execa/index.js:227:15)
    at createWpTestEnvironment (/home/runner/work/wpdtrt-gallery/wpdtrt-gallery/node_modules/wpdtrt-npm-scripts/scripts/pretest/create-wp-test-environment.js:28:66)
    at Object.<anonymous> (/home/runner/work/wpdtrt-gallery/wpdtrt-gallery/node_modules/wpdtrt-npm-scripts/scripts/pretest/create-wp-test-environment.js:39:1)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)

In both cases tests run locally, but the test suite is already installed.

dotherightthing commented 4 years ago

Fixed by specifying the environmental variables with and after the commands to run:

    # env: https://github.com/actions/virtual-environments/blob/master/images/linux/Ubuntu1604-README.md
    # mysql start: https://github.com/actions/virtual-environments/issues/739
    - name: Run tests
      run: |
        sudo /etc/init.d/mysql start
        npm run test --if-present
      env:
        WPUNIT_DB_USER: root
        WPUNIT_DB_PASS: root
        WPUNIT_DB_HOST: 127.0.0.1