Skip to content

Commit e54f674

Browse files
committed
Set up automated test for PID controller
1 parent 5509817 commit e54f674

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
name: "PID Controller Automated Test"
3+
4+
# yamllint disable-line rule:truthy
5+
on:
6+
pull_request:
7+
types: [opened, reopened, synchronize]
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
13+
jobs:
14+
pid-controller-automated-test:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Install dependencies
18+
run: |
19+
sudo apt-get update && sudo apt-get install -y build-essential libssl-dev libmysqlclient-dev imagemagick libmagickwand-dev
20+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
21+
with:
22+
ref: ${{ github.event.pull_request.head.sha }}
23+
fetch-depth: 0
24+
- uses: ruby/setup-ruby@0481980f17b760ef6bca5e8c55809102a0af1e5a # v1.263.0
25+
with:
26+
bundler-cache: true
27+
28+
- name: Update Graphs
29+
run: |
30+
bundle install
31+
bundle exec rake compile
32+
cd experiments
33+
bundle install
34+
# Improve the experiment data collection and graphing
35+
sed -i 's/sleep(0.1)/sleep(0.005)/' example_with_circuit_breaker.rb
36+
# Make graph larger and more visible
37+
sed -i 's/Gruff::Line.new/Gruff::Line.new(1200)/' example_with_circuit_breaker.rb
38+
sed -i 's/graph.line_width = 3/graph.line_width = 5/' example_with_circuit_breaker.rb
39+
# Add debugging
40+
sed -i 's/puts "Generating graph/puts "DEBUG: Total data points:"; puts outcomes.size; puts "Sample data:"; puts outcomes.first(3).inspect; puts "Generating graph/' example_with_circuit_breaker.rb
41+
bundle exec ruby example_with_circuit_breaker.rb
42+
echo "=== Generated files ==="
43+
ls -la *.png
44+
echo "=== File contents check ==="
45+
file *.png
46+
47+
- name: Commit Graphs
48+
run: |
49+
git checkout ${{ github.head_ref }}
50+
git config user.name shopify-actions
51+
git config user.email [email protected]
52+
git add experiments/*.png
53+
if git diff --staged --quiet; then
54+
echo "No changes to commit"
55+
else
56+
git commit -m "Update experiment graphs"
57+
git push
58+
fi
59+

experiments/Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
source "https://rubygems.org"
44

55
# Graphing library for visualization
6+
gemspec path: ".."
67
gem "gruff", "~> 0.23"
78

89
# Alternative: Use rubyplot for pure Ruby plotting (no ImageMagick dependency)

experiments/Gemfile.lock

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

experiments/example_output.png

15.5 KB
Loading

0 commit comments

Comments
 (0)