Skip to content

Commit 63fd3df

Browse files
author
Developer
committed
improve coverage, improve makefile
1 parent fc4fbc3 commit 63fd3df

File tree

133 files changed

+8809
-5109
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+8809
-5109
lines changed

β€Ž.claude/settings.local.jsonβ€Ž

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@
4949
"Bash(else)",
5050
"Bash(fi)",
5151
"Bash(done)",
52-
"Bash(sed:*)"
52+
"Bash(sed:*)",
53+
"Bash(make lint)",
54+
"Bash(make lint-fix:*)",
55+
"Bash(make:*)"
5356
],
5457
"deny": []
5558
}

β€Ž.editorconfigβ€Ž

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
indent_style = space
11+
indent_size = 2
12+
13+
[*.{rb,rake,ru}]
14+
indent_size = 2
15+
16+
[*.{js,jsx,ts,tsx}]
17+
indent_size = 2
18+
19+
[*.{yml,yaml}]
20+
indent_size = 2
21+
22+
[*.{json}]
23+
indent_size = 2
24+
25+
[*.{html,erb}]
26+
indent_size = 2
27+
28+
[*.{css,scss}]
29+
indent_size = 2
30+
31+
[*.md]
32+
trim_trailing_whitespace = false
33+
34+
[Makefile]
35+
indent_style = tab
36+
indent_size = 4
37+
38+
[*.{bat,cmd}]
39+
end_of_line = crlf

β€Ž.eslintrc.jsonβ€Ž

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2022": true
5+
},
6+
"extends": [
7+
"standard"
8+
],
9+
"parserOptions": {
10+
"ecmaVersion": 2022,
11+
"sourceType": "module"
12+
},
13+
"globals": {
14+
"Stimulus": "readonly",
15+
"Turbo": "readonly",
16+
"ActionCable": "readonly",
17+
"Rails": "readonly"
18+
},
19+
"rules": {
20+
"no-console": "warn",
21+
"no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
22+
"prefer-const": "error",
23+
"no-var": "error",
24+
"object-shorthand": "error",
25+
"prefer-template": "error",
26+
"template-curly-spacing": "error",
27+
"arrow-spacing": "error",
28+
"comma-dangle": ["error", "never"],
29+
"quotes": ["error", "single", { "avoidEscape": true }],
30+
"semi": ["error", "never"],
31+
"space-before-function-paren": ["error", "always"],
32+
"keyword-spacing": "error",
33+
"space-infix-ops": "error",
34+
"eol-last": "error",
35+
"no-trailing-spaces": "error",
36+
"indent": ["error", 2],
37+
"no-multiple-empty-lines": ["error", { "max": 1 }],
38+
"padded-blocks": ["error", "never"],
39+
"object-curly-spacing": ["error", "always"],
40+
"array-bracket-spacing": ["error", "never"],
41+
"computed-property-spacing": ["error", "never"],
42+
"func-call-spacing": ["error", "never"],
43+
"key-spacing": ["error", { "beforeColon": false, "afterColon": true }],
44+
"no-mixed-operators": "error",
45+
"no-tabs": "error",
46+
"quote-props": ["error", "as-needed"],
47+
"space-unary-ops": "error",
48+
"spaced-comment": ["error", "always"],
49+
"switch-colon-spacing": "error",
50+
"unicode-bom": ["error", "never"]
51+
},
52+
"overrides": [
53+
{
54+
"files": ["**/controllers/**/*.js"],
55+
"rules": {
56+
"class-methods-use-this": "off",
57+
"no-unused-vars": ["error", { "args": "none" }]
58+
}
59+
}
60+
]
61+
}

β€Ž.github/workflows/deploy.ymlβ€Ž

Lines changed: 153 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,23 @@ on:
55
branches: [ main ]
66
workflow_dispatch:
77

8+
env:
9+
RUBY_VERSION: '3.3.6'
10+
NODE_VERSION: '20'
11+
POSTGRES_VERSION: '17'
12+
REDIS_VERSION: '7'
13+
814
jobs:
915
test:
1016
runs-on: ubuntu-latest
17+
timeout-minutes: 30
1118

