Skip to content

Commit

Permalink
Prepare RestSetAcls for PowerShellGallery publish (#218)
Browse files Browse the repository at this point in the history
* Add github actions

* Add psd1 file

* Rework file structure for publishing

* Fix dev build tools
  • Loading branch information
MaximeKjaer authored Jun 14, 2024
1 parent c3a04a1 commit 557bd6c
Show file tree
Hide file tree
Showing 18 changed files with 415 additions and 78 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/RestSetAcls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Test RestSetAcls
on:
push:
paths:
- ".github/workflows/RestSetAcls.yml"
- "RestSetAcls/**"
pull_request:
paths:
- ".github/workflows/RestSetAcls.yml"
- "RestSetAcls/**"

jobs:
pester-test:
name: Pester test
runs-on: windows-latest
defaults:
run:
working-directory: .\RestSetAcls
shell: pwsh
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Run all Pester tests
run: |
.\init.ps1
.\test.ps1
Check-manifest:
name: Check .psd1 manifest file
runs-on: windows-latest
defaults:
run:
working-directory: .\RestSetAcls
shell: pwsh
steps:
- uses: actions/checkout@v4
- name: Check .psd1 file with Test-ModuleManifest
run: |
.\init.ps1
.\check-manifest.ps1
lint-with-PSScriptAnalyzer:
name: Install and run PSScriptAnalyzer
runs-on: windows-latest
defaults:
run:
working-directory: .\RestSetAcls
shell: pwsh
steps:
- uses: actions/checkout@v4
- name: Lint with PSScriptAnalyzer
run: |
.\init.ps1
.\lint.ps1
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

# RestSetAcls
RestSetAcls/bin

# User-specific files
*.suo
*.user
Expand Down
4 changes: 2 additions & 2 deletions RestSetAcls/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
2. Run the tests
```powershell
Invoke-Pester -Output Detailed
.\test.ps1
```
## Setting up a test run
Expand All @@ -40,7 +40,7 @@
1. Create test files
```powershell
.\RestSetAcls\TestSetup.ps1 -Context $context -FileShareName $FileShareName -NumberDirs 3 -NumberFilesPerDir 3 -Depth 1
.\RestSetAcls\test\TestSetup.ps1 -Context $context -FileShareName $FileShareName -NumberDirs 3 -NumberFilesPerDir 3 -Depth 1
```
This will create a directory structure with 3 directories, each containing 3 files:
Expand Down
File renamed without changes.
148 changes: 148 additions & 0 deletions RestSetAcls/RestSetAcls/RestSetAcls.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
#
# Module manifest for module 'RestSetAcls'
#
# Generated by: Microsoft Corporation
#
# Generated on: 5/8/2024
#

@{

# Script module or binary module file associated with this manifest.
RootModule = 'RestSetAcls.psm1'

# Version number of this module.
ModuleVersion = '0.1.1'

# Supported PSEditions
# CompatiblePSEditions = @()

# ID used to uniquely identify this module
GUID = '1b9ea644-06b1-47d4-8da4-f8758a43fc49'

# Author of this module
Author = 'Microsoft Corporation'

# Company or vendor of this module
CompanyName = 'Microsoft Corporation'

# Copyright statement for this module
Copyright = '(c) Microsoft Corporation. All rights reserved.'

# Description of the functionality provided by this module
Description = 'Set file permissions on an Azure Files share using REST API'

# Minimum version of the PowerShell engine required by this module
PowerShellVersion = '5.1'

# Name of the PowerShell host required by this module
# PowerShellHostName = ''

# Minimum version of the PowerShell host required by this module
# PowerShellHostVersion = ''

# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''

# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# ClrVersion = ''

# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(
@{
ModuleName = "Az.Storage"
GUID = "dfa9e4ea-1407-446d-9111-79122977ab20"
ModuleVersion = "6.0.0"
}
)

# 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.
# ScriptsToProcess = @()

# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @(
"Set-AzureFilesAclRecursive"
)

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()

# Variables to export from this module
VariablesToExport = '*'

# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = @()

# DSC resources to export from this module
# DscResourcesToExport = @()

# List of all modules packaged with this module
# ModuleList = @()

# List of all files packaged with this module
# FileList = @()

# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{

PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
# See: https://learn.microsoft.com/en-us/powershell/gallery/concepts/publishing-guidelines?view=powershellget-3.x#tag-your-package-with-the-compatible-pseditions-and-platforms
Tags = @(
"Azure",
"Storage",
"ACL",
"PSEdition_Desktop", # Packages that are compatible with Windows PowerShell
"PSEdition_Core", # Packages that are compatible with PowerShell 6 and higher
"Windows" # Packages that are compatible with the Windows Operating System
)

# A URL to the license for this module.
LicenseUri = 'https://raw.githubusercontent.com/Azure-Samples/azure-files-samples/master/LICENSE.md'

# A URL to the main website for this project.
ProjectUri = 'https://github.com/Azure-Samples/azure-files-samples'

# A URL to an icon representing this module.
# IconUri = ''

# ReleaseNotes of this module
# ReleaseNotes = ''

# Prerelease string of this module
# Prerelease = ''

# Flag to indicate whether the module requires explicit user acceptance for install/update/save
# RequireLicenseAcceptance = $false

# External dependent modules of this module
# ExternalModuleDependencies = @()

} # End of PSData hashtable

} # End of PrivateData hashtable

# HelpInfo URI of this module
# HelpInfoURI = ''

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''

}

Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ function Get-AzureFilePermissionKey {
}

function Set-AzureFilesAclRecursive {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[Microsoft.WindowsAzure.Commands.Storage.AzureStorageContext]$Context,
Expand Down
File renamed without changes.
75 changes: 0 additions & 75 deletions RestSetAcls/TestSetup.ps1

This file was deleted.

13 changes: 13 additions & 0 deletions RestSetAcls/build.depend.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This file lists out development requirements for the module.
# For the runtime requirements, see the module manifest.
@{
PSDependOptions = @{
Target = 'bin\Dependencies'
Install = $true
AddToPath = $true
}

Pester = 'latest'
PSScriptAnalyzer = 'latest'
'Az.Storage' = '6.0.0'
}
1 change: 1 addition & 0 deletions RestSetAcls/check-manifest.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Test-ModuleManifest -Path $PSScriptRoot\RestSetAcls\RestSetAcls.psd1
15 changes: 15 additions & 0 deletions RestSetAcls/init.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Write-Host "Checking if PSDepend is installed" -ForegroundColor White
$installed = $null -ne (Get-Module PSDepend -ListAvailable)

if ($installed) {
Write-Host "Already installed"
} else {
Write-Host "Not installed"
Write-Host "`nInstalling PSDepend" -ForegroundColor White
Install-Module -Name PSDepend -Repository PSGallery -Force
Write-Host "Done"
}

Write-Host "`nInstalling build dependencies" -ForegroundColor White
Invoke-PSDepend -Path $PSScriptRoot\build.depend.psd1 -Force
Write-Host "Done"
8 changes: 8 additions & 0 deletions RestSetAcls/lint.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Invoke-ScriptAnalyzer -Path $PSScriptRoot\RestSetAcls -Severity Warning -Recurse -Outvariable issues
$errors = $issues.Where({$_.Severity -eq 'Error'})
$warnings = $issues.Where({$_.Severity -eq 'Warning'})
if ($errors) {
Write-Error "There were $($errors.Count) errors and $($warnings.Count) warnings total." -ErrorAction Stop
} else {
Write-Output "There were $($errors.Count) errors and $($warnings.Count) warnings total."
}
Loading

0 comments on commit 557bd6c

Please sign in to comment.