diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 4b839df3..d5404d75 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -24,6 +24,8 @@ After the description, please concisely list the changes as per keepachangelog.com This **should** duplicate what you've updated in the changelog file. + for example: + ### Added - for new features [closes #15] ### Changed @@ -51,13 +53,11 @@ - [ ] The PR represents a single logical change. i.e. Cosmetic updates should go in different PRs. - [ ] Added an entry under the Unreleased section of in the CHANGELOG.md as per [format](https://keepachangelog.com/en/1.0.0/). -- [ ] Local clean build passes without issue or fail tests (`build.ps1 -ResolveDependency`). -- [ ] Resource documentation added/updated in README.md. -- [ ] Resource parameter descriptions added/updated in README.md, schema.mof - and comment-based help. +- [ ] Local clean build passes without issue or fail tests (`build.ps1 -ResolveDependency -Tasks build, test`). - [ ] Comment-based help added/updated. -- [ ] Localization strings added/updated in all localization files as appropriate. - [ ] Examples appropriately added/updated. -- [ ] Unit tests added/updated. See [DSC Resource Testing Guidelines](https://github.com/PowerShell/DscResources/blob/master/TestsGuidelines.md). -- [ ] Integration tests added/updated (where possible). See [DSC Resource Testing Guidelines](https://github.com/PowerShell/DscResources/blob/master/TestsGuidelines.md). -- [ ] New/changed code adheres to [DSC Resource Style Guidelines](https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.md) and [Best Practices](https://github.com/PowerShell/DscResources/blob/master/BestPractices.md). +- [ ] Unit tests added/updated.. +- [ ] Integration tests added/updated (where possible). +- [ ] Documentation added/updated (where applicable). +ed code adheres to [DSC Resource Style Guidelines](https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.md) and [Best Practices](https://github.com/PowerShell/DscResources/blob/master/BestPractices.md). + diff --git a/.github/workflows/deploy-module.yml b/.github/workflows/deploy-module.yml new file mode 100644 index 00000000..fcddb795 --- /dev/null +++ b/.github/workflows/deploy-module.yml @@ -0,0 +1,82 @@ +on: + push: + branches: + - main + paths-ignore: + - CHANGELOG.md + - .vscode/** + - .github/** + - images/** + - tests/** + - '**.md' + - '**.yml' + tags: + - '**' + - '!*preview*' +env: + buildFolderName: output + buildArtifactName: output + + +name: Deploy Module +# This workflow is triggered on push to the main branch and deploys the module to the PowerShell Gallery and creates a GitHub Release. +jobs: + Build_Stage_Package_Module: + name: Package Module + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} # checkout the correct branch name + fetch-depth: 0 + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v0.9.15 + with: + versionSpec: 5.x + - name: Evaluate Next Version + uses: gittools/actions/gitversion/execute@v0.9.15 + with: + configFilePath: GitVersion.yml + - name: Build & Package Module + shell: pwsh + run: ./build.ps1 -ResolveDependency -tasks pack + env: + ModuleVersion: ${{ env.gitVersion.MajorMinorPatch }} + - name: Publish Build Artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.buildArtifactName }} + path: ${{ env.buildFolderName }}/ + + Deploy_Stage_Deploy_Module: + name: Deploy Module + runs-on: ubuntu-latest + needs: + - Build_Stage_Package_Module + if: ${{ success() && (github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')) }} + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} # checkout the correct branch name + fetch-depth: 0 + - name: Download Build Artifact + uses: actions/download-artifact@v4 + with: + name: ${{ env.buildArtifactName }} + path: ${{ env.buildFolderName }} + - name: Publish Release + shell: pwsh + run: ./build.ps1 -tasks publish + env: + GitHubToken: ${{ secrets.GitHubToken }} + GalleryApiToken: ${{ secrets.GalleryApiToken }} + - name: Send Changelog PR + shell: pwsh + run: ./build.ps1 -tasks Create_ChangeLog_GitHub_PR + env: + GitHubToken: ${{ secrets.GitHubToken }} + GalleryApiToken: ${{ secrets.GalleryApiToken }} + ReleaseBranch: main + MainGitBranch: main diff --git a/.github/workflows/deploy-preview-module.yml b/.github/workflows/deploy-preview-module.yml new file mode 100644 index 00000000..478a1011 --- /dev/null +++ b/.github/workflows/deploy-preview-module.yml @@ -0,0 +1,77 @@ +on: + push: + branches: + - develop + paths-ignore: + - CHANGELOG.md + - .vscode/** + - .github/** + - images/** + - tests/** + - '**.md' + - '**.yml' + tags: + - '**' + - '!*preview*' +env: + buildFolderName: output + buildArtifactName: output + testResultFolderName: testResults + +name: Deploy Preview Module + +# This workflow is triggered on push to the develop branch and deploys the module to the PowerShell Gallery as a preview version. +jobs: + Build_Stage_Package_Module: + name: Package Module + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} # checkout the correct branch name + fetch-depth: 0 + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v0.9.15 + with: + versionSpec: 5.x + - name: Evaluate Next Version + uses: gittools/actions/gitversion/execute@v0.9.15 + with: + configFilePath: GitVersion.yml + - name: Build & Package Module + shell: pwsh + run: ./build.ps1 -ResolveDependency -tasks pack + env: + ModuleVersion: ${{ env.gitVersion.NuGetVersionV2 }} + - name: Publish Build Artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.buildArtifactName }} + path: ${{ env.buildFolderName }}/ + + Deploy_Stage_Deploy_Module: + name: Deploy Module + runs-on: ubuntu-latest + needs: + - Build_Stage_Package_Module + if: ${{ success() && (github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')) }} + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} # checkout the correct branch name + fetch-depth: 0 + - name: Download Build Artifact + uses: actions/download-artifact@v4 + with: + name: ${{ env.buildArtifactName }} + path: ${{ env.buildFolderName }} + - name: Publish Release + shell: pwsh + run: ./build.ps1 -tasks publish + env: + GitHubToken: ${{ secrets.GITHUBTOKEN }} + GalleryApiToken: ${{ secrets.GalleryApiToken }} + ReleaseBranch: develop + MainGitBranch: develop diff --git a/.github/workflows/gallery.yml b/.github/workflows/gallery.yml deleted file mode 100644 index c7e14fa7..00000000 --- a/.github/workflows/gallery.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Deploy PowerShell Module to PSGallery - -on: - workflow_dispatch: # Enables manual trigger in GitHub Actions UI - -jobs: - publish: - runs-on: windows-latest # Required for PowerShellGet module - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Install PowerShell dependencies - shell: pwsh - run: | - Install-Module -Name PowerShellGet -Force -AllowClobber -Scope CurrentUser - Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser - Install-Module -Name Az.Accounts -Scope CurrentUser -Force - Install-Module -Name Az.Resources -Scope CurrentUser -Force - Install-Module -Name MicrosoftPowerBIMgmt -Scope CurrentUser -Force - - - name: Publish PowerShell Module - shell: pwsh - env: - PSGALLERY_API_KEY: ${{ secrets.PSGALLERY_API_KEY }} - run: | - $ModulePath = (Get-ChildItem -Path . -Recurse -Filter "*.psd1").FullName - if (-not $ModulePath) { throw "Module manifest (.psd1) not found." } - - Publish-Module -Path (Split-Path -Parent $ModulePath) -NuGetApiKey $env:PSGALLERY_API_KEY -Repository PSGallery diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index e8a452a1..349d3565 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -2,10 +2,10 @@ on: pull_request: branches: - main - - sampler # temporary branch for testing - develop paths-ignore: - CHANGELOG.md +name: Build and Test Module for Pull Request env: buildFolderName: output buildArtifactName: output diff --git a/CHANGELOG.md b/CHANGELOG.md index 0590d24a..1e3b2eec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,23 +7,54 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- For new features. +- Introduced new PowerShell functions for managing Fabric workspaces, recovery points, configurations, tenant settings, and workspace identities. +- Added unit tests for key functions, including `Get-FabricAPIclusterURI` and `Get-FabricCapacityTenantOverrides`. +- Added standard tests for each function and enhanced Help tests to filter by exported commands. +- Added OutputType attributes to several functions for improved type safety. +- Added support for WhatIf and Confirm parameters to update and revoke functions. +- Added Contributor Covenant Code of Conduct and enhanced contributing guidelines. +- Added commit message guidelines for contributors using GitHub Copilot. ### Changed -- For changes in existing functionality. +- Refactored `Get-FabricAPIClusterURI` to use `Invoke-FabricRestApi` for improved consistency. +- Updated validation pattern for `WorkspaceName` to allow additional special characters, then removed the pattern for greater flexibility. +- Improved documentation for many functions, especially around parameters like `WorkspaceId`. +- Refactored multiple functions for clarity, consistency, and maintainability. +- Enhanced error handling and confirmation prompts (ShouldProcess) for potentially destructive actions. +- Updated module manifest and build/test workflows for better automation and deployment. +- Improved code formatting using the dbatools formatter. + +### Fixed + +- Fixed issues with `New-FabricDataPipeline` and its call to `Invoke-FabricAPIRequest`. +- Fixed capital letter handling in test automation. +- Fixed ResourceUrl for token retrieval in `Connect-FabricAccount`. +- Fixed bugs in `New-FabricEventhouse` and improved ShouldProcess logic. +- Fixed parameter naming and example formatting in several functions. ### Deprecated -- For soon-to-be removed features. +- None. ### Removed -- For now removed features. +- Removed unnecessary or duplicate functions (e.g., `Get-AllFabricDatasetRefreshes`, `Get-AllFabricCapacities`). +- Removed obsolete scripts and commented-out configuration paths. -### Fixed +### Security -- For any bug fix. +- None. + +--- + +**Contributors:** +Rob Sewell, Jess Pomfret, Ioana Bouariu, Frank Geisler, Kamil Nowinski, and others. + +**Note:** +For a full list of changes and details, please see the commit history. + +### Added ### Security diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b524ed48..7884d664 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -83,8 +83,23 @@ The workflow for using this and developing the code is shown below. ```PowerShell ./build.ps1 -Tasks build,test ``` - -8. Once you are happy with your code, push your branch to GitHub and create a PR against the repo. +8. Once you are ready to submit your changes for review please ensure that you update the `CHANGELOG.md` file with a summary of your changes. This is important as it helps us keep track of what has changed in the module and makes it easier for users to see what has been added or changed. + + You can use the [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format for this. + + Please add your changes under the `Unreleased` section and then create a new section for the next release. PLease use human readable titles for the changes, such as `Added`, `Changed`, `Fixed`, `Deprecated`, `Removed`, and `Security`. + For example: + + ```markdown + ## [Unreleased] + ### Added + - Added new function to manage Fabric workspaces. + ### Changed + - Updated documentation for `Get-FabricAPIClusterURI`. + ### Fixed + - Fixed issue with `New-FabricDataPipeline` not working correctly. + ``` +9. Once you are happy with your code and you have updated the changelog, push your branch to GitHub and create a PR against the repo. ## Thanks! diff --git a/RequiredModules.psd1 b/RequiredModules.psd1 index 74581735..adef59f5 100644 --- a/RequiredModules.psd1 +++ b/RequiredModules.psd1 @@ -21,7 +21,7 @@ 'Sampler.GitHubTasks' = 'latest' MarkdownLinkCheck = 'latest' PSFramework = 'latest' - 'Az.Accounts' = 'latest' - 'Az.Resources' = 'latest' - 'MicrosoftPowerBIMgmt' = 'latest' + 'Az.Accounts' = '4.2.0' + 'Az.Resources' = '6.15.1' + 'MicrosoftPowerBIMgmt' = '1.2.1111' } diff --git a/build.yaml b/build.yaml index 64d9797d..470eaafc 100644 --- a/build.yaml +++ b/build.yaml @@ -76,9 +76,10 @@ BuildWorkflow: publish: - Publish_Release_To_GitHub # Runs first, if token is expired it will fail early - - Publish_GitHub_Wiki_Content - + # - Publish_GitHub_Wiki_Content - publish_module_to_gallery + # - Create_Changelog_Branch + #################################################### # PESTER Configuration # @@ -120,16 +121,6 @@ Pester: #CodeCoverageFilePattern: JaCoCo_Merge.xml # the pattern used to search all pipeline test job artifacts #CodeCoverageMergedOutputFile: JaCoCo_coverage.xml # the file that is created for the merged code coverage -DscTest: - ExcludeTag: - - "Common Tests - New Error-Level Script Analyzer Rules" - Tag: - ExcludeSourceFile: - - output - ExcludeModuleFile: - - Modules/DscResource.Common - # - Templates - # Import ModuleBuilder tasks from a specific PowerShell module using the build # task's alias. Wildcard * can be used to specify all tasks that has a similar # prefix and or suffix. The module contain the task must be added as a required @@ -152,3 +143,18 @@ TaskHeader: | Write-Build DarkGray " $Path" Write-Build DarkGray " $($Task.InvocationInfo.ScriptName):$($Task.InvocationInfo.ScriptLineNumber)" "" +#################################################### +# Changelog Configuration # +#################################################### +ChangelogConfig: + FilesToAdd: + - 'CHANGELOG.md' + UpdateChangelogOnPrerelease: false + +#################################################### +# Git Configuration # +#################################################### +GitConfig: + UserName: Automation Bot + UserEmail: automation_bot@fabrictools.io + diff --git a/source/FabricTools.psd1 b/source/FabricTools.psd1 index e8095fde..63f76618 100644 --- a/source/FabricTools.psd1 +++ b/source/FabricTools.psd1 @@ -1,9 +1,9 @@ # # Module manifest for module 'FabricTools' # -# Generated by: mrrob +# Generated by: The FabricTools Team # -# Generated on: 08/05/2025 +# Generated on: 26/05/2025 # @{ @@ -21,19 +21,23 @@ ModuleVersion = '0.0.1' GUID = '0ba3e49a-b47e-4beb-8434-5a34ad41ae72' # Author of this module -Author = 'mrrob' +Author = 'The FabricTools Team' # Company or vendor of this module -CompanyName = 'mrrob' + CompanyName = 'fabrictools.io' # Copyright statement for this module -Copyright = '(c) mrrob. All rights reserved.' +Copyright = 'Copyright (c) 2025 by FabricTools Team' # Description of the functionality provided by this module -Description = 'A module to be able to do more with Microsoft Fabric.' +Description = 'A module to be able to do more with Microsoft Fabric. + It lets you pause and resume Fabric capacities. + Adds functionallity previously only available with the REST API as PowerShell functions. + There are also functions to make it easier to monitor usage metrics and refreshes. + It also adds Fabric-friendly aliases for PowerBI functions to make it easier to use the module.' # Minimum version of the PowerShell engine required by this module -PowerShellVersion = '5.0' +PowerShellVersion = '5.1' # Name of the PowerShell host required by this module # PowerShellHostName = '' @@ -51,12 +55,16 @@ PowerShellVersion = '5.0' # ProcessorArchitecture = '' # Modules that must be imported into the global environment prior to importing this module -RequiredModules = @() +RequiredModules = @( + @{ ModuleName = 'Az.Accounts' ; ModuleVersion = '4.2.0' }, + @{ ModuleName = 'MicrosoftPowerBIMgmt.Profile' ; ModuleVersion = '1.2.1111' }, + @{ ModuleName = 'Az.Resources' ; ModuleVersion = '6.15.1' } +) -# Assemblies that must be loaded prior to importing this module +# Assemblies that must be loaded prior to importing this module. # RequiredAssemblies = @() -# Script files (.ps1) that are run in the caller's environment prior to importing this module. +# Script files (.ps1) that are run in the caller's environment prior to importing this module # ScriptsToProcess = @() # Type files (.ps1xml) to be loaded when importing this module @@ -130,14 +138,3 @@ PrivateData = @{ } - - - - - - - - - - - diff --git a/source/Public/Capacity/Get-FabricCapacities.ps1 b/source/Public/Capacity/Get-FabricCapacities.ps1 index b2280eae..58daebb7 100644 --- a/source/Public/Capacity/Get-FabricCapacities.ps1 +++ b/source/Public/Capacity/Get-FabricCapacities.ps1 @@ -64,11 +64,12 @@ function Get-FabricCapacities { # For each resource group, get all resources of type "Microsoft.Fabric/capacities" foreach ($r in $rgs) { # Get all resources of type "Microsoft.Fabric/capacities" and add them to the results array - $res += Get-AzResource -ResourceGroupName $r.ResourceGroupName -resourcetype "Microsoft.Fabric/capacities" -ErrorAction SilentlyContinue + $res += Get-AzResource -ResourceGroupName $r.ResourceGroupName -ResourceType "Microsoft.Fabric/capacities" -ErrorAction SilentlyContinue } } } # Return the results return $res -} \ No newline at end of file +} + diff --git a/source/Public/Connect-FabricAccount.ps1 b/source/Public/Connect-FabricAccount.ps1 index 253150d3..8046f417 100644 --- a/source/Public/Connect-FabricAccount.ps1 +++ b/source/Public/Connect-FabricAccount.ps1 @@ -41,7 +41,7 @@ function Connect-FabricAccount { Connect-AzAccount -TenantId $TenantId | Out-Null Write-Verbose "Get authentication token" - $FabricSession.FabricToken = (Get-AzAccessToken -ResourceUrl $FabricSession.BaseApiUrl).Token + $FabricSession.FabricToken = (Get-AzAccessToken -ResourceUrl $FabricSession.ResourceUrl).Token Write-Verbose "Token: $($FabricSession.FabricToken)" Write-Verbose "Setup headers for API calls" diff --git a/source/Public/Eventhouse/New-FabricEventhouse.ps1 b/source/Public/Eventhouse/New-FabricEventhouse.ps1 index d2db2d3c..2ab61627 100644 --- a/source/Public/Eventhouse/New-FabricEventhouse.ps1 +++ b/source/Public/Eventhouse/New-FabricEventhouse.ps1 @@ -152,17 +152,6 @@ function New-FabricEventhouse -ResponseHeadersVariable "responseHeader" ` -StatusCodeVariable "statusCode" } - # Step 4: Make the API request - $response = Invoke-RestMethod ` - -Headers $FabricConfig.FabricHeaders ` - -Uri $apiEndpointUrl ` - -Method Post ` - -Body $bodyJson ` - -ContentType "application/json" ` - -ErrorAction Stop ` - -SkipHttpErrorCheck ` - -ResponseHeadersVariable "responseHeader" ` - -StatusCodeVariable "statusCode" Write-Message -Message "Response Code: $statusCode" -Level Debug diff --git a/source/Public/Workspace/New-FabricWorkspace.ps1 b/source/Public/Workspace/New-FabricWorkspace.ps1 index a6c020ed..5dc12c8a 100644 --- a/source/Public/Workspace/New-FabricWorkspace.ps1 +++ b/source/Public/Workspace/New-FabricWorkspace.ps1 @@ -31,7 +31,6 @@ Author: Tiago Balabuch param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] - [ValidatePattern('^[a-zA-Z0-9_\- ]*$')] [string]$WorkspaceName, [Parameter(Mandatory = $false)]