-
Notifications
You must be signed in to change notification settings - Fork 4
63 lines (54 loc) · 2.38 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Continuous Integration
on:
push:
paths:
- "plugins/**/*.java" # Match changes in Java files.
- "plugins/**/*.gradle" # Match changes in Gradle configuration.
pull_request:
paths:
- "plugins/**/*.java" # Match changes in Java files.
- "plugins/**/*.gradle" # Match changes in Gradle configuration.
jobs:
ci:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
# Step to find which project folder contains modified files
- name: Detect modified plugins
id: detect_changes
run: |
# Capture the list of modified files
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
# Check if any files are modified in wazuh-indexer-setup
if echo "$CHANGED_FILES" | grep -q "^plugins/setup/"; then
echo "setup" >> affected_projects.txt
fi
# Check if any files are modified in wazuh-command-manager
if echo "$CHANGED_FILES" | grep -q "^plugins/command-manager/"; then
echo "command-manager" >> affected_projects.txt
fi
# Output the list of affected projects
if [ -f affected_projects.txt ]; then
echo "::set-output name=projects::$(cat affected_projects.txt | paste -sd,)"
else
echo "::set-output name=projects::none"
fi
# Run tests for affected projects
- name: Run tests for affected projects
run: |
if [[ "${{ steps.detect_changes.outputs.projects }}" != "none" ]]; then
for project in $(echo "${{ steps.detect_changes.outputs.projects }}" | tr ',' ' '); do
echo "Running tests for $project"
cd plugins/$project
./gradlew check
cd - # Go back to the root folder
done
else
echo "No changes in Java or Gradle files to test."
fi