actions / runner

The Runner for GitHub Actions :rocket:
https://github.com/features/actions
MIT License
4.83k stars 951 forks source link

Allow expression use in Shell: #906

Closed JustinGrote closed 3 years ago

JustinGrote commented 3 years ago

Describe the enhancement When using a matrix, I want to run Powershell and pwsh, but I cannot do the following because expressions aren't supported for this element though I see no reason why not.

shell: ${{ matrix.shellname }}

Code Snippet

name: Test
on:
  push:
  pull_request:
    branches:
      - main

jobs:
  test:
    name: Powershell Pester Tests
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os:
          - ubuntu-20.04
          - ubuntu-18.04
          - windows-2019
          - windows-2016
          - macOS-11.0
        psversion:
          - pwsh
          - powershell
        exclude:
          - os: ubuntu-20.04
            psversion: powershell
          - os: ubuntu-18.04
            psversion: powershell
          - os: macOS-11.0
            psversion: powershell
      fail-fast: false
    steps:
      - uses: actions/checkout@v2
      - name: Prerequisites
        shell: ${{ matrix.psversion }} #What I wish worked but didn't
        run: |
          Install-Module Pester,Microsoft.Powershell.SecretManagement -Force -Scope CurrentUser
      - name: Run Pester
        shell: ${{ matrix.psversion }} #What I wish worked but didn't
        run: |
          $pesterResult = Invoke-Pester -Output Detailed -PassThru
          if ($pesterResult.FailedCount) {throw "There were $($pesterResult.FailedCount) failed tests."}

Additional information Workaround: Set it as an ENV and then call the shell from another shell. Not ideal as it involves extra character escaping

JustinGrote commented 3 years ago

Dupe of #444