f-bader / SentinelARConverter

Sentinel Analytics Rule converter PowerShell module
MIT License
53 stars 11 forks source link

Test: Do crossplatform checks #20

Closed Manbearpiet closed 1 year ago

Manbearpiet commented 1 year ago

Summary of the new feature / enhancement

As a user It would be great if we could have tests done on each platform So that the module becomes more reliable cross-platform

Proposed technical implementation details (optional)

We could use a matrix strategy to test on all supported OS's. Which would run on each pull request

jobs:
  example_matrix:
    strategy:
      matrix:
        version: [10, 12, 14]
        os: [ubuntu-latest, windows-latest]

Something borrowing logic from: https://github.com/devblackops/Stucco/blob/main/Stucco/template/cicd/github-actions.yml

name: CI
on: [pull_request]
jobs:
  test:
    name: Run Tests
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest, macOS-latest]
    steps:
    - uses: actions/checkout@v1
    - name: Test
      shell: pwsh
      run: ./build.ps1 -Task Test -Bootstrap

We should not forget to test for both pwsh and PowerShell to prevent #18 it's scenario.

Manbearpiet commented 1 year ago

We use something like this:

name: Tests
on: [pull_request]
jobs:
  test:
    name: Run Tests
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest, macOS-latest]
    steps:
      - uses: actions/checkout@v3
      - name: Test
        shell: pwsh
        run: |
          $config = New-PesterConfiguration -Hashtable @{TestResult = @{Enabled = $true }; Run = @{Exit = $false }; Output = @{ Verbosity = 'Detailed' }}
          Invoke-Pester -Configuration $config

This just doesn't account for Windows PowerShell, which runs with shell: powershell

f-bader commented 1 year ago

Fixed in #21

Windows PowerShell adds quite some test time and makes the code a bit more complex.

image