Skip to content

Commit

Permalink
add github workflows and docs to template
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh5 committed May 29, 2021
1 parent 39b22bc commit 2aa0b15
Show file tree
Hide file tree
Showing 5 changed files with 483 additions and 0 deletions.
284 changes: 284 additions & 0 deletions .github/workflows/plugin-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,284 @@
name: Unmanic Plugin Test and Generate Repo

on:
push:
branches:
- '**'
pull_request:
branches:
- 'official'
- 'master'

jobs:

# Ensure that all plugins contain the require files and that
# certain files or directories are not present.
plugins-contain-require-files:
runs-on: ubuntu-latest
name: Plugins contain all require files
steps:
# Checkout
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

# _____ ____ _
# | ____|_ __ ___ _ _ _ __ ___ | _ \ _ __ ___ ___ ___ _ __ | |_
# | _| | '_ \/ __| | | | '__/ _ \ | |_) | '__/ _ \/ __|/ _ \ '_ \| __|
# | |___| | | \__ \ |_| | | | __/ | __/| | | __/\__ \ __/ | | | |_
# |_____|_| |_|___/\__,_|_| \___| |_| |_| \___||___/\___|_| |_|\__|
#
- name: Check .gitignore in all plugin folders
if: success() || failure()
run: |
success=0
for plugin_dir in source/*; do
if [ -d "${plugin_dir}" ]; then
# Ensure this directory contains a .gitignore file
if [ -e "${plugin_dir}/.gitignore" ]; then
echo "PASS - Found .gitignore in plugin '${plugin_dir}'"
else
echo "FAIL - Missing .gitignore in plugin '${plugin_dir}'"
success=1
fi
fi
done
if [ ${success} -gt 0 ]; then
exit 1
fi
- name: Check info.json in all plugin folders
if: success() || failure()
run: |
success=0
for plugin_dir in source/*; do
if [ -d "${plugin_dir}" ]; then
# Ensure this directory contains a info.json file
if [ -e "${plugin_dir}/info.json" ]; then
echo "PASS - Found info.json in plugin '${plugin_dir}'"
else
echo "FAIL - Missing info.json in plugin '${plugin_dir}'"
success=1
fi
fi
done
if [ ${success} -gt 0 ]; then
exit 1
fi
- name: Check LICENSE file in all plugin folders
if: success() || failure()
run: |
success=0
for plugin_dir in source/*; do
if [ -d "${plugin_dir}" ]; then
# Ensure this directory contains a LICENSE file
if [ -e "${plugin_dir}/LICENSE" ]; then
echo "PASS - Found LICENSE in plugin '${plugin_dir}'"
else
echo "FAIL - Missing LICENSE in plugin '${plugin_dir}'"
success=1
fi
fi
done
if [ ${success} -gt 0 ]; then
exit 1
fi
- name: Check plugin.py in all plugin folders
if: success() || failure()
run: |
success=0
for plugin_dir in source/*; do
if [ -d "${plugin_dir}" ]; then
# Ensure this directory contains a plugin.py file
if [ -e "${plugin_dir}/plugin.py" ]; then
echo "PASS - Found plugin.py in plugin '${plugin_dir}'"
else
echo "FAIL - Missing plugin.py in plugin '${plugin_dir}'"
success=1
fi
fi
done
if [ ${success} -gt 0 ]; then
exit 1
fi
- name: Check python source files contain the required SPDX identifier in header
if: success() || failure()
run: |
success=0
for plugin_dir in source/*; do
if [ -d "${plugin_dir}" ]; then
correct_header=0
# Ensure this directory contains a settings.json file
for python_file in $(find ${plugin_dir} -name '*.py' -not -path "${plugin_dir}/site-packages/*"); do
if ! grep -q "Copyright:" "${python_file}"; then
echo "FAIL - Python file '${python_file}' Missing required SPDX identifier in header"
echo " See 'Standard License Header' here: https://spdx.org/licenses/GPL-3.0-only.html#licenseHeader"
correct_header=1
success=1
continue
fi
if ! grep -q "Copyright (C)" "${python_file}"; then
echo "FAIL - Python file '${python_file}' Missing required SPDX identifier in header"
echo " See 'Standard License Header' here: https://spdx.org/licenses/GPL-3.0-only.html#licenseHeader"
correct_header=1
success=1
continue
fi
if ! grep -q "This program is free software" "${python_file}"; then
echo "FAIL - Python file '${python_file}' Missing required SPDX identifier in header"
echo " See 'Standard License Header' here: https://spdx.org/licenses/GPL-3.0-only.html#licenseHeader"
correct_header=1
success=1
continue
fi
if ! grep -q "This program is distributed in the hop" "${python_file}"; then
echo "FAIL - Python file '${python_file}' Missing required SPDX identifier in header"
echo " See 'Standard License Header' here: https://spdx.org/licenses/GPL-3.0-only.html#licenseHeader"
correct_header=1
success=1
continue
fi
if ! grep -q "You should have received a copy of the GNU General Public License along with this program" "${python_file}"; then
echo "FAIL - Python file '${python_file}' Missing required SPDX identifier in header"
echo " See 'Standard License Header' here: https://spdx.org/licenses/GPL-3.0-only.html#licenseHeader"
correct_header=1
success=1
continue
fi
done
if [ ${correct_header} == 0 ]; then
echo "PASS - All python files in plugin '${plugin_dir}' contain the correct SPDX identifier in header"
fi
fi
done
if [ ${success} -gt 0 ]; then
exit 1
fi
# _____ __ __ _ _
# | ____|_ __ ___ _ _ _ __ ___ | \/ (_)___ ___(_)_ __ __ _
# | _| | '_ \/ __| | | | '__/ _ \ | |\/| | / __/ __| | '_ \ / _` |
# | |___| | | \__ \ |_| | | | __/ | | | | \__ \__ \ | | | | (_| |
# |_____|_| |_|___/\__,_|_| \___| |_| |_|_|___/___/_|_| |_|\__, |
# |___/
- name: Check site-packages in all plugin folders
if: success() || failure()
run: |
success=0
for plugin_dir in source/*; do
if [ -d "${plugin_dir}" ]; then
# Ensure this directory contains a site-packages file
if [ -e "${plugin_dir}/site-packages" ]; then
echo "FAIL - Directory 'site-packages' found in plugin '${plugin_dir}'"
success=1
else
echo "PASS - No 'site-packages' directory found in plugin '${plugin_dir}'"
fi
fi
done
if [ ${success} -gt 0 ]; then
exit 1
fi
- name: Check settings.json in all plugin folders
if: success() || failure()
run: |
success=0
for plugin_dir in source/*; do
if [ -d "${plugin_dir}" ]; then
# Ensure this directory contains a settings.json file
if [ -e "${plugin_dir}/settings.json" ]; then
echo "FAIL - Directory 'settings.json' found in plugin '${plugin_dir}'"
success=1
else
echo "PASS - No 'settings.json' directory found in plugin '${plugin_dir}'"
fi
fi
done
if [ ${success} -gt 0 ]; then
exit 1
fi
# Store success message in success file artifact
- name: Set success file on completion of tests
if: success()
run: echo 'true' > success_file.txt
- name: Upload success file
if: success()
uses: actions/upload-artifact@v1
with:
name: success_file
path: success_file.txt

# Build the plugin repository
deploy-plugin-repo:
needs: [plugins-contain-require-files]
runs-on: ubuntu-latest
name: Build the plugin repository
steps:

# Fetch and read sucess file
- name: Download success file from previous job
uses: actions/download-artifact@v2
with:
path: ./artifacts/
- name: Read success file
id: previous_jobs_success
run: |
IS_SUCCESS=$(cat ./artifacts/success_file/success_file.txt)
echo ::set-output name=IS_SUCCESS::${IS_SUCCESS}
rm -rfv ./artifacts
# Checkout
- name: Checkout
if: steps.previous_jobs_success.outputs.IS_SUCCESS == 'true'
uses: actions/checkout@v2

# Ensure repo is checked out
- name: Check repo for config file
if: success()
id: ensure_repo
run: |
if [ ! -e ./config.json ]; then
echo "Unable to build repo. Was not checked out."
exit 1
fi
# Import scripts from template branch
- name: Pull in scripts from template branch
if: success()
id: read_template_tree
run: |
git fetch origin template
git read-tree --prefix=template -u origin/template
cp -rf ./template/scripts ./
git rm -r --cached template
if [ ! -e ./scripts/generate_repository.py ]; then
echo "Unable to build repo. Could not find generator script."
exit 1
fi
# Setup python environment
- name: Set up Python 3.8
if: success()
uses: actions/setup-python@v2
with:
python-version: 3.8

# Generate repo
- name: Generate repository from source
if: success()
id: generate_repo
run: |
python ./scripts/generate_repository.py
# Deploy to repo branch
- name: Deploy repository
if: success() && (github.ref == 'refs/heads/master')
uses: s0/git-publish-subdir-action@develop
env:
REPO: self
BRANCH: repo
FOLDER: repo
SQUASH_HISTORY: true
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
60 changes: 60 additions & 0 deletions docs/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
education, socio-economic status, nationality, personal appearance, race,
religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org
Loading

0 comments on commit 2aa0b15

Please sign in to comment.