Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add recipes and github action to test autopkg release nupkg #423

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions .github/workflows/AutoPkgReleaseNupkg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
name: Test AutoPkg Release Nupkg
# based upon: https://github.com/autopkg/recipes/blob/master/AutoPkg/AutoPkgGitMaster.nupkg.recipe

on:
push:
paths:
- ".github/workflows/AutoPkgReleaseNupkg.yaml"
- "AutoPkg/AutoPkg-Release-Source.download.recipe.yaml"
- "AutoPkg/AutoPkg-Release-Source.nupkg.recipe.yaml"
pull_request:
paths:
- ".github/workflows/AutoPkgReleaseNupkg.yaml"
- "AutoPkg/AutoPkg-Release-Source.download.recipe.yaml"
- "AutoPkg/AutoPkg-Release-Source.nupkg.recipe.yaml"

jobs:
AutoPkgNupkg:
runs-on: windows-latest
steps:
# only needed on self hosted windows runners:
- name: set powershell execution policy CurrentUser
if: runner.os == 'Windows'
shell: cmd
run: powershell -command "Set-ExecutionPolicy -Force -ExecutionPolicy RemoteSigned -Scope CurrentUser"

- name: Set token
# required for githubreleaseinfoprovider in github actions
# without this, API limits will be hit
run: |
cd ~
echo ${{ secrets.GITHUB_TOKEN }} > ".autopkg_gh_token"

- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.8

# - name: Install requirements
# run: pip install --requirement requirements.txt
- name: rename folder, git clone autopkg
shell: cmd
run: |
rename "AutoPkg" "AutoPkgRecipe"
git clone https://github.com/autopkg/autopkg.git
- name: Install AutoPkg Reqirements
run: pip install --requirement autopkg/requirements.txt
- name: create empty config windows
# https://stackoverflow.com/questions/57946173/github-actions-run-step-on-specific-os
if: runner.os == 'Windows'
shell: cmd
run: |
if not exist "%USERPROFILE%/AppData/Local/Autopkg" mkdir "%USERPROFILE%/AppData/Local/Autopkg"
if not exist "%USERPROFILE%/AppData/Local/Autopkg/config.json" echo {} > "%USERPROFILE%/AppData/Local/Autopkg/config.json"
- name: create default autopkg config file Linux
if: runner.os == 'Linux'
run: |
cd ~ && mkdir -p .config/Autopkg
cd ~ && echo {} > .config/Autopkg/config.json
- name: run test recipe
run: python autopkg/Code/autopkg run -v com.github.autopkg.test.AutoPkgCoreProcessors
- name: run nupkg recipe
run: python autopkg/Code/autopkg run -v AutoPkgRecipe/AutoPkg-Release-Source.nupkg.recipe.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: chocolately install python
# python versions: 3.8.10, 3.9.12, 3.10.4
# - See Here: https://community.chocolatey.org/packages/python#versionhistory
run: choco install python3 --version 3.9.12 --no-progress --yes --force --force-dependencies
- name: test chocolately install autopkg.nupkg
run: choco install autopkg -s "$env:USERPROFILE\Library\AutoPkg\Cache\com.github.autopkg.nupkg.AutoPkgRelease\nupkgs" --no-progress --yes --force --force-dependencies
- name: test autopkg chocolately install
run: autopkg run -vv com.github.autopkg.test.AutoPkgCoreProcessors
# Related:
# - https://github.com/jgstew/bigfix-content/blob/master/.github/workflows/autopkg.yaml
23 changes: 23 additions & 0 deletions AutoPkg/AutoPkg-Release-Source.download.recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
Description: Download Source zip for Released AutoPkg
# based upon: https://github.com/jgstew/jgstew-recipes/blob/main/AutoPkgRecipe/AutoPkgRelease.download.recipe.yaml
Identifier: com.github.autopkg.download.AutoPkgReleaseSource
Input:
NAME: autopkg
MinimumVersion: "2.3"
Process:
- Processor: GitHubReleasesInfoProvider
Arguments:
# https://github.com/autopkg/autopkg/releases/tag/v2.4.1
# https://github.com/autopkg/autopkg/archive/refs/tags/v2.4.1.zip
github_repo: autopkg/autopkg
#asset_regex: ".*.zip"
- Processor: URLDownloader
Arguments:
url: "https://github.com/autopkg/autopkg/archive/refs/tags/v%version%.zip"
filename: autopkg.zip
# NOTE: a valid %GITHUB_TOKEN% is only required if running in a GitHub Action:
# - if run locally without %GITHUB_TOKEN% this should still work unless you hit API limits locally
# - https://github.community/t/using-github-token-in-http-call-to-api/16608/8?u=jgstew
request_headers: {"authorization": "Bearer %GITHUB_TOKEN%"}
- Processor: EndOfCheckPhase
33 changes: 33 additions & 0 deletions AutoPkg/AutoPkg-Release-Source.nupkg.recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
# Based upon: https://github.com/autopkg/recipes/blob/master/AutoPkg/AutoPkgGitMaster.nupkg.recipe
Description: Build Chocolatey Package for Released AutoPkg
Identifier: com.github.autopkg.nupkg.AutoPkgRelease
Input:
NAME: autopkg
PYTHON_PACKAGE_ID: python3
PYTHON_VERSION: "3.8"
MinimumVersion: "2.3"
SupportedPlatforms:
- Windows
ParentRecipe: com.github.autopkg.download.AutoPkgReleaseSource
Process:
- Processor: ChocolateyPackager
Arguments:
id: "%NAME%"
version: "%version%"
title: "%NAME%"
authors: Autopkg Contributors
description: AutoPkg is an automation framework software packaging and distribution, oriented towards the tasks one would normally perform manually to prepare third-party software for mass deployment to managed clients.
installer_type: zip
dependencies:
- {"id": "%PYTHON_PACKAGE_ID%", "version": "%PYTHON_VERSION%"}
additional_install_actions: |
$AutoPkgDir = Resolve-Path $env:ChocolateyPackageFolder\tools\autopkg-*
& python -m venv $AutoPkgDir\.python-env
Write-Output 'Running "pip install ..." to generate self-contained environment.'
& $AutoPkgDir\.python-env\Scripts\pip --disable-pip-version-check install -r $AutoPkgDir\requirements.txt --quiet
Get-ChildItem -Recurse $AutoPkgDir\.python-env -Include *.exe, *.dll |
foreach { New-Item -ItemType File "$($_.FullName).ignore" } | Write-Verbose
Install-ChocolateyPowershellCommand -PackageName $packageArgs.packageName -PsFileFullPath $AutoPkgDir\Scripts\autopkg.ps1

