-
Notifications
You must be signed in to change notification settings - Fork 27
102 lines (93 loc) · 3.59 KB
/
pr-integration-tests.yaml
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: Integration Tests
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- "**"
push:
branches:
- main
merge_group:
jobs:
integration-tests:
name: "Integration Tests"
runs-on: ubuntu-latest
if: (github.repository == 'openwallet-foundation/acapy-plugins') && ((github.event_name == 'pull_request' && github.event.pull_request.draft == false) || (github.event_name != 'pull_request'))
steps:
#----------------------------------------------
# Check out repo
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v4
#----------------------------------------------
# Get docker compose
#----------------------------------------------
- name: Initialize Docker Compose
uses: isbang/compose-action@v1.5.1
#----------------------------------------------
# Get changed files
#----------------------------------------------
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v45
#----------------------------------------------
# Get changed plugins
#----------------------------------------------
- name: Get changed plugins
id: changed-plugins
run: |
# Collects all the plugin names that have changes.
# If there is directory that isn't a plugin then it will need to skip it. Currently skipping plugin_globals
declare -a changed_dirs=()
for dir in ./*/; do
current_folder=$(basename "$dir")
if [[ $current_folder == "plugin_globals" ]]; then
continue
fi
for changed_file in ${{ steps.changed-files.outputs.all_changed_files }}; do
if [[ $changed_file == *"$current_folder"* ]]; then
if ! [[ ${changed_dirs[*]} =~ $current_folder ]]; then
changed_dirs+=("$current_folder")
fi
fi
done
done
# Remove any lite plugins from the changed_dirs array
readarray -t lite_plugin_array < lite_plugins
echo "${changed_dirs[@]}"
echo "${lite_plugin_array[@]}"
# Function to remove items in array2 from array1
remove_items() {
local -n source_array=$1
local -n remove_array=$2
local temp_array=()
for item in "${source_array[@]}"; do
skip=false
for remove_item in "${remove_array[@]}"; do
if [[ "$item" == "$remove_item" ]]; then
skip=true
break
fi
done
if ! $skip; then
temp_array+=("$item")
fi
done
source_array=("${temp_array[@]}")
}
remove_items changed_dirs lite_plugin_array
echo "changed-plugins=${changed_dirs[*]}" >> $GITHUB_OUTPUT
#----------------------------------------------
# Run Integation Tests
#----------------------------------------------
- name: Run Integration Tests
id: integration-tests
run: |
for dir in ${{ steps.changed-plugins.outputs.changed-plugins }}; do
echo "Running integration tests for $dir"
cd $dir/integration
docker compose down --remove-orphans
docker compose build
docker compose run tests
cd ../..
done