From a95fc2d07d4b641cffa9c09dd40e388ba330d693 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Mon, 4 Nov 2024 15:57:46 +0100 Subject: [PATCH 1/3] Update pull_request_template.md Signed-off-by: CanbiZ <47820557+MickLesk@users.noreply.github.com> --- .github/pull_request_template.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index e8491e01..c8169f25 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -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. From fab6cfc6cd1e64703be8e38e0e3b94fbca28c3f8 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Mon, 4 Nov 2024 16:07:38 +0100 Subject: [PATCH 2/3] Create pr-review.yml Signed-off-by: CanbiZ <47820557+MickLesk@users.noreply.github.com> --- .github/pr-review.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/pr-review.yml diff --git a/.github/pr-review.yml b/.github/pr-review.yml new file mode 100644 index 00000000..44c3cea5 --- /dev/null +++ b/.github/pr-review.yml @@ -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." From 0f2a1fdb45b7934bf4faadec24268b281224f06c Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Mon, 4 Nov 2024 16:14:49 +0100 Subject: [PATCH 3/3] Create check-script.yml Signed-off-by: CanbiZ <47820557+MickLesk@users.noreply.github.com> --- .github/check-script.yml | 54 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/check-script.yml diff --git a/.github/check-script.yml b/.github/check-script.yml new file mode 100644 index 00000000..560bc396 --- /dev/null +++ b/.github/check-script.yml @@ -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