1219
services:
1320
postgres:
1421
image: postgres:17
1522
env:
1623
POSTGRES_PASSWORD: postgres
24+
POSTGRES_DB: streamsource_test
1725
options: >-
1826
--health-cmd pg_isready
1927
--health-interval 10s
@@ -33,23 +41,46 @@ jobs:
3341
- 6379:6379
3442

3543
steps:
36-
- uses: actions/checkout@v4
44+
- name: Checkout code
45+
uses: actions/checkout@v4
46+
with:
47+
fetch-depth: 0 # Full history for better caching
3748

49+
- name: Cache Ruby dependencies
50+
uses: actions/cache@v4
51+
with:
52+
path: |
53+
~/.bundle
54+
vendor/bundle
55+
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
56+
restore-keys: |
57+
${{ runner.os }}-gems-
58+
3859
- name: Set up Ruby
3960
uses: ruby/setup-ruby@v1
4061
with:
41-
ruby-version: '3.3.6'
62+
ruby-version: ${{ env.RUBY_VERSION }}
4263
bundler-cache: true
4364

65+
- name: Cache Node dependencies
66+
uses: actions/cache@v4
67+
with:
68+
path: |
69+
~/.cache/yarn
70+
node_modules
71+
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
72+
restore-keys: |
73+
${{ runner.os }}-node-
74+
4475
- name: Setup Node
4576
uses: actions/setup-node@v4
4677
with:
47-
node-version: '20'
78+
node-version: ${{ env.NODE_VERSION }}
4879
cache: 'yarn'
4980

5081
- name: Install dependencies
5182
run: |
52-
yarn install --frozen-lockfile
83+
yarn install --frozen-lockfile --prefer-offline
5384
5485
- name: Setup test database
5586
env:
@@ -69,37 +100,148 @@ jobs:
69100

70101
- name: Run security checks
71102
run: |
72-
bundle exec brakeman -q -w2
73-
bundle exec bundler-audit --update
103+
echo "πŸ” Running security analysis..."
104+
105+
# Static Application Security Testing (SAST)
106+
bundle exec brakeman -q -w2 --format json --output brakeman-report.json
107+
108+
# Dependency vulnerability scanning
109+
bundle exec bundler-audit check --update --format json --output bundler-audit-report.json
110+
111+
# Display results
112+
echo "Brakeman security scan completed"
113+
if [ -f brakeman-report.json ]; then
114+
echo "Brakeman found $(jq '.warnings | length' brakeman-report.json) potential issues"
115+
fi
116+
117+
echo "Bundler audit completed"
118+
if [ -f bundler-audit-report.json ]; then
119+
echo "Bundler audit found $(jq '.vulnerabilities | length' bundler-audit-report.json) vulnerabilities"
120+
fi
121+
122+
- name: Upload security reports
123+
uses: actions/upload-artifact@v4
124+
if: always()
125+
with:
126+
name: security-reports
127+
path: |
128+
brakeman-report.json
129+
bundler-audit-report.json
130+
retention-days: 30
74131

75132
deploy:
76133
needs: test
77134
runs-on: ubuntu-latest
78135
if: github.ref == 'refs/heads/main'
136+
timeout-minutes: 20
137+
environment:
138+
name: production
139+
url: https://${{ secrets.DROPLET_HOST }}
79140

80141
steps:
81-
- uses: actions/checkout@v4
142+
- name: Checkout code
143+
uses: actions/checkout@v4
82144

