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:
|
||||
run-install-script:
|
||||
runs-on: pvenode
|
||||
steps:
|
||||
steps:
|
||||
- name: Checkout PR branch
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.ref }}
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
fetch-depth: 0
|
||||
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Add Git safe directory
|
||||
run: |
|
||||
git config --global --add safe.directory /__w/ProxmoxVE/ProxmoxVE
|
||||
|
||||
|
||||
- name: Set up GH_TOKEN
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@ -38,15 +38,15 @@ jobs:
|
||||
echo "SCRIPT=$CHANGED_FILES" >> $GITHUB_ENV
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
|
||||
|
||||
- name: Get scripts
|
||||
id: check-install-script
|
||||
run: |
|
||||
ALL_FILES=()
|
||||
ADDED_FILES=()
|
||||
for FILE in ${{ env.SCRIPT }}; do
|
||||
if [[ $FILE =~ ^install/.*-install\.sh$ ]] || [[ $FILE =~ ^ct/.*\.sh$ ]]; then
|
||||
ADDED_FILES=()
|
||||
for FILE in ${{ env.SCRIPT }}; do
|
||||
if [[ $FILE =~ ^install/.*-install\.sh$ ]] || [[ $FILE =~ ^ct/.*\.sh$ ]]; then
|
||||
STRIPPED_NAME=$(basename "$FILE" | sed 's/-install//' | sed 's/\.sh$//')
|
||||
if [[ ! " ${ADDED_FILES[@]} " =~ " $STRIPPED_NAME " ]]; then
|
||||
ALL_FILES+=("$FILE")
|
||||
@ -57,14 +57,14 @@ 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
|
||||
run: |
|
||||
set +e
|
||||
set +e
|
||||
#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$//')
|
||||
echo "Running Test for: $STRIPPED_NAME"
|
||||
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"
|
||||
echo "$ERROR_MSG" > result_$STRIPPED_NAME.log
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
echo "Found install script for $STRIPPED_NAME"
|
||||
chmod +x "$INSTALL_SCRIPT"
|
||||
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-alpine-install.func
|
||||
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-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"
|
||||
export TERM=xterm
|
||||
ERROR_MSG=$(./$RUNNING_FILE 2>&1 > /dev/null)
|
||||
echo "Finished running $FILE"
|
||||
if [ -n "$ERROR_MSG" ]; then
|
||||
@ -127,38 +128,38 @@ jobs:
|
||||
fi
|
||||
done
|
||||
set -e # Restore exit-on-error
|
||||
|
||||
|
||||
- name: Cleanup PVE Node
|
||||
run: |
|
||||
containers=$(pct list | tail -n +2 | awk '{print $0 " " $4}' | awk '{print $1}')
|
||||
|
||||
|
||||
for container_id in $containers; do
|
||||
status=$(pct status $container_id | awk '{print $2}')
|
||||
if [[ $status == "running" ]]; then
|
||||
pct stop $container_id
|
||||
pct destroy $container_id
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
- name: Post error comments
|
||||
run: |
|
||||
ERROR="false"
|
||||
SEARCH_LINE=".github/workflows/scripts/app-test/pr-build.func: line 255:"
|
||||
|
||||
|
||||
# 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
|
||||
STRIPPED_NAME=$(basename "$FILE" | sed 's/-install//' | sed 's/\.sh$//')
|
||||
if [[ ! -f result_$STRIPPED_NAME.log ]]; then
|
||||
continue
|
||||
fi
|
||||
ERROR_MSG=$(cat result_$STRIPPED_NAME.log)
|
||||
|
||||
|
||||
if [ -n "$ERROR_MSG" ]; then
|
||||
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>"
|
||||
|
||||
|
||||
# Check if the comment already exists
|
||||
if echo "$EXISTING_COMMENTS" | grep -qF "$COMMENT_BODY"; then
|
||||
echo "Skipping duplicate comment for $FILE"
|
||||
@ -171,7 +172,7 @@ jobs:
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
echo "ERROR=$ERROR" >> $GITHUB_ENV
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -147,9 +147,9 @@ build_container() {
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
pushd $TEMP_DIR >/dev/null
|
||||
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
|
||||
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
|
||||
|
||||
export CACHER="$APT_CACHER"
|
||||
|
Loading…
x
Reference in New Issue
Block a user