-
Notifications
You must be signed in to change notification settings - Fork 9
142 lines (117 loc) · 3.58 KB
/
packer-test.yml
File metadata and controls
142 lines (117 loc) · 3.58 KB
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Packer Script Testing
on:
pull_request:
paths:
- 'packer/**'
- '.github/workflows/packer-test.yml'
push:
branches:
- main
paths:
- 'packer/**'
- '.github/workflows/packer-test.yml'
workflow_dispatch:
jobs:
test-individual-scripts:
name: Test Individual Scripts
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
script:
- cassandra/install/install_cassandra_easy_stress.sh
- base/install/install_docker.sh
- base/install/install_python.sh
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build test image
run: |
cd packer
docker build -t easy-cass-lab-packer-test .
- name: Test script - ${{ matrix.script }}
run: |
cd packer
./test-script.sh ${{ matrix.script }}
test-changed-scripts:
name: Test Changed Scripts
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build test image
run: |
cd packer
docker build -t easy-cass-lab-packer-test .
- name: Detect and test changed scripts
run: |
cd packer
echo "Detecting changed shell scripts..."
# Get list of changed .sh files
CHANGED_SCRIPTS=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep '^packer/.*\.sh$' | grep -v 'test-script.sh' || true)
if [ -z "$CHANGED_SCRIPTS" ]; then
echo "No shell scripts changed in this PR"
exit 0
fi
echo "Changed scripts:"
echo "$CHANGED_SCRIPTS"
# Test each changed script
EXIT_CODE=0
for script in $CHANGED_SCRIPTS; do
# Remove 'packer/' prefix if present
script_path="${script#packer/}"
# Skip deleted files
if [ ! -f "$script" ]; then
echo "⊘ $script_path was deleted, skipping test"
continue
fi
echo "Testing: $script_path"
if ./test-script.sh "$script_path"; then
echo "✓ $script_path passed"
else
echo "✗ $script_path failed"
EXIT_CODE=1
fi
done
exit $EXIT_CODE
test-base-provisioning:
name: Test Base Provisioning Sequence
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Test base provisioning
run: |
cd packer
docker compose up --exit-code-from test-base test-base
- name: Show logs on failure
if: failure()
run: |
cd packer
docker compose logs test-base
test-cassandra-provisioning:
name: Test Cassandra Provisioning Sequence
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Test cassandra provisioning
run: |
cd packer
docker compose up --exit-code-from test-cassandra test-cassandra
- name: Show logs on failure
if: failure()
run: |
cd packer
docker compose logs test-cassandra