Skip to content

Commit 0fe995c

Browse files
Merge pull request #31 from Stephenson-Software/copilot/fix-483ab8f9-fda2-4256-9253-c3292e4ac779
Add GitHub Action to run Kreatures program with automated inputs
2 parents b2b9bd2 + 10b5a3c commit 0fe995c

File tree

1 file changed

+131
-0
lines changed

1 file changed

+131
-0
lines changed

.github/workflows/run-program.yml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: Run Kreatures Program Demo
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
workflow_dispatch: # Allow manual triggering
9+
10+
jobs:
11+
run-program:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Python 3.11
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.11'
21+
22+
- name: Install system dependencies
23+
run: |
24+
sudo apt-get update
25+
sudo apt-get install -y expect
26+
27+
- name: Create input automation script
28+
run: |
29+
cat > run_kreatures.exp << 'EOF'
30+
#!/usr/bin/expect -f
31+
32+
# Set timeout for the entire script
33+
set timeout 60
34+
35+
# Start the program
36+
spawn python src/kreatures.py
37+
38+
# Handle the creature name prompt
39+
expect "What would you like to name your kreature?"
40+
expect "> "
41+
send "GitHubRunner\r"
42+
43+
# Main game loop - handle various possible prompts
44+
set continue_game 1
45+
while {$continue_game} {
46+
expect {
47+
# Child continuation prompt - if our creature dies but has children
48+
"Would you like to continue as one of your children? (y/n)" {
49+
expect "> "
50+
send "y\r"
51+
52+
# Handle potential child selection
53+
expect {
54+
"Which child would you like to continue as?" {
55+
expect "> "
56+
send "1\r"
57+
}
58+
-re "You are now playing as.*!" {
59+
# Child was auto-selected, continue
60+
}
61+
timeout {
62+
puts "Timeout waiting for child selection"
63+
set continue_game 0
64+
}
65+
}
66+
}
67+
68+
# Final continue prompt at end of simulation
69+
"\[CONTINUE\]" {
70+
send "\r"
71+
set continue_game 0
72+
}
73+
74+
# Maximum iterations reached
75+
"Maximum iterations reached." {
76+
# Game will end soon, wait for final prompt
77+
}
78+
79+
# Timeout or end of output
80+
timeout {
81+
puts "\nSimulation completed or timed out"
82+
set continue_game 0
83+
}
84+
85+
eof {
86+
puts "\nProgram ended normally"
87+
set continue_game 0
88+
}
89+
}
90+
}
91+
92+
# Wait for the program to fully complete
93+
expect eof
94+
EOF
95+
96+
chmod +x run_kreatures.exp
97+
98+
- name: Display program information
99+
run: |
100+
echo "🧬 Starting Kreatures Simulation Demo"
101+
echo "======================================"
102+
echo ""
103+
echo "Kreatures is a virtual creature simulation game where:"
104+
echo "• You create a creature and release it into an environment"
105+
echo "• Your creature interacts with other creatures through fighting, befriending, and reproduction"
106+
echo "• Creatures adjust their behavior based on their actions"
107+
echo "• The simulation runs until your creature dies or reaches maximum iterations"
108+
echo ""
109+
echo "This demo will create a creature named 'GitHubRunner' and simulate its life."
110+
echo ""
111+
112+
- name: Run Kreatures program with automation
113+
run: |
114+
echo "🎮 Running simulation..."
115+
echo "======================="
116+
./run_kreatures.exp
117+
118+
- name: Display completion message
119+
run: |
120+
echo ""
121+
echo "✅ Kreatures simulation completed successfully!"
122+
echo "=============================================="
123+
echo ""
124+
echo "The GitHub Action successfully demonstrated the Kreatures program by:"
125+
echo "• Creating a creature named 'GitHubRunner'"
126+
echo "• Simulating creature interactions in the virtual environment"
127+
echo "• Handling all user prompts automatically"
128+
echo "• Displaying the final simulation results and statistics"
129+
echo ""
130+
echo "This shows how the program works when run by a user, with all"
131+
echo "interactive prompts handled automatically for CI/CD demonstration."

0 commit comments

Comments
 (0)