This commit is contained in:
CanbiZ 2024-11-04 17:02:29 +01:00
commit 90c5f1c2eb
3 changed files with 98 additions and 2 deletions

54
.github/check-script.yml vendored Normal file
View File

@ -0,0 +1,54 @@
name: Check Shell Scripts
on:
pull_request:
paths:
- '**/*.sh' # Führt den Check nur für Shell-Skripte aus
jobs:
check-scripts:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Check `source` Line in Scripts
shell: bash
run: |
set -e
ERROR_COUNT=0
FILES=$(find . -name "*.sh")
for FILE in $FILES; do
# Check for exact match of the source line in line 2
if [[ $(sed -n '2p' "$FILE") =~ ^source[[:space:]]+<(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) ]]; then
echo "Check passed for: $FILE"
else
echo "Error in $FILE: Line 2 must be exactly 'source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)' if a source line is used."
ERROR_COUNT=$((ERROR_COUNT + 1))
fi
# Check for shebang line at the top
if [[ $(head -n 1 "$FILE") != "#!/usr/bin/env bash" ]]; then
echo "Error in $FILE: The first line must be '#!/usr/bin/env bash'."
ERROR_COUNT=$((ERROR_COUNT + 1))
fi
# Check for executable permissions
if [[ ! -x "$FILE" ]]; then
echo "Warning in $FILE: This script is not executable. Consider running 'chmod +x $FILE'."
fi
# Check for empty lines at the beginning of the script
if [[ $(head -n 10 "$FILE" | grep -c '^$') -gt 0 ]]; then
echo "Warning in $FILE: There are empty lines at the beginning of the script. Consider removing them."
fi
done
if [[ "$ERROR_COUNT" -gt 0 ]]; then
echo "$ERROR_COUNT script(s) failed validation."
exit 1
else
echo "All scripts passed."
fi

28
.github/pr-review.yml vendored Normal file
View File

@ -0,0 +1,28 @@
name: Pull Request Review Enforcement
on:
pull_request:
types: [opened, reopened, synchronize]
jobs:
enforce-review-requirements:
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v2
- name: Verify Reviewer Approvals
id: review-check
run: |
reviews=$(gh api repos/$GITHUB_REPOSITORY/pulls/$GITHUB_EVENT_NUMBER/reviews --jq '[.[] | select(.state == "APPROVED") | .user.login] | unique | length')
if [ "$reviews" -lt 2 ]; then
echo "PR requires at least 2 approvals from the Contributor team."
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Confirm Ready to Merge
if: ${{ steps.review-check.outputs.reviews == '2' }}
run: echo "PR is ready to be merged."

View File

@ -1,5 +1,5 @@
> [!NOTE]
We are meticulous when it comes to merging code into the main branch, so please understand that we may reject pull requests that do not meet the project's standards. It's never personal. Also, game-related scripts have a lower chance of being merged.
> We are meticulous when it comes to merging code into the main branch, so please understand that we may reject pull requests that do not meet the project's standards. It's never personal. Also, game-related scripts have a lower chance of being merged.
## Description
@ -8,7 +8,6 @@ Provide a summary of the changes made and/or reference the issue being addressed
Fixes # (issue)
## Type of change
Please check the relevant option(s):
- [ ] Bug fix (non-breaking change that resolves an issue)
@ -18,3 +17,18 @@ Please check the relevant option(s):
- [ ] Self-review performed (I have reviewed my code, ensuring it follows established patterns and conventions)
- [ ] Documentation update required (this change requires an update to the documentation)
## Additional Information (optional)
Provide any additional context or screenshots about the feature or fix here.
## Related Pull Requests / Discussions
If there are other pull requests or discussions related to this change, please link them here:
- Related PR #1
- Related PR #2
## Review Guidelines
- [ ] This PR requires review and approval by at least **two contributors**.
- [ ] If changes affect critical functionality, please notify the project maintainers.
- [ ] For major updates, ensure all conversations on this PR are resolved before merging.