# TODO: set output var `nuget_package_path` to ENV for further github action use
41 changes: 41 additions & 0 deletions AutoPkg/AutopkgCoreProcessors.test.recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
Description: Test AutoPkg Core Cross Platform Processors
Identifier: com.github.autopkg.test.AutoPkgCoreProcessors
Input:
NAME: AutoPkgCoreTest
MinimumVersion: "2.3"
Process:
# TODO: add: PlistEditor, PlistReader, Unarchiver, Versioner
- Processor: DeprecationWarning
# https://github.com/autopkg/autopkg/blob/master/Code/autopkglib/DeprecationWarning.py
Arguments:
warning_message: "This is just a test, not a real Deprecation Warning"
- Processor: FileCreator
# https://github.com/autopkg/autopkg/blob/master/Code/autopkglib/FileCreator.py
Arguments:
file_path: "test_file.txt"
file_content: "Hello World! FileCreator Processor test"
- Processor: FileFinder
# https://github.com/autopkg/autopkg/blob/master/Code/autopkglib/FileFinder.py
Arguments:
pattern: "**test_file.txt"
- Processor: FileMover
# https://github.com/autopkg/autopkg/blob/master/Code/autopkglib/FileMover.py
Arguments:
source: "test_file.txt"
target: "test_file_moved.txt"
- Processor: Copier
# https://github.com/autopkg/autopkg/blob/master/Code/autopkglib/Copier.py
Arguments:
source_path: "test_file_moved.txt"
destination_path: "test_file.txt"
- Processor: PackageRequired
# https://github.com/autopkg/autopkg/blob/master/Code/autopkglib/PackageRequired.py
Arguments:
PKG: "test_file.txt"
# PathDeleter should have an option to NOT raise an error if file not found
# it is a common practice to "delete" before copy or "delete" before move
- Processor: PathDeleter
# https://github.com/autopkg/autopkg/blob/master/Code/autopkglib/PathDeleter.py
Arguments:
path_list: ["test_file.txt", "test_file_moved.txt"]