Workflow Changes
This commit is contained in:
parent
21e6c6f29d
commit
bbee45e605
51
.github/workflows/script-test.yaml
vendored
51
.github/workflows/script-test.yaml
vendored
@ -12,18 +12,18 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
run-install-script:
|
run-install-script:
|
||||||
runs-on: pvenode
|
runs-on: pvenode
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout PR branch
|
- name: Checkout PR branch
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.head.ref }}
|
ref: ${{ github.event.pull_request.head.ref }}
|
||||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Add Git safe directory
|
- name: Add Git safe directory
|
||||||
run: |
|
run: |
|
||||||
git config --global --add safe.directory /__w/ProxmoxVE/ProxmoxVE
|
git config --global --add safe.directory /__w/ProxmoxVE/ProxmoxVE
|
||||||
|
|
||||||
- name: Set up GH_TOKEN
|
- name: Set up GH_TOKEN
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@ -38,15 +38,15 @@ jobs:
|
|||||||
echo "SCRIPT=$CHANGED_FILES" >> $GITHUB_ENV
|
echo "SCRIPT=$CHANGED_FILES" >> $GITHUB_ENV
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
|
||||||
- name: Get scripts
|
- name: Get scripts
|
||||||
id: check-install-script
|
id: check-install-script
|
||||||
run: |
|
run: |
|
||||||
ALL_FILES=()
|
ALL_FILES=()
|
||||||
ADDED_FILES=()
|
ADDED_FILES=()
|
||||||
for FILE in ${{ env.SCRIPT }}; do
|
for FILE in ${{ env.SCRIPT }}; do
|
||||||
if [[ $FILE =~ ^install/.*-install\.sh$ ]] || [[ $FILE =~ ^ct/.*\.sh$ ]]; then
|
if [[ $FILE =~ ^install/.*-install\.sh$ ]] || [[ $FILE =~ ^ct/.*\.sh$ ]]; then
|
||||||
STRIPPED_NAME=$(basename "$FILE" | sed 's/-install//' | sed 's/\.sh$//')
|
STRIPPED_NAME=$(basename "$FILE" | sed 's/-install//' | sed 's/\.sh$//')
|
||||||
if [[ ! " ${ADDED_FILES[@]} " =~ " $STRIPPED_NAME " ]]; then
|
if [[ ! " ${ADDED_FILES[@]} " =~ " $STRIPPED_NAME " ]]; then
|
||||||
ALL_FILES+=("$FILE")
|
ALL_FILES+=("$FILE")
|
||||||
@ -57,14 +57,14 @@ jobs:
|
|||||||
ALL_FILES=$(echo "${ALL_FILES[@]}" | xargs)
|
ALL_FILES=$(echo "${ALL_FILES[@]}" | xargs)
|
||||||
echo "$ALL_FILES"
|
echo "$ALL_FILES"
|
||||||
echo "ALL_FILES=$ALL_FILES" >> $GITHUB_ENV
|
echo "ALL_FILES=$ALL_FILES" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Run scripts
|
- name: Run scripts
|
||||||
id: run-install
|
id: run-install
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
set +e
|
set +e
|
||||||
#run for each files in /ct
|
#run for each files in /ct
|
||||||
for FILE in ${{ env.ALL_FILES }}; do
|
for FILE in ${{ env.ALL_FILES }}; do
|
||||||
STRIPPED_NAME=$(basename "$FILE" | sed 's/-install//' | sed 's/\.sh$//')
|
STRIPPED_NAME=$(basename "$FILE" | sed 's/-install//' | sed 's/\.sh$//')
|
||||||
echo "Running Test for: $STRIPPED_NAME"
|
echo "Running Test for: $STRIPPED_NAME"
|
||||||
if grep -E -q 'read\s+-r\s+-p\s+".*"\s+\w+' "$FILE"; then
|
if grep -E -q 'read\s+-r\s+-p\s+".*"\s+\w+' "$FILE"; then
|
||||||
@ -93,7 +93,7 @@ jobs:
|
|||||||
ERROR_MSG="No install script found for $FILE"
|
ERROR_MSG="No install script found for $FILE"
|
||||||
echo "$ERROR_MSG" > result_$STRIPPED_NAME.log
|
echo "$ERROR_MSG" > result_$STRIPPED_NAME.log
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
echo "Found install script for $STRIPPED_NAME"
|
echo "Found install script for $STRIPPED_NAME"
|
||||||
chmod +x "$INSTALL_SCRIPT"
|
chmod +x "$INSTALL_SCRIPT"
|
||||||
RUNNING_FILE=$FILE
|
RUNNING_FILE=$FILE
|
||||||
@ -112,13 +112,14 @@ jobs:
|
|||||||
git checkout community-scripts/main -- .github/workflows/scripts/app-test/pr-install.func
|
git checkout community-scripts/main -- .github/workflows/scripts/app-test/pr-install.func
|
||||||
git checkout community-scripts/main -- .github/workflows/scripts/app-test/pr-alpine-install.func
|
git checkout community-scripts/main -- .github/workflows/scripts/app-test/pr-alpine-install.func
|
||||||
git checkout community-scripts/main -- .github/workflows/scripts/app-test/pr-create-lxc.sh
|
git checkout community-scripts/main -- .github/workflows/scripts/app-test/pr-create-lxc.sh
|
||||||
chmod +x $RUNNING_FILE
|
chmod +x $RUNNING_FILE
|
||||||
chmod +x .github/workflows/scripts/app-test/pr-create-lxc.sh
|
chmod +x .github/workflows/scripts/app-test/pr-create-lxc.sh
|
||||||
chmod +x .github/workflows/scripts/app-test/pr-install.func
|
chmod +x .github/workflows/scripts/app-test/pr-install.func
|
||||||
chmod +x .github/workflows/scripts/app-test/pr-alpine-install.func
|
chmod +x .github/workflows/scripts/app-test/pr-alpine-install.func
|
||||||
chmod +x .github/workflows/scripts/app-test/pr-build.func
|
chmod +x .github/workflows/scripts/app-test/pr-build.func
|
||||||
sed -i 's|source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)|source .github/workflows/scripts/app-test/pr-build.func|g' "$RUNNING_FILE"
|
sed -i 's|source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)|source .github/workflows/scripts/app-test/pr-build.func|g' "$RUNNING_FILE"
|
||||||
echo "Executing $RUNNING_FILE"
|
echo "Executing $RUNNING_FILE"
|
||||||
|
export TERM=xterm
|
||||||
ERROR_MSG=$(./$RUNNING_FILE 2>&1 > /dev/null)
|
ERROR_MSG=$(./$RUNNING_FILE 2>&1 > /dev/null)
|
||||||
echo "Finished running $FILE"
|
echo "Finished running $FILE"
|
||||||
if [ -n "$ERROR_MSG" ]; then
|
if [ -n "$ERROR_MSG" ]; then
|
||||||
@ -127,38 +128,38 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
set -e # Restore exit-on-error
|
set -e # Restore exit-on-error
|
||||||
|
|
||||||
- name: Cleanup PVE Node
|
- name: Cleanup PVE Node
|
||||||
run: |
|
run: |
|
||||||
containers=$(pct list | tail -n +2 | awk '{print $0 " " $4}' | awk '{print $1}')
|
containers=$(pct list | tail -n +2 | awk '{print $0 " " $4}' | awk '{print $1}')
|
||||||
|
|
||||||
for container_id in $containers; do
|
for container_id in $containers; do
|
||||||
status=$(pct status $container_id | awk '{print $2}')
|
status=$(pct status $container_id | awk '{print $2}')
|
||||||
if [[ $status == "running" ]]; then
|
if [[ $status == "running" ]]; then
|
||||||
pct stop $container_id
|
pct stop $container_id
|
||||||
pct destroy $container_id
|
pct destroy $container_id
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: Post error comments
|
- name: Post error comments
|
||||||
run: |
|
run: |
|
||||||
ERROR="false"
|
ERROR="false"
|
||||||
SEARCH_LINE=".github/workflows/scripts/app-test/pr-build.func: line 255:"
|
SEARCH_LINE=".github/workflows/scripts/app-test/pr-build.func: line 255:"
|
||||||
|
|
||||||
# Get all existing comments on the PR
|
# Get all existing comments on the PR
|
||||||
EXISTING_COMMENTS=$(gh pr view ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --json comments --jq '.comments[].body')
|
#EXISTING_COMMENTS=$(gh pr view ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --json comments --jq '.comments[].body')
|
||||||
|
EXISTING_COMMENTS="NONE"
|
||||||
for FILE in ${{ env.ALL_FILES }}; do
|
for FILE in ${{ env.ALL_FILES }}; do
|
||||||
STRIPPED_NAME=$(basename "$FILE" | sed 's/-install//' | sed 's/\.sh$//')
|
STRIPPED_NAME=$(basename "$FILE" | sed 's/-install//' | sed 's/\.sh$//')
|
||||||
if [[ ! -f result_$STRIPPED_NAME.log ]]; then
|
if [[ ! -f result_$STRIPPED_NAME.log ]]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
ERROR_MSG=$(cat result_$STRIPPED_NAME.log)
|
ERROR_MSG=$(cat result_$STRIPPED_NAME.log)
|
||||||
|
|
||||||
if [ -n "$ERROR_MSG" ]; then
|
if [ -n "$ERROR_MSG" ]; then
|
||||||
CLEANED_ERROR_MSG=$(echo "$ERROR_MSG" | sed "s|$SEARCH_LINE.*||")
|
CLEANED_ERROR_MSG=$(echo "$ERROR_MSG" | sed "s|$SEARCH_LINE.*||")
|
||||||
COMMENT_BODY=":warning: The script _**$FILE**_ failed with the following message: <br> <div><strong>${CLEANED_ERROR_MSG}</strong></div>"
|
COMMENT_BODY=":warning: The script _**$FILE**_ failed with the following message: <br> <div><strong>${CLEANED_ERROR_MSG}</strong></div>"
|
||||||
|
|
||||||
# Check if the comment already exists
|
# Check if the comment already exists
|
||||||
if echo "$EXISTING_COMMENTS" | grep -qF "$COMMENT_BODY"; then
|
if echo "$EXISTING_COMMENTS" | grep -qF "$COMMENT_BODY"; then
|
||||||
echo "Skipping duplicate comment for $FILE"
|
echo "Skipping duplicate comment for $FILE"
|
||||||
@ -171,7 +172,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "ERROR=$ERROR" >> $GITHUB_ENV
|
echo "ERROR=$ERROR" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
|
||||||
|
@ -147,9 +147,9 @@ build_container() {
|
|||||||
TEMP_DIR=$(mktemp -d)
|
TEMP_DIR=$(mktemp -d)
|
||||||
pushd $TEMP_DIR >/dev/null
|
pushd $TEMP_DIR >/dev/null
|
||||||
if [ "$var_os" == "alpine" ]; then
|
if [ "$var_os" == "alpine" ]; then
|
||||||
export FUNCTIONS_FILE_PATH="$(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/.github/workflows/scripts/app-test/pr-alpine-install.func)"
|
export FUNCTIONS_FILE_PATH="$(wget -qLO https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/.github/workflows/scripts/app-test/pr-alpine-install.func)"
|
||||||
else
|
else
|
||||||
export FUNCTIONS_FILE_PATH="$(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/.github/workflows/scripts/app-test/pr-install.func)"
|
export FUNCTIONS_FILE_PATH="$(wget -qLO https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/.github/workflows/scripts/app-test/pr-install.func)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export CACHER="$APT_CACHER"
|
export CACHER="$APT_CACHER"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user