Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Test docker container

on:
pull_request:
push:
branches:
- "rootstock"
workflow_dispatch:

# Declare default permissions as read only.
permissions: read-all

jobs:
docker:
runs-on: ubuntu-24.04

steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
Copy link

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pinning to a specific commit SHA can make upgrades harder; consider using the version tag (e.g. actions/checkout@v4) for clearer maintenance.

Suggested change
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
uses: actions/checkout@v4.2.2

Copilot uses AI. Check for mistakes.

- name: Validate Docker container
run: |
set -e

docker build -t safe-watcher:latest .
container_id=$(docker run -d --name safe-watcher-container -v $(pwd)/config.example.yaml:/app/config.yaml safe-watcher:latest)
Copy link

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the --rm flag to docker run to automatically clean up the container after stopping, avoiding leftover containers on the runner.

Suggested change
container_id=$(docker run -d --name safe-watcher-container -v $(pwd)/config.example.yaml:/app/config.yaml safe-watcher:latest)
container_id=$(docker run -d --rm --name safe-watcher-container -v $(pwd)/config.example.yaml:/app/config.yaml safe-watcher:latest)

Copilot uses AI. Check for mistakes.
trap 'docker stop "$container_id"' EXIT INT QUIT TERM

# Give a couple of seconds for the container to start.
sleep 5

if [ "$(docker inspect -f '{{.State.Running}}' safe-watcher-container)" != "true" ]; then
echo "Container failed to start"
exit 1
fi

max_attempts=20
attempts=0
count=0

while [ $attempts -lt $max_attempts ]; do
Copy link

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loop polls without delay and may spin CPU. Insert a sleep 1 (or appropriate interval) inside the loop to avoid busy–waiting.

Copilot uses AI. Check for mistakes.
count=$(docker logs safe-watcher-container | grep -c "started healthcheck")

if [ $count -gt 0 ]; then
echo "✅ Found 'started healthcheck' block in logs!"
break
fi

attempts=$(($attempts + 1))
done

if [ $count -le 0 ]; then
echo "❌ 'started healthcheck' block not found in logs after $max_attempts attempts"
exit 1
fi

echo "Container is running properly"
9 changes: 6 additions & 3 deletions config.example.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
telegramBotToken: "xxxx"
telegramChannelId: "-1111"
slackBotToken: "xoxb-1234567890-1234567890-1234567890"
Copy link

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use placeholder syntax (e.g. <SLACK_BOT_TOKEN>) instead of a realistic-looking token to avoid confusion and accidental leaks.

Suggested change
slackBotToken: "xoxb-1234567890-1234567890-1234567890"
slackBotToken: "<SLACK_BOT_TOKEN>"

Copilot uses AI. Check for mistakes.
slackChannelId: "C01234567890"
safeAddresses:
- "desc: eth:0x11111"
- "rsk:0x0000000000000000000000000000000000000001": "Safe 1"
signers:
"0x22222": "alice"
"0x33333": "bob"
"0x1234567890123456789012345678901234567890": "Alice"
"0x0987654321098765432109876543210987654321": "Bob"
"0x1234567890abcdef1234567890abcdef12345678": "Charlie"