Skip to content

Commit

Permalink
Update GitHub Actions build CI (#2029)
Browse files Browse the repository at this point in the history
* Updates to build pipeline

* Ignore trx

* Add shell into test matrix

* Fix matrix

* Fix matrix

* Fix Windows PowerShell

* Minor tweaks
  • Loading branch information
BernieWhite authored Feb 11, 2023
1 parent e38dfea commit fef02ce
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .azure-pipelines/pipeline-deps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ if ($Null -eq (Get-PackageProvider -Name NuGet -ErrorAction Ignore)) {
Install-PackageProvider -Name NuGet -Force -Scope CurrentUser;
}

if ($Null -eq (Get-InstalledModule -Name PowerShellGet -MinimumVersion 2.2.1 -ErrorAction Ignore)) {
Install-Module PowerShellGet -MinimumVersion 2.2.1 -Scope CurrentUser -Force -AllowClobber;
if ($Null -eq (Get-InstalledModule -Name PowerShellGet -MinimumVersion 2.2.1 -ErrorAction Ignore -WarningAction SilentlyContinue)) {
Install-Module PowerShellGet -MinimumVersion 2.2.1 -Scope CurrentUser -Force -AllowClobber -WarningAction SilentlyContinue;
}

if ($Null -eq (Get-InstalledModule -Name InvokeBuild -MinimumVersion 5.4.0 -ErrorAction Ignore)) {
Expand Down
30 changes: 20 additions & 10 deletions .github/workflows/analyze.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,21 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- run: |
# echo '### Hello world! :rocket:' >> $GITHUB_STEP_SUMMARY
echo "JOBSUMMARYPATH=$GITHUB_STEP_SUMMARY" >> $GITHUB_ENV
echo $GITHUB_STEP_SUMMARY
- name: Run PSRule analysis
uses: microsoft/[email protected]
with:
modules: PSRule.Rules.MSFT.OSS
prerelease: true
env:
PSRULE_OUTPUT_JOBSUMMARYPATH: summary.md

- run: cat summary.md >> $GITHUB_STEP_SUMMARY

devskim:
name: Analyze with DevSkim
Expand All @@ -45,18 +55,18 @@ jobs:
security-events: write
steps:

- name: Checkout
uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3

- name: Run DevSkim scanner
uses: microsoft/DevSkim-Action@v1
with:
directory-to-scan: src/
- name: Run DevSkim scanner
uses: microsoft/DevSkim-Action@v1
with:
directory-to-scan: src/

- name: Upload results to security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: devskim-results.sarif
- name: Upload results to security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: devskim-results.sarif

codeql:
name: Analyze with CodeQL
Expand Down
57 changes: 44 additions & 13 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,37 +36,42 @@ jobs:

- name: Install dependencies
shell: pwsh
timeout-minutes: 3
run: ./.azure-pipelines/pipeline-deps.ps1

- name: Build module
shell: pwsh
timeout-minutes: 5
run: Invoke-Build -Configuration Release -AssertStyle GitHubActions

- name: Upload module
uses: actions/upload-artifact@v3
with:
name: module-release
name: Module
path: ./out/modules/PSRule.Rules.Azure/*
retention-days: 3
if-no-files-found: error

- name: Upload Test Results
uses: actions/upload-artifact@v3
if: always()
with:
name: Module.DotNet.TestResults
path: ./reports/*.trx
if-no-files-found: error
# - name: Upload Test Results
# uses: actions/upload-artifact@v3
# if: always()
# with:
# name: Module.DotNet.TestResults
# path: ./reports/*.trx
# retention-days: 3
# if-no-files-found: error

- name: Upload Test Results
- name: Upload PSRule Results
uses: actions/upload-artifact@v3
if: always()
with:
name: Module.PSRule.TestResults
path: ./reports/ps-rule*.xml
retention-days: 3
if-no-files-found: error

Test:
name: Test module (${{ matrix.rid }})
name: Test (${{ matrix.rid }}-${{ matrix.shell }})
runs-on: ${{ matrix.os }}
needs: Build
permissions:
Expand All @@ -77,15 +82,25 @@ jobs:
fail-fast: false

matrix:
os: [ 'ubuntu-latest' ]
rid: [ 'linux-x64' ]
shell: [ 'pwsh' ]
include:
- os: windows-latest
rid: win-x64
shell: pwsh
- os: windows-latest
rid: win-x64
shell: powershell
- os: ubuntu-latest
rid: linux-x64
shell: pwsh
- os: ubuntu-latest
rid: linux-musl-x64
shell: pwsh
- os: macos-latest
rid: osx-x64
shell: pwsh

steps:

Expand All @@ -97,16 +112,32 @@ jobs:
with:
dotnet-version: 6.x

- name: Install dependencies
- if: ${{ matrix.shell == 'pwsh' }}
name: Install dependencies (PowerShell)
shell: pwsh
timeout-minutes: 3
run: ./.azure-pipelines/pipeline-deps.ps1

- if: ${{ matrix.shell == 'powershell' }}
name: Install dependencies (Windows PowerShell)
shell: powershell
timeout-minutes: 3
run: ./.azure-pipelines/pipeline-deps.ps1

- name: Download module
uses: actions/download-artifact@v3
with:
name: module-release
name: Module
path: ./out/modules/PSRule.Rules.Azure

- name: Test module
- if: ${{ matrix.shell == 'pwsh' }}
name: Test module (PowerShell)
shell: pwsh
timeout-minutes: 15
run: Invoke-Build TestModule -Configuration Release -AssertStyle GitHubActions

- if: ${{ matrix.shell == 'powershell' }}
name: Test module (Windows PowerShell)
shell: powershell
timeout-minutes: 15
run: Invoke-Build TestModule -Configuration Release -AssertStyle GitHubActions
1 change: 1 addition & 0 deletions ps-rule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ include:
output:
culture:
- en-US
# jobSummaryPath: summary.md

configuration:
# Authoring rules
Expand Down

0 comments on commit fef02ce

Please sign in to comment.