mirror of
https://github.com/community-scripts/ProxmoxVE
synced 2025-02-09 17:29:16 +00:00
Compare commits
7 Commits
84d36eba84
...
32a99a44d4
Author | SHA1 | Date | |
---|---|---|---|
|
32a99a44d4 | ||
|
e94280f1a1 | ||
|
b9ca4b7634 | ||
|
8431931cc4 | ||
|
8bf7f7a460 | ||
|
6adf8e38b0 | ||
|
817455360e |
54
.github/check-script.yml
vendored
54
.github/check-script.yml
vendored
@ -1,54 +0,0 @@
|
||||
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
|
10
.github/workflows/changelog-pr.yml
vendored
10
.github/workflows/changelog-pr.yml
vendored
@ -157,3 +157,13 @@ jobs:
|
||||
if [ -n "$PR_NUMBER" ]; then
|
||||
gh pr review $PR_NUMBER --approve
|
||||
fi
|
||||
|
||||
- name: Re-approve pull request after update
|
||||
if: steps.verify-diff.outputs.changed == 'true'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
PR_NUMBER=$(gh pr list --head "${BRANCH_NAME}" --json number --jq '.[].number')
|
||||
if [ -n "$PR_NUMBER" ]; then
|
||||
gh pr review $PR_NUMBER --approve
|
||||
fi
|
||||
|
92
.github/workflows/check-lowercase.yml
vendored
92
.github/workflows/check-lowercase.yml
vendored
@ -1,92 +0,0 @@
|
||||
name: Check Lowercase Filenames
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- 'ct/*.sh'
|
||||
- 'install/*.sh'
|
||||
- 'json/*.json'
|
||||
|
||||
jobs:
|
||||
check_lowercase:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# Step 1: Checkout the code
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # Ensure the full history is fetched for accurate diffing
|
||||
|
||||
# Step 2: Fetch the base branch
|
||||
- name: Fetch base branch
|
||||
run: git fetch origin ${{ github.base_ref }}
|
||||
|
||||
# Step 3a: Validate filenames in ct directory
|
||||
- name: "Validate filenames in ct directory"
|
||||
run: |
|
||||
changed_files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -E '^ct/.*\.sh$')
|
||||
|
||||
ERROR_COUNT=0
|
||||
|
||||
for FILE in $changed_files; do
|
||||
BASENAME=$(basename "$FILE")
|
||||
if [[ "$BASENAME" =~ ^[a-z0-9._-]+$ ]]; then
|
||||
echo "$FILE: Check for lowercase in filename passed."
|
||||
else
|
||||
echo "Error in $FILE. Change filename to lowercase."
|
||||
ERROR_COUNT=$((ERROR_COUNT + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$ERROR_COUNT" -ne 0 ]; then
|
||||
exit 1
|
||||
else
|
||||
echo "All filenames in ct directory passed the lowercase check."
|
||||
fi
|
||||
|
||||
# Step 3b: Validate filenames in install directory
|
||||
- name: "Validate filenames in install directory"
|
||||
run: |
|
||||
changed_files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -E '^install/.*\.sh$')
|
||||
|
||||
ERROR_COUNT=0
|
||||
|
||||
for FILE in $changed_files; do
|
||||
BASENAME=$(basename "$FILE")
|
||||
if [[ "$BASENAME" =~ ^[a-z0-9._-]+$ ]]; then
|
||||
echo "$FILE: Check for lowercase in filename passed."
|
||||
else
|
||||
echo "Error in $FILE. Change filename to lowercase."
|
||||
ERROR_COUNT=$((ERROR_COUNT + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$ERROR_COUNT" -ne 0 ]; then
|
||||
exit 1
|
||||
else
|
||||
echo "All filenames in install directory passed the lowercase check."
|
||||
fi
|
||||
|
||||
# Step 3c: Validate filenames in json directory
|
||||
- name: "Validate filenames in json directory."
|
||||
run: |
|
||||
changed_files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -E '^json/.*\.json$')
|
||||
|
||||
ERROR_COUNT=0
|
||||
|
||||
for FILE in $changed_files; do
|
||||
BASENAME=$(basename "$FILE")
|
||||
if [[ "$BASENAME" =~ ^[a-z0-9._-]+$ ]]; then
|
||||
echo "$FILE: Check for lowercase in filename passed."
|
||||
else
|
||||
echo "Error in $FILE. Change filename to lowercase."
|
||||
ERROR_COUNT=$((ERROR_COUNT + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$ERROR_COUNT" -ne 0 ]; then
|
||||
exit 1
|
||||
else
|
||||
echo "All filenames in json directory passed the lowercase check."
|
||||
fi
|
55
.github/workflows/check-metadata.yml
vendored
55
.github/workflows/check-metadata.yml
vendored
@ -1,55 +0,0 @@
|
||||
name: Check Metadata
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- '/ct/*.sh'
|
||||
- '/install/*.sh'
|
||||
jobs:
|
||||
check-metadata:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
- name: Check Metadata Lines in Scripts
|
||||
shell: bash
|
||||
run: |
|
||||
set -e
|
||||
ERROR_COUNT=0
|
||||
FILES=$(find . -name "*.sh")
|
||||
|
||||
for FILE in $FILES; do
|
||||
if [[ "$(sed -n '3p' "$FILE")" == "# Copyright (c) 2021-2024 community-scripts ORG" ]]; then
|
||||
echo "Check for Copyright metadata passed for line 3 in: $FILE"
|
||||
else
|
||||
echo "Error in $FILE: Copyright metadata missing or not on line 3"
|
||||
ERROR_COUNT=$((ERROR_COUNT + 1))
|
||||
fi
|
||||
|
||||
if sed -n '4p' "$FILE" | grep -qE "^# Author: .+"; then
|
||||
echo "Check for Author metadata passed for line 4 in: $FILE"
|
||||
else
|
||||
echo "Error in $FILE: Author metadata missing or invalid on line 4"
|
||||
ERROR_COUNT=$((ERROR_COUNT + 1))
|
||||
fi
|
||||
|
||||
if [[ "$(sed -n '5p' "$FILE")" == "# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE" ]]; then
|
||||
echo "Check for License metadata passed for line 5 in: $FILE"
|
||||
else
|
||||
echo "Error in $FILE: License metadata missing or not on line 5"
|
||||
ERROR_COUNT=$((ERROR_COUNT + 1))
|
||||
fi
|
||||
|
||||
if sed -n '6p' "$FILE" | grep -qE "^# Source: .+"; then
|
||||
echo "Check for Source metadata passed for line 6 in: $FILE"
|
||||
else
|
||||
echo "Error in $FILE: Source metadata missing or invalid on line 6"
|
||||
ERROR_COUNT=$((ERROR_COUNT + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ "$ERROR_COUNT" -gt 0 ]]; then
|
||||
echo "$ERROR_COUNT script(s) failed validation."
|
||||
exit 1
|
||||
else
|
||||
echo "All scripts passed."
|
||||
fi
|
143
.github/workflows/validate-filenames.yml
vendored
Normal file
143
.github/workflows/validate-filenames.yml
vendored
Normal file
@ -0,0 +1,143 @@
|
||||
name: Validate filenames
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- "ct/*.sh"
|
||||
- "install/*.sh"
|
||||
- "json/*.json"
|
||||
- ".github/workflows/validate-filenames.yml"
|
||||
|
||||
jobs:
|
||||
check-files:
|
||||
name: Check changed files
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # Ensure the full history is fetched for accurate diffing
|
||||
|
||||
- name: Get changed files
|
||||
id: changed-files
|
||||
run: |
|
||||
if ${{ github.event_name == 'pull_request' }}; then
|
||||
echo "files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | xargs)" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: "Validate filenames in ct and install directory"
|
||||
if: always() && steps.changed-files.outputs.files != ''
|
||||
id: check-scripts
|
||||
run: |
|
||||
CHANGED_FILES=$(printf "%s\n" ${{ steps.changed-files.outputs.files }} | { grep -E '^(ct|install)/.*\.sh$' || true; })
|
||||
|
||||
NON_COMPLIANT_FILES=""
|
||||
for FILE in $CHANGED_FILES; do
|
||||
BASENAME=$(echo "$(basename "${FILE%.*}")")
|
||||
if [[ ! "$BASENAME" =~ ^[a-z0-9-]+$ ]]; then
|
||||
NON_COMPLIANT_FILES="$NON_COMPLIANT_FILES $FILE"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$NON_COMPLIANT_FILES" ]; then
|
||||
echo "files=$NON_COMPLIANT_FILES" >> $GITHUB_OUTPUT
|
||||
echo "Non-compliant filenames found, change to lowercase:"
|
||||
for FILE in $NON_COMPLIANT_FILES; do
|
||||
echo "$FILE"
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: "Validate filenames in json directory."
|
||||
if: always() && steps.changed-files.outputs.files != ''
|
||||
id: check-json
|
||||
run: |
|
||||
CHANGED_FILES=$(printf "%s\n" ${{ steps.changed-files.outputs.files }} | { grep -E '^json/.*\.json$' || true; })
|
||||
|
||||
NON_COMPLIANT_FILES=""
|
||||
for FILE in $CHANGED_FILES; do
|
||||
BASENAME=$(echo "$(basename "${FILE%.*}")")
|
||||
if [[ ! "$BASENAME" =~ ^[a-z0-9-]+$ ]]; then
|
||||
NON_COMPLIANT_FILES="$NON_COMPLIANT_FILES $FILE"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$NON_COMPLIANT_FILES" ]; then
|
||||
echo "files=$NON_COMPLIANT_FILES" >> $GITHUB_OUTPUT
|
||||
echo "Non-compliant filenames found, change to lowercase:"
|
||||
for FILE in $NON_COMPLIANT_FILES; do
|
||||
echo "$FILE"
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Post results and comment
|
||||
if: always() && steps.check-scripts.outputs.files != '' && steps.check-json.outputs.files != '' && github.event_name == 'pull_request'
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const result = "${{ job.status }}" === "success" ? "success" : "failure";
|
||||
const nonCompliantFiles = {
|
||||
script: "${{ steps.check-scripts.outputs.files }}",
|
||||
JSON: "${{ steps.check-json.outputs.files }}",
|
||||
};
|
||||
|
||||
const issueNumber = context.payload.pull_request
|
||||
? context.payload.pull_request.number
|
||||
: null;
|
||||
const commentIdentifier = "validate-filenames";
|
||||
let newCommentBody = `<!-- ${commentIdentifier}-start -->\n### Filename validation\n\n`;
|
||||
|
||||
if (result === "failure") {
|
||||
newCommentBody += ":x: We found issues in the following changed files:\n\n";
|
||||
for (const [check, files] of Object.entries(nonCompliantFiles)) {
|
||||
if (files) {
|
||||
newCommentBody += `**${check.charAt(0).toUpperCase() + check.slice(1)} filename invalid:**\n${files
|
||||
.trim()
|
||||
.split(" ")
|
||||
.map((file) => `- ${file}`)
|
||||
.join("\n")}\n\n`;
|
||||
}
|
||||
}
|
||||
newCommentBody +=
|
||||
"Please change the filenames to lowercase and use only alphanumeric characters and dashes.\n";
|
||||
} else {
|
||||
newCommentBody += `:rocket: All files passed filename validation!\n`;
|
||||
}
|
||||
|
||||
newCommentBody += `\n\n<!-- ${commentIdentifier}-end -->`;
|
||||
|
||||
if (issueNumber) {
|
||||
const { data: comments } = await github.rest.issues.listComments({
|
||||
...context.repo,
|
||||
issue_number: issueNumber,
|
||||
});
|
||||
|
||||
const existingComment = comments.find(
|
||||
(comment) => comment.user.login === "github-actions[bot]",
|
||||
);
|
||||
|
||||
if (existingComment) {
|
||||
if (existingComment.body.includes(commentIdentifier)) {
|
||||
const re = new RegExp(String.raw`<!-- ${commentIdentifier}-start -->[\s\S]*?<!-- ${commentIdentifier}-end -->`, "");
|
||||
newCommentBody = existingComment.body.replace(re, newCommentBody);
|
||||
} else {
|
||||
newCommentBody = existingComment.body + '\n\n---\n\n' + newCommentBody;
|
||||
}
|
||||
|
||||
await github.rest.issues.updateComment({
|
||||
...context.repo,
|
||||
comment_id: existingComment.id,
|
||||
body: newCommentBody,
|
||||
});
|
||||
} else {
|
||||
await github.rest.issues.createComment({
|
||||
...context.repo,
|
||||
issue_number: issueNumber,
|
||||
body: newCommentBody,
|
||||
});
|
||||
}
|
||||
}
|
118
.github/workflows/validate-formatting.yaml
vendored
Normal file
118
.github/workflows/validate-formatting.yaml
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
name: Validate script formatting
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
paths:
|
||||
- "**/*.sh"
|
||||
- "**/*.func"
|
||||
- ".github/workflows/validate-formatting.yaml"
|
||||
|
||||
jobs:
|
||||
shfmt:
|
||||
name: Check changed files
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Get changed files
|
||||
id: changed-files
|
||||
run: |
|
||||
if ${{ github.event_name == 'pull_request' }}; then
|
||||
echo "files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -E '\.(sh|func)$' | xargs)" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -E '\.(sh|func)$' | xargs)" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Set up Go
|
||||
if: steps.changed-files.outputs.files != ''
|
||||
uses: actions/setup-go@v5
|
||||
|
||||
- name: Install shfmt
|
||||
if: steps.changed-files.outputs.files != ''
|
||||
run: |
|
||||
go install mvdan.cc/sh/v3/cmd/shfmt@latest
|
||||
echo "$GOPATH/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Run shfmt
|
||||
if: steps.changed-files.outputs.files != ''
|
||||
id: shfmt
|
||||
run: |
|
||||
set +e
|
||||
|
||||
shfmt_output=$(shfmt -d ${{ steps.changed-files.outputs.files }})
|
||||
if [[ $? -eq 0 ]]; then
|
||||
exit 0
|
||||
else
|
||||
echo "diff=\"$(echo -n "$shfmt_output" | base64 -w 0)\"" >> $GITHUB_OUTPUT
|
||||
printf "%s" "$shfmt_output"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Post comment with results
|
||||
if: always() && steps.changed-files.outputs.files != '' && github.event_name == 'pull_request'
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const result = "${{ job.status }}" === "success" ? "success" : "failure";
|
||||
const diff = Buffer.from(
|
||||
"${{ steps.shfmt.outputs.diff }}",
|
||||
"base64",
|
||||
).toString();
|
||||
const issueNumber = context.payload.pull_request
|
||||
? context.payload.pull_request.number
|
||||
: null;
|
||||
const commentIdentifier = "validate-formatting";
|
||||
let newCommentBody = `<!-- ${commentIdentifier}-start -->\n### Script formatting\n\n`;
|
||||
|
||||
if (result === "failure") {
|
||||
newCommentBody +=
|
||||
":x: We found issues in the formatting of the following changed files:\n\n\`\`\`diff\n${diff}\n\`\`\`\n";
|
||||
} else {
|
||||
newCommentBody += `:rocket: All changed shell scripts are formatted correctly!\n`;
|
||||
}
|
||||
|
||||
newCommentBody += `\n\n<!-- ${commentIdentifier}-end -->`;
|
||||
|
||||
if (issueNumber) {
|
||||
const { data: comments } = await github.rest.issues.listComments({
|
||||
...context.repo,
|
||||
issue_number: issueNumber,
|
||||
});
|
||||
|
||||
const existingComment = comments.find(
|
||||
(comment) => comment.user.login === "github-actions[bot]",
|
||||
);
|
||||
|
||||
if (existingComment) {
|
||||
if (existingComment.body.includes(commentIdentifier)) {
|
||||
const re = new RegExp(
|
||||
String.raw`<!-- ${commentIdentifier}-start -->[\s\S]*?<!-- ${commentIdentifier}-end -->`,
|
||||
"",
|
||||
);
|
||||
newCommentBody = existingComment.body.replace(re, newCommentBody);
|
||||
} else {
|
||||
newCommentBody = existingComment.body + "\n\n---\n\n" + newCommentBody;
|
||||
}
|
||||
|
||||
await github.rest.issues.updateComment({
|
||||
...context.repo,
|
||||
comment_id: existingComment.id,
|
||||
body: newCommentBody,
|
||||
});
|
||||
} else {
|
||||
await github.rest.issues.createComment({
|
||||
...context.repo,
|
||||
issue_number: issueNumber,
|
||||
body: newCommentBody,
|
||||
});
|
||||
}
|
||||
}
|
214
.github/workflows/validate-scripts.yml
vendored
Normal file
214
.github/workflows/validate-scripts.yml
vendored
Normal file
@ -0,0 +1,214 @@
|
||||
name: Validate scripts
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
paths:
|
||||
- "ct/*.sh"
|
||||
- "install/*.sh"
|
||||
- ".github/workflows/validate-scripts.yml"
|
||||
|
||||
jobs:
|
||||
check-scripts:
|
||||
name: Check changed files
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
|
||||
|
||||
- name: Get changed files
|
||||
id: changed-files
|
||||
run: |
|
||||
if ${{ github.event_name == 'pull_request' }}; then
|
||||
echo "files=$(git diff --name-only -r HEAD^1 HEAD | grep -E '\.(sh|func)$' | xargs)" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -E '\.(sh|func)$' | xargs)" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Check build.func line
|
||||
if: always() && steps.changed-files.outputs.files != ''
|
||||
id: build-func
|
||||
run: |
|
||||
NON_COMPLIANT_FILES=""
|
||||
for FILE in ${{ steps.changed-files.outputs.files }}; do
|
||||
if [[ "$FILE" == ct/* ]] && [[ $(sed -n '2p' "$FILE") != "source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)" ]]; then
|
||||
NON_COMPLIANT_FILES="$NON_COMPLIANT_FILES $FILE"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$NON_COMPLIANT_FILES" ]; then
|
||||
echo "files=$NON_COMPLIANT_FILES" >> $GITHUB_OUTPUT
|
||||
echo "Build.func line missing or incorrect in files:"
|
||||
for FILE in $NON_COMPLIANT_FILES; do
|
||||
echo "$FILE"
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Check executable permissions
|
||||
if: always() && steps.changed-files.outputs.files != ''
|
||||
id: check-executable
|
||||
run: |
|
||||
NON_COMPLIANT_FILES=""
|
||||
for FILE in ${{ steps.changed-files.outputs.files }}; do
|
||||
if [[ ! -x "$FILE" ]]; then
|
||||
NON_COMPLIANT_FILES="$NON_COMPLIANT_FILES $FILE"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$NON_COMPLIANT_FILES" ]; then
|
||||
echo "files=$NON_COMPLIANT_FILES" >> $GITHUB_OUTPUT
|
||||
echo "Files not executable:"
|
||||
for FILE in $NON_COMPLIANT_FILES; do
|
||||
echo "$FILE"
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Check copyright
|
||||
if: always() && steps.changed-files.outputs.files != ''
|
||||
id: check-copyright
|
||||
run: |
|
||||
NON_COMPLIANT_FILES=""
|
||||
for FILE in ${{ steps.changed-files.outputs.files }}; do
|
||||
if ! sed -n '3p' "$FILE" | grep -qE "^# Copyright \(c\) [0-9]{4}(-[0-9]{4})? (tteck \| community-scripts ORG|community-scripts ORG|tteck)$"; then
|
||||
NON_COMPLIANT_FILES="$NON_COMPLIANT_FILES $FILE"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$NON_COMPLIANT_FILES" ]; then
|
||||
echo "files=$NON_COMPLIANT_FILES" >> $GITHUB_OUTPUT
|
||||
echo "Copyright header missing or not on line 3 in files:"
|
||||
for FILE in $NON_COMPLIANT_FILES; do
|
||||
echo "$FILE"
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Check author
|
||||
if: always() && steps.changed-files.outputs.files != ''
|
||||
id: check-author
|
||||
run: |
|
||||
NON_COMPLIANT_FILES=""
|
||||
for FILE in ${{ steps.changed-files.outputs.files }}; do
|
||||
if ! sed -n '4p' "$FILE" | grep -qE "^# Author: .+"; then
|
||||
NON_COMPLIANT_FILES="$NON_COMPLIANT_FILES $FILE"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$NON_COMPLIANT_FILES" ]; then
|
||||
echo "files=$NON_COMPLIANT_FILES" >> $GITHUB_OUTPUT
|
||||
echo "Author header missing or invalid on line 4 in files:"
|
||||
for FILE in $NON_COMPLIANT_FILES; do
|
||||
echo "$FILE"
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Check license
|
||||
if: always() && steps.changed-files.outputs.files != ''
|
||||
id: check-license
|
||||
run: |
|
||||
NON_COMPLIANT_FILES=""
|
||||
for FILE in ${{ steps.changed-files.outputs.files }}; do
|
||||
if [[ "$(sed -n '5p' "$FILE")" != "# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE" ]]; then
|
||||
NON_COMPLIANT_FILES="$NON_COMPLIANT_FILES $FILE"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$NON_COMPLIANT_FILES" ]; then
|
||||
echo "files=$NON_COMPLIANT_FILES" >> $GITHUB_OUTPUT
|
||||
echo "License header missing or not on line 5 in files:"
|
||||
for FILE in $NON_COMPLIANT_FILES; do
|
||||
echo "$FILE"
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Check source
|
||||
if: always() && steps.changed-files.outputs.files != ''
|
||||
id: check-source
|
||||
run: |
|
||||
NON_COMPLIANT_FILES=""
|
||||
for FILE in ${{ steps.changed-files.outputs.files }}; do
|
||||
if ! sed -n '6p' "$FILE" | grep -qE "^# Source: .+"; then
|
||||
NON_COMPLIANT_FILES="$NON_COMPLIANT_FILES $FILE"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$NON_COMPLIANT_FILES" ]; then
|
||||
echo "files=$NON_COMPLIANT_FILES" >> $GITHUB_OUTPUT
|
||||
echo "Source header missing or not on line 6 in files:"
|
||||
for FILE in $NON_COMPLIANT_FILES; do
|
||||
echo "$FILE"
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Post results and comment
|
||||
if: always() && steps.changed-files.outputs.files != '' && github.event_name == 'pull_request'
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const result = '${{ job.status }}' === 'success' ? 'success' : 'failure';
|
||||
const nonCompliantFiles = {
|
||||
'Invalid build.func source': "${{ steps.build-func.outputs.files }}",
|
||||
'Not executable': "${{ steps.check-executable.outputs.files }}",
|
||||
'Copyright header line missing or invalid': "${{ steps.check-copyright.outputs.files }}",
|
||||
'Author header line missing or invalid': "${{ steps.check-author.outputs.files }}",
|
||||
'License header line missing or invalid': "${{ steps.check-license.outputs.files }}",
|
||||
'Source header line missing or invalid': "${{ steps.check-source.outputs.files }}"
|
||||
};
|
||||
|
||||
const issueNumber = context.payload.pull_request ? context.payload.pull_request.number : null;
|
||||
const commentIdentifier = 'validate-scripts';
|
||||
let newCommentBody = `<!-- ${commentIdentifier}-start -->\n### Script validation\n\n`;
|
||||
|
||||
if (result === 'failure') {
|
||||
newCommentBody += ':x: We found issues in the following changed files:\n\n';
|
||||
for (const [check, files] of Object.entries(nonCompliantFiles)) {
|
||||
if (files) {
|
||||
newCommentBody += `**${check}:**\n${files.trim().split(' ').map(file => `- ${file}`).join('\n')}\n\n`;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
newCommentBody += `:rocket: All changed shell scripts passed validation!\n`;
|
||||
}
|
||||
|
||||
newCommentBody += `\n\n<!-- ${commentIdentifier}-end -->`;
|
||||
|
||||
if (issueNumber) {
|
||||
const { data: comments } = await github.rest.issues.listComments({
|
||||
...context.repo,
|
||||
issue_number: issueNumber
|
||||
});
|
||||
|
||||
const existingComment = comments.find(comment => comment.user.login === 'github-actions[bot]');
|
||||
|
||||
if (existingComment) {
|
||||
if (existingComment.body.includes(commentIdentifier)) {
|
||||
const re = new RegExp(String.raw`<!-- ${commentIdentifier}-start -->[\s\S]*?<!-- ${commentIdentifier}-end -->`, "");
|
||||
newCommentBody = existingComment.body.replace(re, newCommentBody);
|
||||
} else {
|
||||
newCommentBody = existingComment.body + '\n\n---\n\n' + newCommentBody;
|
||||
}
|
||||
|
||||
await github.rest.issues.updateComment({
|
||||
...context.repo,
|
||||
comment_id: existingComment.id,
|
||||
body: newCommentBody
|
||||
});
|
||||
} else {
|
||||
await github.rest.issues.createComment({
|
||||
...context.repo,
|
||||
issue_number: issueNumber,
|
||||
body: newCommentBody
|
||||
});
|
||||
}
|
||||
}
|
11
CHANGELOG.md
11
CHANGELOG.md
@ -16,6 +16,17 @@ All LXC instances created using this repository come pre-installed with Midnight
|
||||
> [!IMPORTANT]
|
||||
Do not break established syntax in this file, as it is automatically updated by a Github Workflow
|
||||
|
||||
## 2025-01-06
|
||||
|
||||
### Changed
|
||||
|
||||
### 🧰 Maintenance
|
||||
|
||||
- ci: combine header checks into workflow with PR comment [@se-bastiaan](https://github.com/se-bastiaan) ([#1257](https://github.com/community-scripts/ProxmoxVE/pull/1257))
|
||||
- ci: change filename checks into steps with PR comment [@se-bastiaan](https://github.com/se-bastiaan) ([#1255](https://github.com/community-scripts/ProxmoxVE/pull/1255))
|
||||
- Add reapproval of Changelog-PR [@MickLesk](https://github.com/MickLesk) ([#1279](https://github.com/community-scripts/ProxmoxVE/pull/1279))
|
||||
- ci: add pipeline for code formatting checks [@se-bastiaan](https://github.com/se-bastiaan) ([#1239](https://github.com/community-scripts/ProxmoxVE/pull/1239))
|
||||
|
||||
## 2025-01-05
|
||||
|
||||
### Changed
|
||||
|
@ -56,11 +56,11 @@ $STD composer install --no-dev --optimize-autoloader --no-interaction
|
||||
cp .env.dist .env
|
||||
sed -i "/^DATABASE_URL=/c\DATABASE_URL=mysql://$DB_USER:$DB_PASS@127.0.0.1:3306/$DB_NAME?charset=utf8mb4&serverVersion=$MYSQL_VERSION" /opt/kimai/.env
|
||||
$STD bin/console kimai:install -n
|
||||
chown -R :www-data /opt/kimai
|
||||
chmod -R g+r /opt/kimai
|
||||
chmod -R g+rw /opt/kimai
|
||||
sudo chown -R www-data:www-data /opt/kimai
|
||||
sudo chmod -R 755 /opt/kimai
|
||||
chown -R :www-data /opt/*
|
||||
chmod -R g+r /opt/*
|
||||
chmod -R g+rw /opt/*
|
||||
sudo chown -R www-data:www-data /opt/*
|
||||
sudo chmod -R 755 /opt/*
|
||||
$STD expect <<EOF
|
||||
set timeout -1
|
||||
log_user 0
|
||||
|
Loading…
Reference in New Issue
Block a user