83145
- name: Deploy to DigitalOcean
146+
id: deploy
84147
uses: appleboy/[email protected]
85148
with:
86149
host: ${{ secrets.DROPLET_HOST }}
87150
username: deploy
88151
key: ${{ secrets.DEPLOY_SSH_KEY }}
152+
timeout: 900s
89153
script: |
154+
set -e
90155
cd /var/www/streamsource
156+
157+
# Set environment variables for deployment
158+
export GITHUB_REPOSITORY="${{ github.repository }}"
159+
export GITHUB_SHA="${{ github.sha }}"
160+
export GITHUB_REF="${{ github.ref }}"
161+
162+
# Run deployment with error handling
163+
echo "πŸš€ Starting deployment..."
91164
./deploy/github-deploy.sh
165+
166+
echo "βœ… Deployment completed successfully"
92167
93-
- name: Health check
168+
- name: Comprehensive health check
94169
run: |
170+
echo "πŸ₯ Running comprehensive health checks..."
171+
172+
# Wait for application to stabilize
95173
sleep 30
96-
curl -f https://${{ secrets.DROPLET_HOST }}/health || exit 1
174+
175+
# Test multiple endpoints
176+
echo "Testing basic health endpoint..."
177+
curl -f -s https://${{ secrets.DROPLET_HOST }}/health || exit 1
178+
179+
echo "Testing database connectivity..."
180+
curl -f -s https://${{ secrets.DROPLET_HOST }}/health/db || exit 1
181+
182+
echo "Testing Redis connectivity..."
183+
curl -f -s https://${{ secrets.DROPLET_HOST }}/health/redis || exit 1
184+
185+
echo "Testing application responsiveness..."
186+
RESPONSE_TIME=$(curl -w "%{time_total}" -s -o /dev/null https://${{ secrets.DROPLET_HOST }}/health)
187+
echo "Response time: ${RESPONSE_TIME}s"
188+
189+
# Fail if response time is too slow (> 5 seconds)
190+
if (( $(echo "$RESPONSE_TIME > 5.0" | bc -l) )); then
191+
echo "❌ Application is responding too slowly ($RESPONSE_TIME seconds)"
192+
exit 1
193+
fi
194+
195+
echo "βœ… All health checks passed"
97196
197+
- name: Rollback on failure
198+
if: failure() && steps.deploy.conclusion == 'failure'
199+
uses: appleboy/[email protected]
200+
with:
201+
host: ${{ secrets.DROPLET_HOST }}
202+
username: deploy
203+
key: ${{ secrets.DEPLOY_SSH_KEY }}
204+
script: |
205+
cd /var/www/streamsource
206+
echo "πŸ”„ Initiating automatic rollback..."
207+
./deploy/rollback.sh
208+
echo "βœ… Rollback completed"
209+
continue-on-error: true
210+
98211
- name: Notify deployment status
99212
if: always()
100213
uses: 8398a7/action-slack@v3
101214
with:
102215
status: ${{ job.status }}
103-
text: 'StreamSource deployment ${{ job.status }}'
104216
webhook_url: ${{ secrets.SLACK_WEBHOOK }}
105-
continue-on-error: true
217+
text: |
218+
StreamSource deployment ${{ job.status }}
219+
220+
πŸ“‹ *Deployment Details:*
221+
β€’ Commit: `${{ github.sha }}`
222+
β€’ Branch: `${{ github.ref_name }}`
223+
β€’ Author: ${{ github.actor }}
224+
β€’ Workflow: ${{ github.workflow }}
225+
226+
${{ job.status == 'success' && 'βœ… Deployment successful!' || '❌ Deployment failed - automatic rollback initiated' }}
227+
228+
πŸ”— [View Workflow Run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
229+
continue-on-error: true
230+
231+
- name: Record deployment metrics
232+
if: always()
233+
run: |
234+
echo "πŸ“Š Recording deployment metrics..."
235+
236+
# Create deployment record
237+
curl -X POST "https://api.github.com/repos/${{ github.repository }}/deployments" \
238+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
239+
-H "Content-Type: application/json" \
240+
-d '{
241+
"ref": "${{ github.sha }}",
242+
"environment": "production",
243+
"description": "Deployment via GitHub Actions",
244+
"auto_merge": false
245+
}' || echo "Failed to record deployment"
246+
247+
echo "βœ… Deployment metrics recorded"

0 commit comments

Comments
Β (0)