Skip to content

Commit 7bc5f36

Browse files
authored
Updates
1 parent bc1dccf commit 7bc5f36

12 files changed

Lines changed: 677 additions & 376 deletions

File tree

.github/workflows/branch-cleanup.yml

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,43 @@ permissions:
1414

1515
jobs:
1616
cleanup:
17+
if: github.event.pull_request.merged == true
1718
runs-on: ubuntu-latest
1819

1920
steps:
20-
- uses: actions/checkout@v6
21-
with:
22-
fetch-depth: 0
23-
token: ${{ secrets.GITHUB_TOKEN }}
24-
2521
- name: Delete merged branch
26-
if: github.event.pull_request.merged == true
27-
env:
28-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29-
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
30-
REPOSITORY: ${{ github.repository }}
31-
run: |
32-
echo "Checking branch: $BRANCH_NAME"
33-
34-
# Protected branch check - using quotes to prevent injection
35-
if [[ "$BRANCH_NAME" =~ ^(main|master|dev|develop|staging|production)$ ]]; then
36-
echo "::warning::Skipping deletion of protected branch: $BRANCH_NAME"
37-
exit 0
38-
fi
39-
40-
# Attempt branch deletion - using quotes to prevent injection
41-
echo "Attempting to delete branch: $BRANCH_NAME"
42-
if git push origin --delete "$BRANCH_NAME" 2>/dev/null; then
43-
echo "::notice::Successfully deleted branch: $BRANCH_NAME"
44-
else
45-
echo "::error::Failed to delete branch: $BRANCH_NAME"
46-
exit 1
47-
fi
22+
uses: actions/github-script@v8
23+
with:
24+
script: |
25+
const protectedPattern = /^(main|master|dev|develop|staging|production)$/;
26+
const pullRequest = context.payload.pull_request;
27+
const branchName = pullRequest.head.ref;
28+
const sourceRepo = pullRequest.head.repo.full_name;
29+
const targetRepo = `${context.repo.owner}/${context.repo.repo}`;
30+
31+
core.info(`Checking branch: ${branchName}`);
32+
33+
if (protectedPattern.test(branchName)) {
34+
core.warning(`Skipping deletion of protected branch: ${branchName}`);
35+
return;
36+
}
37+
38+
if (sourceRepo !== targetRepo) {
39+
core.notice(`Skipping deletion for fork branch ${sourceRepo}:${branchName}`);
40+
return;
41+
}
42+
43+
try {
44+
await github.rest.git.deleteRef({
45+
owner: context.repo.owner,
46+
repo: context.repo.repo,
47+
ref: `heads/${branchName}`
48+
});
49+
core.notice(`Successfully deleted branch: ${branchName}`);
50+
} catch (error) {
51+
if (error.status === 404 || error.status === 422) {
52+
core.warning(`Branch already deleted or unavailable: ${branchName}`);
53+
return;
54+
}
55+
throw error;
56+
}

.github/workflows/enginescript-build-test.yml

Lines changed: 34 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,23 @@ name: EngineScript Nginx Build Test
22

33
on:
44
pull_request:
5-
# Run on all pull requests for comprehensive testing
5+
# Only run expensive build tests when relevant files are changed.
6+
paths:
7+
- 'scripts/**'
8+
- 'config/**'
9+
- 'patches/**'
10+
- '.github/ci-config/**'
11+
- '.github/workflows/enginescript-build-test.yml'
12+
- 'enginescript-variables.txt'
613
push:
7-
# Run on all pushes to any branch for comprehensive testing
14+
# Only run expensive build tests when relevant files are changed.
815
paths:
916
- 'scripts/**'
1017
- 'config/**'
18+
- 'patches/**'
19+
- '.github/ci-config/**'
20+
- '.github/workflows/enginescript-build-test.yml'
1121
- 'enginescript-variables.txt'
12-
create:
13-
# Run when new branches are created
1422
workflow_dispatch:
1523

1624
concurrency:
@@ -20,7 +28,6 @@ concurrency:
2028
permissions:
2129
contents: read
2230
pull-requests: write
23-
actions: read
2431
issues: write
2532

