From ff8a93770a2ddf498362f1bd9e14af5e1397bc01 Mon Sep 17 00:00:00 2001 From: Steve Villardi <42367049+stevevillardi@users.noreply.github.com> Date: Tue, 16 Apr 2024 12:36:05 -0400 Subject: [PATCH] submit tests --- .github/workflows/main.yml | 156 +++++++++++++++++++++++++++++++++ .github/workflows/test-win.yml | 54 ++++++++++++ .github/workflows/test.yml | 55 ++++++++++++ .gitignore | 4 + 4 files changed, 269 insertions(+) create mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/test-win.yml create mode 100644 .github/workflows/test.yml create mode 100644 .gitignore diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..6b1bdfc --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,156 @@ +# This is a basic workflow to help you get started with Actions + +name: Build PSGallery Release + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the main branch + release: + types: [ published ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + publish_to_gallery: + runs-on: ubuntu-latest + environment: publish + outputs: + githubReleaseMessage: ${{steps.psgallery_publish.outputs.githubReleaseMessage}} + steps: + - uses: actions/checkout@v4 + - name: Build and publish + id: psgallery_publish + env: + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + BUILD_VERSION: ${{github.ref_name}} + shell: pwsh + run: | + ./Build.ps1 + Publish-Module -path ./ -NuGetApiKey $env:NUGET_API_KEY -SkipAutomaticTags -Verbose + $GithubReleaseMessage = @' + ${{github.event.release.body}} + '@ + $GithubReleaseMessage = $GithubReleaseMessage.Replace("`n","\n").Replace("`"","\`"").Replace("**","*").Replace(" - ",">").Replace("- ","• ").Replace("###","").Replace("##","").Replace("powershell","").Replace("`r","") + "githubReleaseMessage=$GithubReleaseMessage" | Out-File -FilePath $env:GITHUB_OUTPUT -Append + push_to_slack: + needs: publish_to_gallery + runs-on: ubuntu-latest + environment: publish + steps: + - name: Send custom JSON data to Slack workflow + uses: slackapi/slack-github-action@v1.25.0 + id: slack-post + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + with: + payload: | + { + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": ":party-lm-bug: Logic.Monitor PowerShell Module Release (${{github.event.release.tag_name}}) :party-lm-bug:" + } + }, + { + "type": "context", + "elements": [ + { + "text": "*${{github.event.release.published_at}}* | Logic.Monitor Update Announcements", + "type": "mrkdwn" + } + ] + }, + { + "type": "divider" + }, + { + "type": "header", + "text": { + "type": "plain_text", + "text": ":powershell-core: Release Notes :powershell-core:", + "emoji": true + } + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "${{needs.publish_to_gallery.outputs.githubReleaseMessage}}" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Logic.Monitor* Release Notes" + }, + "accessory": { + "type": "button", + "text": { + "type": "plain_text", + "text": "Release Notes", + "emoji": true + }, + "value": "click_me_123", + "url": "https://github.com/stevevillardi/Logic.Monitor/releases", + "action_id": "button-action" + } + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Logic.Monitor.SE* Toolkit Release Notes:" + }, + "accessory": { + "type": "button", + "text": { + "type": "plain_text", + "text": "Release Notes", + "emoji": true + }, + "value": "click_me_123", + "url": "https://github.com/stevevillardi/Logic.Monitor.SE/releases", + "action_id": "button-action" + } + }, + { + "type": "divider" + }, + { + "type": "header", + "text": { + "type": "plain_text", + "text": ":rocket: How to get the latest version :rocket:", + "emoji": true + } + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "```Update-Module -Name Logic.Monitor -Force```" + } + }, + { + "type": "divider" + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": ":pushpin: Do you have a feature request or bug report? ." + } + ] + } + ] + } \ No newline at end of file diff --git a/.github/workflows/test-win.yml b/.github/workflows/test-win.yml new file mode 100644 index 0000000..05015a2 --- /dev/null +++ b/.github/workflows/test-win.yml @@ -0,0 +1,54 @@ +# This is a basic workflow to help you get started with Actions + +name: Test Current Build on Windows Powershell 5.1 + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the main branch + push: + branches: [ main ] + paths-ignore: + - '**.md' + - '**.yml' + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + test-build: + runs-on: windows-latest + environment: test + steps: + - uses: actions/checkout@v4 + - name: Build and Test 5.1 + # API key generated in PSGallery + env: + LM_ACCESS_ID: ${{ secrets.LM_ACCESS_ID }} + LM_ACCESS_KEY: ${{ secrets.LM_ACCESS_KEY }} + LM_PORTAL: ${{ secrets.LM_PORTAL }} + LM_BEARER_TOKEN: ${{ secrets.LM_BEARER_TOKEN }} + BUILD_VERSION: 9.9.9 + shell: powershell + run: | + ./Build.ps1 + + $Data = @{ + AccessId="$env:LM_ACCESS_ID" + AccessKey="$env:LM_ACCESS_KEY" + AccountName="$env:LM_PORTAL" + BearerToken="$env:LM_BEARER_TOKEN" + Module="./Logic.Monitor.psd1" + PreferredCollectorId="8" + } + $Version = $PSVersionTable.PSVersion + Write-Host "Powershell version: $Version" + + $Container = New-PesterContainer -Path ./Tests/ -Data $Data + $Result = Invoke-Pester -Container $Container -Output Detailed -PassThru + + #Write OpsNote to test portal indicating test status + Connect-LMAccount -AccessId $env:LM_ACCESS_ID -AccessKey $env:LM_ACCESS_KEY -AccountName $env:LM_PORTAL -DisableConsoleLogging + $TimeNow = Get-Date -UFormat %m%d%Y-%H%M + $OpsNote = New-LMOpsNote -Note "Github test build submitted on $TimeNow - $($Result.Result)" -Tags @("GithubActions","TestPipeline-Win5.1","PSVersion-$Version") + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..0092a87 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,55 @@ +# This is a basic workflow to help you get started with Actions + +name: Test Current Build on PowerShell Core + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the main branch + push: + branches: [ main ] + paths-ignore: + - '**.md' + - '**.yml' + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + test-build: + runs-on: ubuntu-latest + environment: test + steps: + - uses: actions/checkout@v4 + - name: Build and Test + # API key generated in PSGallery + env: + LM_ACCESS_ID: ${{ secrets.LM_ACCESS_ID }} + LM_ACCESS_KEY: ${{ secrets.LM_ACCESS_KEY }} + LM_PORTAL: ${{ secrets.LM_PORTAL }} + LM_BEARER_TOKEN: ${{ secrets.LM_BEARER_TOKEN }} + BUILD_VERSION: 9.9.9 + shell: pwsh + run: | + ./Build.ps1 + + $Data = @{ + AccessId="$env:LM_ACCESS_ID" + AccessKey="$env:LM_ACCESS_KEY" + AccountName="$env:LM_PORTAL" + BearerToken="$env:LM_BEARER_TOKEN" + Module="./Logic.Monitor.psd1" + PreferredCollectorId="8" + } + + $Version = $PSVersionTable.PSVersion + Write-Host "Powershell version: $Version" + + $Container = New-PesterContainer -Path ./Tests/ -Data $Data + $Result = Invoke-Pester -Container $Container -Output Detailed -PassThru + + #Write OpsNote to test portal indicating test status + Connect-LMAccount -AccessId $env:LM_ACCESS_ID -AccessKey $env:LM_ACCESS_KEY -AccountName $env:LM_PORTAL -DisableConsoleLogging + $TimeNow = Get-Date -UFormat %m%d%Y-%H%M + $OpsNote = New-LMOpsNote -Note "Github test build submitted on $TimeNow - $($Result.Result)" -Tags @("GithubActions","TestPipeline-Core","PSVersion-$Version") + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0f976c7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ + +Dev.Logic.Monitor.psd1 +.github/.DS_Store +.DS_Store