Skip to content

Commit

Permalink
Merge branch 'main' into 913-json-report
Browse files Browse the repository at this point in the history
  • Loading branch information
adhilto authored Mar 7, 2024
2 parents 43f0c76 + a806c52 commit 16fe298
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Purpose: Build, sign, and check a draft release

name: Build and Draft Release

on:
workflow_dispatch:
inputs:
Expand All @@ -15,17 +19,18 @@ on:
type: boolean
default: true

name: Build and Sign Release

jobs:
build-and-deploy:
build-and-draft:
name: Build and Draft Release
runs-on: windows-latest
environment: Development
env:
RELEASE_VERSION: ${{ inputs.version }}
permissions:
id-token: write
contents: write
# This condition prevents duplicate runs.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
powershell-lint-check:
name: MegaLint PowerShell Check
runs-on: ubuntu-latest
# This condition prevents duplicate runs.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
defaults:
run:
shell: bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
yaml-lint-check:
name: MegaLint YAML Check
runs-on: ubuntu-latest
# This condition prevents duplicate runs.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
defaults:
run:
shell: bash
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Purpose: Publish the package to a private gallery

name: Publish Package

on:
Expand All @@ -14,12 +16,15 @@ env:
ModuleName: ScubaGear

jobs:
Publish-Private-Package:
private-package:
name: Private Package Publish
runs-on: windows-latest
environment: Development
permissions:
id-token: write
contents: write
# This condition prevents duplicate runs.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
defaults:
run:
shell: powershell
Expand Down Expand Up @@ -102,7 +107,7 @@ jobs:
azPSVersion: "latest"
- name: Check Scuba Version
run: |
$ScubaModules = Find-Module -Name ScubaGear -AllVersions -AllowPrerelease
$ScubaModules = Find-Module -Name ScubaGear -AllVersions -AllowPrerelease -Repository $env:GalleryName
($ScubaModules).Version
if ($ScubaModules.Count -eq 2) {
Exit 0
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/run_pipeline.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Purpose: Run the CI/CD pipeline that tests, packages, and publishes ScubaGear.
# Note: This pipeline is a work in progress. At the moment, it is only doing linting, syntax checking, and unit testing.

name: CI/CD Pipeline
name: Run the CI/CD Pipeline

on:
push:
Expand All @@ -20,6 +20,8 @@ jobs:
test-files:
name: Test for Changes
runs-on: ubuntu-latest
# This condition prevents duplicate runs.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- name: Checkout Repo
uses: actions/checkout@v4
Expand Down Expand Up @@ -54,28 +56,28 @@ jobs:
needs:
- test-files
if: needs.test-files.outputs.yaml-changes == 'true'
uses: ./.github/workflows/run_linter_yaml.yaml
uses: ./.github/workflows/lint_yaml.yaml
lint-powershell:
name: Lint
needs:
- test-files
if: needs.test-files.outputs.powershell-changes == 'true'
uses: ./.github/workflows/run_linter_powershell.yaml
uses: ./.github/workflows/lint_powershell.yaml
syntax:
name: Syntax
needs:
- test-files
if: needs.test-files.outputs.markdown-changes == 'true'
uses: ./.github/workflows/run_markdown_check.yaml
uses: ./.github/workflows/syntax_check_markdown.yaml
unit-powershell:
name: Unit
needs:
- test-files
if: needs.test-files.outputs.powershell-changes == 'true'
uses: ./.github/workflows/run_powershell_tests.yaml
uses: ./.github/workflows/unit_test_powershell.yaml
unit-opa:
name: Unit
needs:
- test-files
if: needs.test-files.outputs.rego-changes == 'true'
uses: ./.github/workflows/run_opa_tests.yaml
uses: ./.github/workflows/unit_test_opa.yaml
7 changes: 6 additions & 1 deletion .github/workflows/run_smoke_test.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Purpose: Run smoke tests

name: Smoke Test

on:
Expand All @@ -17,10 +19,13 @@ on:
- "*smoke*"

jobs:
Run-Smoke-Test:
smoke-tests:
name: Smoke Tests
runs-on: windows-latest
env:
SCUBA_GITHUB_AUTOMATION_CREDS: ${{ secrets.SCUBA_GITHUB_AUTOMATION_CREDS }}
# This condition prevents duplicate runs.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
defaults:
run:
shell: powershell
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# Purpose: Syntax checking for Markdown.
# Purpose: Run the syntax checks for Markdown.

name: Markdown Check
name: Syntax Checks for Markdown

# This is a reusable workflow called by the pipeline.
on:
workflow_call:
workflow_dispatch:

jobs:
Run-Markdown-Check:
markdown-check:
name: Markdown Syntax Checks
runs-on: windows-latest
# This condition prevents duplicate runs.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
defaults:
run:
shell: powershell
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Purpose: Run the product functional tests every night

name: Nightly Product Functional Tests
name: Test Product Functionality Nightly

# Run this workflow at 12:15 am
# on every Sun to Thr (b/c GMT -5)
Expand All @@ -13,6 +13,8 @@ jobs:
product-tests:
name: Product Tests
runs-on: windows-latest
# This condition prevents duplicate runs.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
defaults:
run:
shell: powershell
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Purpose: Run unit tests for OPA

name: Run OPA Tests
name: Unit Test OPA

# This is a reusable workflow called by the pipeline.
on:
Expand All @@ -10,8 +10,11 @@ on:
env:
MODULE_ROOT: PowerShell/ScubaGear
jobs:
Run-OPA-Tests:
opa-tests:
name: OPA Unit Tests
runs-on: ubuntu-latest
# This condition prevents duplicate runs.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- name: Check out repository code
uses: actions/checkout@v4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# Purpose: Run unit tests for PowerShell

name: Run PowerShell Tests
name: Unit Test PowerShell

# This is a reusable workflow called by the pipeline.
on:
workflow_call:
workflow_dispatch:

jobs:
Run-PowerShell-Tests:
powershell-tests:
name: PowerShell Unit Tests
runs-on: windows-latest
# This condition prevents duplicate runs.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- name: Check out repository code
uses: actions/checkout@v4
Expand Down
10 changes: 8 additions & 2 deletions PowerShell/ScubaGear/Modules/Support/Support.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,16 @@ function Initialize-SCuBA {
# Start a stopwatch to time module installation elapsed time
$Stopwatch = [System.Diagnostics.Stopwatch]::StartNew()

$RequiredModulesPath = Join-Path -Path $PSScriptRoot -ChildPath "PowerShell\ScubaGear\RequiredVersions.ps1"
if (Test-Path -Path $RequiredModulesPath) {
# Need to determine where module is so we can get required versions info
$ModuleParentDir = Split-Path -Path (Get-Module ScubaGear).Path -Parent

try {
($RequiredModulesPath = Join-Path -Path $ModuleParentDir -ChildPath 'RequiredVersions.ps1') *> $null
. $RequiredModulesPath
}
catch{
throw "Unable to find RequiredVersions.ps1 in expected directory:`n`t$ModuleParentDir"
}

if ($ModuleList) {
# Add PowerShellGet to beginning of ModuleList for installing required modules.
Expand Down
12 changes: 6 additions & 6 deletions PowerShell/ScubaGear/RequiredVersions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,32 @@ $ModuleList = @(
@{
ModuleName = 'Microsoft.Graph.Authentication'
ModuleVersion = [version] '2.0.0'
MaximumVersion = [version] '2.12.0'
MaximumVersion = [version] '2.15.99999'
},
@{
ModuleName = 'Microsoft.Graph.Beta.Users'
ModuleVersion = [version] '2.0.0'
MaximumVersion = [version] '2.12.0'
MaximumVersion = [version] '2.15.99999'
},
@{
ModuleName = 'Microsoft.Graph.Beta.Groups'
ModuleVersion = [version] '2.0.0'
MaximumVersion = [version] '2.12.0'
MaximumVersion = [version] '2.15.99999'
},
@{
ModuleName = 'Microsoft.Graph.Beta.Identity.DirectoryManagement'
ModuleVersion = [version] '2.0.0'
MaximumVersion = [version] '2.12.0'
MaximumVersion = [version] '2.15.99999'
},
@{
ModuleName = 'Microsoft.Graph.Beta.Identity.Governance'
ModuleVersion = [version] '2.0.0'
MaximumVersion = [version] '2.12.0'
MaximumVersion = [version] '2.15.99999'
},
@{
ModuleName = 'Microsoft.Graph.Beta.Identity.SignIns'
ModuleVersion = [version] '2.0.0'
MaximumVersion = [version] '2.12.0'
MaximumVersion = [version] '2.15.99999'
},
@{
ModuleName = 'powershell-yaml'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ InModuleScope Connection {
BeforeAll {
function Connect-MgGraph {throw 'this will be mocked'}
Mock Connect-MgGraph -MockWith {}
function Connect-PnPOnline {throw 'this will be mocked'}
Mock Connect-PnPOnline -MockWith {}
function Connect-SPOService {throw 'this will be mocked'}
Mock Connect-SPOService -MockWith {}
function Connect-MicrosoftTeams{throw 'this will be mocked'}
Mock Connect-MicrosoftTeams -MockWith {}
function Add-PowerAppsAccount {throw 'this will be mocked'}
Mock Add-PowerAppsAccount -MockWith {}
function Connect-EXOHelper {throw 'this will be mocked'}
Mock -ModuleName Connection Connect-EXOHelper -MockWith {}
function Get-MgBetaOrganization {throw 'this will be mocked'}
Mock Get-MgBetaOrganization -MockWith {
return [pscustomobject]@{
DisplayName = "DisplayName";
Expand Down

0 comments on commit 16fe298

Please sign in to comment.