|
| 1 | +name: tox |
| 2 | +description: Run tox specified environment |
| 3 | + |
| 4 | +inputs: |
| 5 | + path: |
| 6 | + description: | |
| 7 | + The directory containng 'tox.ini' file in which the tox command is executed. |
| 8 | + required: true |
| 9 | + tox_extra_args: |
| 10 | + description: extra args for tox command |
| 11 | + required: false |
| 12 | + default: "-vv --skip-missing-interpreters=false" |
| 13 | + tox_envlist: |
| 14 | + description: tox env list |
| 15 | + required: false |
| 16 | + default: "" |
| 17 | + tox_config_file: |
| 18 | + description: tox configuration file |
| 19 | + required: false |
| 20 | + default: "" |
| 21 | + tox_environment: |
| 22 | + description: | |
| 23 | + list of environment variables to set when running ansible-test. |
| 24 | + required: false |
| 25 | + default: "" |
| 26 | + tox_dependencies: |
| 27 | + description: | |
| 28 | + Path to dependencies to install into tox environment prior running command. |
| 29 | + e.g: '/home/runner/goutelette /home/runner/collection_prep' |
| 30 | + required: false |
| 31 | + tox_constraints_file: |
| 32 | + description: the location to the tox constraints file. |
| 33 | + default: "" |
| 34 | + |
| 35 | +runs: |
| 36 | + using: composite |
| 37 | + steps: |
| 38 | + - name: Ensure 'tox.ini' is present |
| 39 | + run: >- |
| 40 | + if ! test -f "${{ inputs.path }}/tox.ini"; then |
| 41 | + echo "Missing expected tox configuration file '${{ inputs.path }}/tox.ini'" |
| 42 | + exit 1 |
| 43 | + fi |
| 44 | + shell: bash |
| 45 | + |
| 46 | + - name: setup python |
| 47 | + uses: actions/setup-python@v4 |
| 48 | + with: |
| 49 | + python-version: "3.9" |
| 50 | + |
| 51 | + - name: Install tox |
| 52 | + run: pip install -U tox |
| 53 | + shell: bash |
| 54 | + |
| 55 | + - name: Emit tox command options |
| 56 | + id: py-options |
| 57 | + shell: bash |
| 58 | + run: | |
| 59 | + PY_OPTIONS="" |
| 60 | + if [ ! -z "${TOX_CONFIG_FILE}" ]; then |
| 61 | + PY_OPTIONS="${PY_OPTIONS} --tox-config-file ${TOX_CONFIG_FILE}" |
| 62 | + fi |
| 63 | + if [ ! -z "${TOX_ENV_LIST}" ]; then |
| 64 | + PY_OPTIONS="${PY_OPTIONS} --tox-envname ${TOX_ENV_LIST}" |
| 65 | + fi |
| 66 | + if [ ! -z "${TOX_CONSTRAINTS}" ]; then |
| 67 | + PY_OPTIONS="${PY_OPTIONS} --tox-constraints-file ${TOX_CONSTRAINTS}" |
| 68 | + fi |
| 69 | + if [ ! -z "${TOX_ENVIRONMENT}" ]; then |
| 70 | + PY_OPTIONS="${PY_OPTIONS} --tox-env-vars ${TOX_ENVIRONMENT}" |
| 71 | + fi |
| 72 | + echo "python_args=${PY_OPTIONS}" >> $GITHUB_OUTPUT |
| 73 | + env: |
| 74 | + TOX_CONFIG_FILE: ${{ inputs.tox_config_file }} |
| 75 | + TOX_ENV_LIST: ${{ inputs.tox_envlist }} |
| 76 | + TOX_CONSTRAINTS: ${{ inputs.tox_constraints_file }} |
| 77 | + TOX_ENVIRONMENT: ${{ inputs.tox_environment }} |
| 78 | + |
| 79 | + - name: install dependencies packages |
| 80 | + run: >- |
| 81 | + python3 ${{ github.action_path }}/install_packages.py |
| 82 | + --tox-project-dir ${{ inputs.path }} |
| 83 | + ${{ steps.py-options.outputs.python_args }} |
| 84 | + ${{ inputs.tox_dependencies }} |
| 85 | + shell: bash |
| 86 | + env: |
| 87 | + TOX_EXTRA_ARGS: ${{ inputs.tox_extra_args }} |
| 88 | + if: inputs.tox_dependencies != '' |
| 89 | + |
| 90 | + - name: Emit tox command options |
| 91 | + id: tox-options |
| 92 | + shell: bash |
| 93 | + run: | |
| 94 | + TOX_CMD_OPTIONS="" |
| 95 | + if [ ! -z "${TOX_CONFIG_FILE}" ]; then |
| 96 | + TOX_CMD_OPTIONS="-c ${TOX_CONFIG_FILE}" |
| 97 | + fi |
| 98 | + if [ ! -z "${TOX_ENV_LIST}" ]; then |
| 99 | + TOX_CMD_OPTIONS="${TOX_CMD_OPTIONS} -e ${TOX_ENV_LIST}" |
| 100 | + fi |
| 101 | + echo "tox_common_args=${TOX_CMD_OPTIONS}" >> $GITHUB_OUTPUT |
| 102 | + env: |
| 103 | + TOX_CONFIG_FILE: ${{ inputs.tox_config_file }} |
| 104 | + TOX_ENV_LIST: ${{ inputs.tox_envlist }} |
| 105 | + |
| 106 | + - name: Set environment variables |
| 107 | + run: echo "${{ inputs.tox_environment }}" >> $GITHUB_ENV |
| 108 | + shell: bash |
| 109 | + if: inputs.tox_environment != '' |
| 110 | + |
| 111 | + - name: Run tox |
| 112 | + run: >- |
| 113 | + tox |
| 114 | + ${{ steps.tox-options.outputs.tox_common_args }} |
| 115 | + ${{ inputs.tox_extra_args }} |
| 116 | + shell: bash |
| 117 | + working-directory: ${{ inputs.path }} |
0 commit comments