[GH] Remove unwanted output from script test workflow (#2337)

* Remove unwanted output from workflow

* Remove unwanted output from workflow

* update .yml so it supports external repos

* update .yml so it supports external repos
This commit is contained in:
Michel Roegl-Brunner
2025-02-13 13:00:35 +01:00
committed by GitHub
parent b99adb5e1a
commit caa4b7d19e
4 changed files with 63 additions and 60 deletions

View File

@@ -1,21 +1,25 @@
name: Run Scripts on PVE Node
name: Run Scripts on PVE Node for testing
permissions:
pull-requests: write
on:
pull_request:
pull_request_target:
branches:
- main
paths:
- 'install/*.sh'
- 'ct/*.sh'
- 'install/**.sh'
- 'ct/**.sh'
jobs:
run-install-script:
runs-on: pvenode
steps:
- name: Checkout PR branch
- name: Checkout PR branch (supports forks)
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: Add Git safe directory
run: |
git config --global --add safe.directory /__w/ProxmoxVE/ProxmoxVE
@@ -26,13 +30,14 @@ jobs:
run: |
echo "GH_TOKEN=${GH_TOKEN}" >> $GITHUB_ENV
- name: Get changed files in PR
id: changed-files
run: |
CHANGED_FILES=$(gh pr diff --name-only ${{ github.event.pull_request.number }})
CHANGED_FILES=$(echo "$CHANGED_FILES" | tr '\n' ' ')
echo "Changed files: $CHANGED_FILES"
- name: Get Changed Files
run: |
CHANGED_FILES=$(gh pr diff ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --name-only)
CHANGED_FILES=$(echo "$CHANGED_FILES" | tr '\n' ' ')
echo "Changed files: $CHANGED_FILES"
echo "SCRIPT=$CHANGED_FILES" >> $GITHUB_ENV
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get scripts
id: check-install-script
@@ -51,7 +56,7 @@ jobs:
ALL_FILES=$(echo "${ALL_FILES[@]}" | xargs)
echo "$ALL_FILES"
echo "ALL_FILES=$ALL_FILES" >> $GITHUB_ENV
- name: Run scripts
id: run-install
continue-on-error: true
@@ -59,13 +64,15 @@ jobs:
set +e
#run for each files in /ct
for FILE in ${{ env.ALL_FILES }}; do
echo "Running: $FILE"
STRIPPED_NAME=$(basename "$FILE" | sed 's/-install//' | sed 's/\.sh$//')
echo "Running Test for: $STRIPPED_NAME"
if [[ $FILE =~ ^install/.*-install\.sh$ ]]; then
CT_SCRIPT="ct/$STRIPPED_NAME.sh"
if [[ ! -f $CT_SCRIPT ]]; then
echo "No CT script found for $STRIPPED_NAME"
exit 1
ERROR_MSG="No CT script found for $FILE"
echo "$ERROR_MSG" > result_$STRIPPED_NAME.log
continue
fi
echo "Found CT script for $STRIPPED_NAME"
chmod +x "$CT_SCRIPT"
@@ -74,8 +81,10 @@ jobs:
INSTALL_SCRIPT="install/$STRIPPED_NAME-install.sh"
if [[ ! -f $INSTALL_SCRIPT ]]; then
echo "No install script found for $STRIPPED_NAME"
exit 1
fi
ERROR_MSG="No install script found for $FILE"
echo "$ERROR_MSG" > result_$STRIPPED_NAME.log
continue
fi
echo "Found install script for $STRIPPED_NAME"
chmod +x "$INSTALL_SCRIPT"
RUNNING_FILE=$FILE
@@ -84,13 +93,13 @@ jobs:
git checkout origin/main .github/workflows/scripts/app-test/pr-install.func
git checkout origin/main .github/workflows/scripts/app-test/pr-alpine-install.func
git checkout origin/main .github/workflows/scripts/app-test/pr-create-lxc.sh
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"
chmod +x $RUNNING_FILE
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-alpine-install.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"
echo "Executing $RUNNING_FILE"
ERROR_MSG=$(./$RUNNING_FILE 2>&1 > /dev/null)
echo "Finished running $FILE"
if [ -n "$ERROR_MSG" ]; then
@@ -110,8 +119,8 @@ jobs:
pct stop $container_id
pct destroy $container_id
fi
done
done
- name: Post error comments
run: |
ERROR="false"
@@ -128,12 +137,17 @@ jobs:
echo "Posting error message for $FILE"
echo ${CLEANED_ERROR_MSG}
gh pr comment ${{ github.event.pull_request.number }} \
--repo ${{ github.repository }} \
--body ":warning: The script _**$FILE**_ failed with the following message: <br> <div><strong>${CLEANED_ERROR_MSG}</strong></div>"
ERROR="true"
fi
done
echo "ERROR=$ERROR" >> $GITHUB_ENV
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Fail if error
if: ${{ env.ERROR }} == 'true'
if: ${{ env.ERROR == 'true' }}
run: exit 1