autopkg / smithjw-recipes

Smithjw's AutoPkg recipes
Apache License 2.0
14 stars 16 forks source link

Add AutoPkg pre-commit hooks #38

Closed homebysix closed 1 year ago

homebysix commented 1 year ago

This PR adds a pre-commit configuration tailored to AutoPkg recipes, and this repository specifically. It also includes the fixes to recipes needed to pass the initial checks, with two exceptions:

Here's an example of what pre-commit will produce once this PR is merged, when errors or warnings exist:

% pre-commit run --all-files
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...............................................................Passed
check xml................................................................Passed
check for added large files..............................................Passed
Check AutoPkg Recipes....................................................Failed
- hook id: check-autopkg-recipes
- exit code: 1

Luxafor/Luxafor.download.recipe: Contains a download processor, but no EndOfCheckPhase processor.
Luxafor/Luxafor.download.recipe: URLTextSearcher processor requires minimum AutoPkg version 0.2.9
Xcode/Xcode.jamf.recipe.yaml: WARNING: JamfUploader processors are not in the recommended order: JamfCategoryUploader, JamfPackageUploader, JamfScriptUploader, JamfComputerGroupUploader, JamfPolicyUploader.
Little Snitch/Little Snitch 5.download.recipe: CodeSignatureVerifier processor requires minimum AutoPkg version 0.3.1
Little Snitch/Little Snitch 5.download.recipe: URLTextSearcher processor requires minimum AutoPkg version 0.2.9
Microsoft/Azure_Data_Studio.jamf.recipe.yaml: Processor EndOfCheckPhase is not conventional for this recipe type.
Zoom/ZoomOutlook.download.recipe: CodeSignatureVerifier processor requires minimum AutoPkg version 0.3.1
Zoom/ZoomClientSharing.download.recipe: CodeSignatureVerifier processor requires minimum AutoPkg version 0.3.1
JetBrains/RubyMine.pkg.recipe: FileMover processor requires minimum AutoPkg version 0.2.9
Zoom/ZoomMeetings.download.recipe: CodeSignatureVerifier processor requires minimum AutoPkg version 0.3.1
Xray Exploratory App/Xray_Exploratory_App.download.recipe.yaml: EndOfCheckPhase typically goes after a download processor, not before.
Little Snitch/Little Snitch.download.recipe: URLTextSearcher processor requires minimum AutoPkg version 0.2.9
Docker/Docker.munki.recipe.yaml: pkginfo key supported_architectures should be type <class 'list'>, not type <class 'str'>
Zoom/ZoomIT.download.recipe: CodeSignatureVerifier processor requires minimum AutoPkg version 0.3.1
GitHub/GitHub_Desktop.download.recipe.yaml: Contains a download processor, but no EndOfCheckPhase processor.
Apple/Enable_macOS_Beta.jamf.recipe.yaml: WARNING: JamfUploader processors are not in the recommended order: JamfCategoryUploader, JamfExtensionAttributeUploader, JamfScriptUploader, JamfComputerGroupUploader, JamfPolicyUploader.
Luxafor/Luxafor.pkg.recipe: PlistReader processor requires minimum AutoPkg version 0.2.5
Viscosity/Viscosity.pkg.recipe: FileMover processor requires minimum AutoPkg version 0.2.9
Zoom/ZoomRooms.download.recipe: CodeSignatureVerifier processor requires minimum AutoPkg version 0.3.1

Forbid AutoPkg Overrides.................................................Passed
Forbid AutoPkg Trust Info................................................Passed

Here's an example of all tests passing successfully:

% pre-commit run --all-files
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...............................................................Passed
check xml................................................................Passed
check for added large files..............................................Passed
Check AutoPkg Recipes....................................................Passed
Forbid AutoPkg Overrides.................................................Passed
Forbid AutoPkg Trust Info................................................Passed

Some more details and examples in this quick talk from MacDevOpsYVR: https://www.youtube.com/watch?v=1UCyGC6DVOU