Skip to content

Commit fb80bb6

Browse files
committed
Refacted testing workflow to use bash script too.
1 parent 09b900a commit fb80bb6

File tree

1 file changed

+13
-46
lines changed

1 file changed

+13
-46
lines changed

.github/workflows/codeception.yml

Lines changed: 13 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -35,64 +35,31 @@ jobs:
3535
- name: Checkout
3636
uses: actions/checkout@v4
3737

38-
- name: Detect changed plugins with test config
39-
id: detect
38+
- name: Get changed plugin directory
39+
id: plugin
4040
run: |
41-
git fetch --prune --unshallow
41+
bash .github/scripts/get-plugin-slug.sh ${{ github.event.pull_request.base.sha }} ${{ github.sha }}
4242
43-
# Get changed files based on event type
44-
if [ "${{ github.event_name }}" = "pull_request" ]; then
45-
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep '^plugins/' || true)
46-
else
47-
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD | grep '^plugins/' || true)
48-
fi
49-
50-
if [ -z "$CHANGED_FILES" ]; then
51-
echo "No plugin files changed"
43+
- name: Detect changed plugins with quality config
44+
id: detect
45+
run: |
46+
if [ -z "${{ steps.plugin.outputs.slug }}" ]; then
47+
echo "No plugin slug detected"
5248
echo "plugins=[]" >> $GITHUB_OUTPUT
5349
echo "has-plugins=false" >> $GITHUB_OUTPUT
5450
exit 0
5551
fi
5652
57-
# Extract unique plugin names and check for test config
58-
PLUGINS_WITH_CONFIG=()
59-
CHECKED_PLUGINS=()
60-
61-
for file in $CHANGED_FILES; do
62-
plugin=$(echo $file | cut -d/ -f2)
63-
64-
# Skip if we already checked this plugin
65-
if [[ " ${CHECKED_PLUGINS[@]} " =~ " $plugin " ]]; then
66-
continue
67-
fi
68-
69-
CHECKED_PLUGINS+=("$plugin")
70-
71-
# Check for both codeception.dist.yml and composer.json
72-
if [ -f "plugins/$plugin/codeception.dist.yml" ] && [ -f "plugins/$plugin/composer.json" ]; then
73-
PLUGINS_WITH_CONFIG+=("$plugin")
74-
echo "✅ Found test config for plugin: $plugin (codeception.dist.yml + composer.json)"
75-
else
76-
echo "ℹ️ Missing test config for plugin: $plugin, skipping tests"
77-
if [ ! -f "plugins/$plugin/codeception.dist.yml" ]; then
78-
echo " - Missing: codeception.dist.yml"
79-
fi
80-
if [ ! -f "plugins/$plugin/composer.json" ]; then
81-
echo " - Missing: composer.json"
82-
fi
83-
fi
84-
done
53+
PLUGIN="${{ steps.plugin.outputs.slug }}"
8554
86-
# Convert to JSON array
87-
if [ ${#PLUGINS_WITH_CONFIG[@]} -gt 0 ]; then
88-
PLUGINS_JSON=$(printf '%s\n' "${PLUGINS_WITH_CONFIG[@]}" | jq -R -s -c 'split("\n")[:-1]')
89-
echo "plugins=${PLUGINS_JSON}" >> $GITHUB_OUTPUT
55+
if [ -f "plugins/$PLUGIN/codeception.dist.yml" ]; then
56+
echo "plugins=[\"$PLUGIN\"]" >> $GITHUB_OUTPUT
9057
echo "has-plugins=true" >> $GITHUB_OUTPUT
91-
echo "Found ${#PLUGINS_WITH_CONFIG[@]} plugin(s) with test config: ${PLUGINS_WITH_CONFIG[*]}"
58+
echo "Found codeception.dist.yml for plugin: $PLUGIN"
9259
else
9360
echo "plugins=[]" >> $GITHUB_OUTPUT
9461
echo "has-plugins=false" >> $GITHUB_OUTPUT
95-
echo "No plugins found with test configuration"
62+
echo "ℹ️ No codeception.dist.yml found for plugin: $PLUGIN, skipping automated tests"
9663
fi
9764
9865
continuous_integration:

0 commit comments

Comments
 (0)