Skip to content

Commit

Permalink
feat!: install and validate spec
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Mar 8, 2024
1 parent 7ed8230 commit 5fbd564
Show file tree
Hide file tree
Showing 8 changed files with 427 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ jobs:
id: action
uses: ./
with:
formula_file: ${{ github.workspace }}/tests/Formula/hello_world.rb
git_email: ${{ secrets.GH_BOT_EMAIL }}
git_username: ${{ secrets.GH_BOT_NAME }}
local_repo_directory: ${{ github.workspace }}/tests
target_repo: ${{ github.repository }}
target_repo_branch: tests
token: ${{ secrets.GH_BOT_TOKEN }}
Expand Down
160 changes: 159 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,160 @@
# ignore jetbrains files
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/
119 changes: 93 additions & 26 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ name: "Homebrew Release"
description: "A reusable action to publish a Homebrew formula to a tap."
author: "LizardByte"
inputs:
local_repo_directory:
description: 'The location of the local directory. If the default is not used, you must pass the entire path.'
default: "homebrew"
required: false
formula_file:
description: 'The full path to the formula file.'
required: true
git_email:
description: 'The email to use for the commit.'
required: true
Expand All @@ -28,33 +27,101 @@ inputs:
runs:
using: "composite"
steps:
- name: Checkout database
uses: actions/checkout@v4
- name: OS check
id: os-check
shell: bash
run: |
echo "Detected OS: ${{ runner.os }}"
if [[ "${{ runner.os }}" == "Windows" ]]; then
# fail if Windows
echo "${{ runner.os }} is not supported"
exit 1
fi
- name: Setup Python
id: setup-python
uses: actions/setup-python@v5
with:
repository: ${{ inputs.target_repo }}
ref: ${{ inputs.target_repo_branch }}
path: ${{ github.action_path }}/build
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of the personal token
fetch-depth: 0 # otherwise, will fail to push refs to dest repo
python-version: "3.11"
update-environment: false

- name: Prepare Homebrew repo
- name: Create venv
# borrowed from LizardByte/plexhints action
id: venv
shell: bash
working-directory: ${{ github.action_path }}
run: |
if [ "${{ inputs.local_repo_directory }}" == "homebrew" ]; then
source_path="${{ github.workspace }}/${{ inputs.local_repo_directory }}"
echo "::group::Create venv"
if [[ "${{ runner.os }}" == "Windows" ]]; then
# use cygpath to convert windows path to unix path while creating venv
$(cygpath.exe -u "${{ steps.setup-python.outputs.python-path }}") -m venv venv
# set python executable as step output
echo "python-path=$(cygpath.exe -u $(pwd)\\venv\\Scripts\\python.exe)" >> $GITHUB_OUTPUT
else
source_path="${{ inputs.local_repo_directory }}"
${{ steps.setup-python.outputs.python-path }} -m venv venv
# set python executable as step output
echo "python-path=$(pwd)/venv/bin/python" >> $GITHUB_OUTPUT
fi
echo "::endgroup::"
# copy local repo to target repo
cp -f -r ${source_path}/. ${{ github.action_path }}/build/
- name: Install Python Requirements
id: install-requirements
shell: bash
working-directory: ${{ github.action_path }}
run: |
echo "::group::Install Python Requirements"
# install requirements required for this action to complete
"${{ steps.venv.outputs.python-path }}" -m pip install -r requirements-action.txt
echo "::endgroup::"
- name: GitHub Commit & Push
uses: actions-js/[email protected]
with:
author_email: ${{ inputs.git_email }}
author_name: ${{ inputs.git_username }}
branch: ${{ inputs.target_repo_branch }} # commit to target branch
directory: ${{ github.action_path }}/build # use the build directory
github_token: ${{ inputs.token }}
message: "Update ${{ github.repository }} to ${{ github.sha }}"
- name: Homebrew tests
env:
INPUT_FORMULA_FILE: ${{ inputs.formula_file }}
id: homebrew-tests
shell: bash
working-directory: ${{ github.action_path }}
run: |
echo "::group::Setup Homebrew PATH"
if [[ "${{ runner.os }}" == "Linux" ]]; then
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md#homebrew-note
echo "Adding Homebrew to PATH"
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
fi
echo "::endgroup::"
echo "::group::Homebrew tests"
"${{ steps.venv.outputs.python-path }}" -u ./action/main.py
echo "::endgroup::"
# - name: Checkout homebrew repo
# uses: actions/checkout@v4
# with:
# repository: ${{ inputs.target_repo }}
# ref: ${{ inputs.target_repo_branch }}
# path: ${{ github.action_path }}/build
# persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of the personal token
# fetch-depth: 0 # otherwise, will fail to push refs to dest repo
#
# - name: Prepare Homebrew repo
# shell: bash
# run: |
# if [ "${{ inputs.local_repo_directory }}" == "homebrew" ]; then
# source_path="${{ github.workspace }}/${{ inputs.local_repo_directory }}"
# else
# source_path="${{ inputs.local_repo_directory }}"
# fi
#
# # copy local repo to target repo
# cp -f -r ${source_path}/. ${{ github.action_path }}/build/
#
# - name: GitHub Commit & Push
# uses: actions-js/[email protected]
# with:
# author_email: ${{ inputs.git_email }}
# author_name: ${{ inputs.git_username }}
# branch: ${{ inputs.target_repo_branch }} # commit to target branch
# directory: ${{ github.action_path }}/build # use the build directory
# github_token: ${{ inputs.token }}
# message: "Update ${{ github.repository }} to ${{ github.sha }}"
Empty file added action/__init__.py
Empty file.
Loading

0 comments on commit 5fbd564

Please sign in to comment.