2633
jobs:
@@ -44,15 +51,12 @@ jobs:
4451
sudo rm -rf /usr/local/graalvm
4552
sudo rm -rf /usr/local/.ghcup
4653
sudo docker system prune -af
47-
sudo apt-get autoremove -y
48-
sudo apt-get autoclean
4954
echo "💾 Available disk space:"
5055
df -h
5156
5257
- name: Setup Nginx Build Environment
5358
run: |
5459
echo "🏗️ Setting up Nginx build environment..."
55-
sudo apt-get update -qq
5660
5761
# Create required directories including log directories
5862
sudo mkdir -p /usr/local/bin/enginescript /home/EngineScript /var/log/EngineScript /tmp/ci-logs
@@ -198,10 +202,8 @@ jobs:
198202
sudo apt-get remove 'apache2.*' -y 2>&1 | sudo tee -a /tmp/ci-logs/setup.log
199203
echo "✅ Old packages cleaned up" | sudo tee -a /tmp/ci-logs/setup.log
200204
201-
# Final update
202-
echo "� Final system update..." | sudo tee -a /tmp/ci-logs/setup.log
203-
sudo apt update --allow-releaseinfo-change -y 2>&1 | sudo tee -a /tmp/ci-logs/setup.log
204-
sudo apt upgrade -y 2>&1 | sudo tee -a /tmp/ci-logs/setup.log
205+
# Skip duplicate full upgrade pass to reduce CI runtime
206+
echo "⏭️ Skipping duplicate final apt update/upgrade pass in CI" | sudo tee -a /tmp/ci-logs/setup.log
205207
206208
# Skip timezone configuration (problematic in CI)
207209
echo "⏭️ Skipping timezone configuration (not suitable for CI environment)" | sudo tee -a /tmp/ci-logs/setup.log
@@ -457,75 +459,35 @@ jobs:
457459
458460
- name: Install GCC
459461
run: |
460-
echo "🔨 Installing GCC..."
461-
cd /usr/local/bin/enginescript/scripts/install
462-
463-
# Set CI environment variables
464-
export CI_ENVIRONMENT=true
465-
export DEBIAN_FRONTEND=noninteractive
466-
467-
cd /usr/local/bin/enginescript/scripts/install
468-
469-
timeout 600 sudo bash ./gcc/gcc-install.sh 2>&1 | sudo tee /tmp/ci-logs/gcc.log || {
470-
echo "⚠️ GCC installation had issues, continuing..."
471-
tail -30 /tmp/ci-logs/gcc.log 2>/dev/null || echo "No GCC log available"
472-
}
473-
sudo sync
474-
echo "✅ GCC installation completed"
462+
/usr/local/bin/enginescript/scripts/ci/run-install-step.sh \
463+
"GCC" \
464+
"600" \
465+
"/usr/local/bin/enginescript/scripts/install/gcc/gcc-install.sh" \
466+
"/tmp/ci-logs/gcc.log"
475467
476468
- name: Install OpenSSL
477469
run: |
478-
echo "� Installing OpenSSL..."
479-
cd /usr/local/bin/enginescript/scripts/install
480-
481-
# Set CI environment variables
482-
export CI_ENVIRONMENT=true
483-
export DEBIAN_FRONTEND=noninteractive
484-
485-
cd /usr/local/bin/enginescript/scripts/install
486-
487-
timeout 900 sudo bash ./openssl/openssl-install.sh 2>&1 | sudo tee /tmp/ci-logs/openssl.log || {
488-
echo "⚠️ OpenSSL installation had issues, continuing..."
489-
tail -50 /tmp/ci-logs/openssl.log 2>/dev/null || echo "No OpenSSL log available"
490-
}
491-
sudo sync
492-
echo "✅ OpenSSL installation completed"
470+
/usr/local/bin/enginescript/scripts/ci/run-install-step.sh \
471+
"OpenSSL" \
472+
"900" \
473+
"/usr/local/bin/enginescript/scripts/install/openssl/openssl-install.sh" \
474+
"/tmp/ci-logs/openssl.log"
493475
494476
- name: Install PCRE
495477
run: |
496-
echo "� Installing PCRE..."
497-
cd /usr/local/bin/enginescript/scripts/install
498-
499-
# Set CI environment variables
500-
export CI_ENVIRONMENT=true
501-
export DEBIAN_FRONTEND=noninteractive
502-
503-
cd /usr/local/bin/enginescript/scripts/install
504-
505-
timeout 600 sudo bash ./pcre/pcre-install.sh 2>&1 | sudo tee /tmp/ci-logs/pcre.log || {
506-
echo "⚠️ PCRE installation had issues, continuing..."
507-
tail -30 /tmp/ci-logs/pcre.log 2>/dev/null || echo "No PCRE log available"
508-
}
509-
sudo sync
510-
echo "✅ PCRE installation completed"
478+
/usr/local/bin/enginescript/scripts/ci/run-install-step.sh \
479+
"PCRE" \
480+
"600" \
481+
"/usr/local/bin/enginescript/scripts/install/pcre/pcre-install.sh" \
482+
"/tmp/ci-logs/pcre.log"
511483
512484
- name: Install Zlib
513485
run: |
514-
echo "📦 Installing Zlib..."
515-
cd /usr/local/bin/enginescript/scripts/install
516-
517-
# Set CI environment variables
518-
export CI_ENVIRONMENT=true
519-
export DEBIAN_FRONTEND=noninteractive
520-
521-
cd /usr/local/bin/enginescript/scripts/install
522-
523-
timeout 600 sudo bash ./zlib/zlib-install.sh 2>&1 | sudo tee /tmp/ci-logs/zlib.log || {
524-
echo "⚠️ Zlib installation had issues, continuing..."
525-
tail -30 /tmp/ci-logs/zlib.log 2>/dev/null || echo "No Zlib log available"
526-
}
527-
sudo sync
528-
echo "✅ Zlib installation completed"
486+
/usr/local/bin/enginescript/scripts/ci/run-install-step.sh \
487+
"Zlib" \
488+
"600" \
489+
"/usr/local/bin/enginescript/scripts/install/zlib/zlib-install.sh" \
490+
"/tmp/ci-logs/zlib.log"
529491
530492
- name: Build Nginx Component
531493
run: |

0 commit comments

Comments
 (0)