Skip to content

Commit b99f780

Browse files
committed
auto test action
1 parent 7c7469c commit b99f780

5 files changed

Lines changed: 608 additions & 81 deletions

File tree

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
name: Auto Test - Dev CI
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
paths-ignore:
8+
- '**.md'
9+
- 'docs/**'
10+
11+
jobs:
12+
build-and-test:
13+
name: Build and Integration Test
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Get version info
21+
id: version
22+
run: |
23+
if [ -f version.json ]; then
24+
version=$(jq -r '.version' version.json)
25+
echo "version=$version" >> $GITHUB_OUTPUT
26+
echo "Current version: $version"
27+
else
28+
echo "version=dev-$(date +%Y%m%d-%H%M%S)" >> $GITHUB_OUTPUT
29+
fi
30+
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v3
33+
34+
- name: Build appmanage image
35+
if: hashFiles('appmanage/Dockerfile') != ''
36+
run: |
37+
echo "Building appmanage image for dev..."
38+
version=$(grep -Po '(?<=LABEL version=").*?(?=")' appmanage/Dockerfile || echo "dev")
39+
docker build -t websoft9dev/appmanage:$version ./appmanage
40+
docker tag websoft9dev/appmanage:$version websoft9dev/appmanage:dev-latest
41+
echo "✅ Appmanage image built successfully"
42+
43+
- name: Run docker-compose validation
44+
run: |
45+
echo "Validating all docker-compose configurations..."
46+
if [ -d docker ]; then
47+
for compose_file in $(find docker -name "docker-compose.yml"); do
48+
echo "Validating: $compose_file"
49+
docker-compose -f "$compose_file" config > /dev/null
50+
done
51+
echo "✅ All docker-compose files validated"
52+
fi
53+
54+
- name: Test systemd service files
55+
run: |
56+
echo "Checking systemd service files..."
57+
if [ -d systemd ]; then
58+
for service_file in $(find systemd -name "*.service"); do
59+
echo "Checking: $service_file"
60+
# Basic syntax check
61+
grep -q "\[Unit\]" "$service_file" || exit 1
62+
grep -q "\[Service\]" "$service_file" || exit 1
63+
done
64+
echo "✅ Systemd service files are valid"
65+
fi
66+
67+
- name: Test installation script
68+
run: |
69+
echo "Testing installation script..."
70+
if [ -f install/install.sh ]; then
71+
# Syntax check
72+
bash -n install/install.sh
73+
74+
# Check for required functions/variables
75+
grep -q "install" install/install.sh || echo "Warning: No install function found"
76+
77+
echo "✅ Installation script syntax validated"
78+
fi
79+
80+
- name: Security scan with Trivy
81+
uses: aquasecurity/trivy-action@master
82+
with:
83+
scan-type: 'fs'
84+
scan-ref: '.'
85+
format: 'table'
86+
exit-code: '0'
87+
severity: 'CRITICAL,HIGH'
88+
89+
- name: Upload to dev channel (simulation)
90+
run: |
91+
echo "========================================="
92+
echo "Dev build completed successfully"
93+
echo "Version: ${{ steps.version.outputs.version }}"
94+
echo "Would upload to dev channel in production"
95+
echo "========================================="
96+
97+
integration-test:
98+
name: Integration Test
99+
runs-on: ubuntu-latest
100+
needs: build-and-test
101+
102+
steps:
103+
- name: Checkout code
104+
uses: actions/checkout@v4
105+
106+
- name: Setup test environment
107+
run: |
108+
echo "Setting up test environment..."
109+
# Create necessary directories
110+
sudo mkdir -p /data/apps
111+
sudo mkdir -p /opt/websoft9
112+
echo "✅ Test environment ready"
113+
114+
- name: Test script execution
115+
run: |
116+
echo "Testing critical scripts..."
117+
118+
# Test update_issue.sh if exists
119+
if [ -f systemd/script/update_issue.sh ]; then
120+
echo "Testing update_issue.sh..."
121+
sudo bash systemd/script/update_issue.sh || echo "Note: Script requires full system context"
122+
fi
123+
124+
echo "✅ Script execution tests completed"
125+
126+
- name: API endpoint test
127+
run: |
128+
echo "Testing API endpoints (when available)..."
129+
# Add API tests here when services are running
130+
echo "✅ API tests completed"
131+
132+
notify:
133+
name: Notification
134+
runs-on: ubuntu-latest
135+
needs: [build-and-test, integration-test]
136+
if: always()
137+
138+
steps:
139+
- name: Build summary
140+
run: |
141+
echo "========================================="
142+
echo "Dev CI - Build Summary"
143+
echo "========================================="
144+
echo "Build & Test: ${{ needs.build-and-test.result }}"
145+
echo "Integration Test: ${{ needs.integration-test.result }}"
146+
echo "========================================="
147+
148+
if [[ "${{ needs.build-and-test.result }}" == "success" ]] && \
149+
[[ "${{ needs.integration-test.result }}" == "success" ]]; then
150+
echo "✅ Dev CI passed - Ready for merge to main"
151+
else
152+
echo "❌ Dev CI failed - Please review"
153+
exit 1
154+
fi

0 commit comments

Comments
 (0)