Skip to content

Commit b9bda86

Browse files
committed
Refactored all notification scripts to use unified variables and messages with token support.
1 parent 5360aeb commit b9bda86

43 files changed

Lines changed: 1927 additions & 533 deletions

Some content is hidden

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

.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ VORTEX_NOTIFY_EMAIL_RECIPIENTS="webmaster@your-site-domain.example|Webmaster"
250250
#;> NOTIFICATIONS_EMAIL
251251

252252
#;< NOTIFICATIONS_JIRA
253-
# JIRA user email.
254-
VORTEX_NOTIFY_JIRA_USER=user@example.com
253+
# JIRA user email address.
254+
VORTEX_NOTIFY_JIRA_USER_EMAIL=user@example.com
255255
#;> NOTIFICATIONS_JIRA
256256

257257
#;< NOTIFICATIONS_WEBHOOK

.lagoon.yml

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,14 @@ tasks:
2323

2424
#;< !NOTIFICATIONS
2525
- run:
26-
name: Notify about pre-deployment.
26+
name: Send pre-deployment notifications
2727
command: |
28-
if [ -n "$LAGOON_PR_NUMBER" ]; then
29-
export VORTEX_NOTIFY_SHA=${LAGOON_PR_HEAD_SHA#origin/}
30-
export VORTEX_NOTIFY_BRANCH=$LAGOON_PR_HEAD_BRANCH
31-
export VORTEX_NOTIFY_PR_NUMBER="${LAGOON_PR_NUMBER:-}"
32-
else
33-
export VORTEX_NOTIFY_SHA=$LAGOON_GIT_SHA
34-
export VORTEX_NOTIFY_BRANCH=$LAGOON_GIT_BRANCH
35-
fi
36-
VORTEX_NOTIFY_PROJECT=$LAGOON_PROJECT \
37-
VORTEX_NOTIFY_ENVIRONMENT_URL=$LAGOON_ROUTE \
38-
VORTEX_NOTIFY_EVENT=pre_deployment ./scripts/vortex/notify.sh || true
28+
export VORTEX_NOTIFY_PROJECT=$LAGOON_PROJECT
29+
export VORTEX_NOTIFY_ENVIRONMENT_URL=$LAGOON_ROUTE
30+
export VORTEX_NOTIFY_LABEL="$LAGOON_GIT_BRANCH"
31+
[ -n "$LAGOON_PR_NUMBER" ] && export VORTEX_NOTIFY_LABEL="PR-${LAGOON_PR_NUMBER}"
32+
export VORTEX_NOTIFY_EVENT=pre_deployment
33+
./scripts/vortex/notify.sh
3934
service: cli
4035
shell: bash
4136
#;> !NOTIFICATIONS
@@ -93,20 +88,13 @@ tasks:
9388

9489
#;< !NOTIFICATIONS
9590
- run:
96-
name: Send deployment notifications
91+
name: Send post-deployment notifications
9792
command: |
98-
if [ -n "$LAGOON_PR_NUMBER" ]; then
99-
export VORTEX_NOTIFY_SHA=${LAGOON_PR_HEAD_SHA#origin/}
100-
export VORTEX_NOTIFY_BRANCH=$LAGOON_PR_HEAD_BRANCH
101-
export VORTEX_NOTIFY_PR_NUMBER="${LAGOON_PR_NUMBER:-}"
102-
else
103-
export VORTEX_NOTIFY_SHA=$LAGOON_GIT_SHA
104-
export VORTEX_NOTIFY_BRANCH=$LAGOON_GIT_BRANCH
105-
fi
106-
VORTEX_NOTIFY_EVENT=post_deployment \
107-
VORTEX_NOTIFY_PROJECT=$LAGOON_PROJECT \
108-
VORTEX_NOTIFY_ENVIRONMENT_URL=$LAGOON_ROUTE \
109-
./scripts/vortex/notify.sh || true
93+
export VORTEX_NOTIFY_PROJECT=$LAGOON_PROJECT
94+
export VORTEX_NOTIFY_ENVIRONMENT_URL=$LAGOON_ROUTE
95+
export VORTEX_NOTIFY_LABEL="$LAGOON_GIT_BRANCH"
96+
[ -n "$LAGOON_PR_NUMBER" ] && export VORTEX_NOTIFY_LABEL="PR-${LAGOON_PR_NUMBER}"
97+
./scripts/vortex/notify.sh
11098
service: cli
11199
shell: bash
112100
#;> !NOTIFICATIONS

.vortex/CLAUDE.md

Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ UPDATE_FIXTURES=1 composer test # Update test fixtures
109109
- `phpunit/` - Functional tests for complete workflows
110110
- `bats/` - Unit tests for individual shell scripts
111111
- `bats/fixtures/` - Test fixtures and mock data
112+
- `manual/` - Manual integration tests with real external services
112113

113114
**Commands** (from `.vortex/`):
114115

@@ -120,7 +121,7 @@ cd tests && ./vendor/bin/phpunit # Run PHPUnit workflow tests
120121

121122
## Testing Architecture Overview
122123

123-
Vortex uses **three independent testing systems**, each serving different parts of the codebase:
124+
Vortex uses **four independent testing systems**, each serving different parts of the codebase:
124125

125126
### 1. Documentation Tests (.vortex/docs/)
126127

@@ -178,6 +179,27 @@ Vortex uses **three independent testing systems**, each serving different parts
178179
- **PHPUnit Functional**: End-to-end workflow testing
179180
- **BATS Unit**: Individual shell script testing with mocking
180181

182+
### 4. Manual Integration Tests (.vortex/tests/manual/)
183+
184+
**Scope**: Manual verification of notification integrations with real external services
185+
186+
**Technology**: Bash scripts + Real service APIs (Slack, JIRA, etc.)
187+
188+
**What it Tests**:
189+
190+
- Actual notification message formatting in live services
191+
- Real API authentication and authorization
192+
- Service-specific rendering (Slack rich attachments, JIRA ADF)
193+
- End-to-end integration workflows (comment posting, issue transitions)
194+
195+
**Test Types**:
196+
197+
- **Manual Slack Tests**: Branch and PR deployment notifications to real Slack channels
198+
- **Manual JIRA Tests**: Comment creation, transitions, and assignments on real JIRA issues
199+
- **Authentication Verification**: API token validation and permission checks
200+
201+
**Key Difference**: These tests use REAL services (not mocks) and require manual verification of output, complementing automated tests by validating actual service integration and message appearance.
202+
181203
## Template BATS Testing System (.vortex/tests/bats/)
182204

183205
### Overview
@@ -305,6 +327,53 @@ bats tests/bats/unit/notify.bats
305327
./lint.scripts.sh # Shell script linting
306328
```
307329

330+
### 4. Manual Integration Tests (.vortex/tests/manual/)
331+
332+
**Purpose**: Manually verify notification integrations with real external services
333+
334+
**Technology**: Bash scripts that invoke actual notification endpoints
335+
336+
**What to Test**:
337+
338+
- Real Slack webhook message formatting and delivery
339+
- JIRA comment creation, issue transitions, and assignments
340+
- Actual service API authentication and responses
341+
342+
**Available Scripts**:
343+
344+
```bash
345+
# Slack notifications (requires SLACK_WEBHOOK_URL)
346+
export SLACK_WEBHOOK_URL="your-webhook-url"
347+
.vortex/tests/manual/try-slack-notification.sh branch # Test branch deployment
348+
.vortex/tests/manual/try-slack-notification.sh pr # Test PR deployment
349+
350+
# JIRA notifications (requires JIRA_TOKEN)
351+
export JIRA_TOKEN="your-api-token"
352+
export JIRA_USER="your-email@example.com" # Optional (default: alex@drevops.com)
353+
export JIRA_ENDPOINT="https://your-domain.atlassian.net" # Optional (default: https://drevops.atlassian.net)
354+
export JIRA_ISSUE="PROJECT-123" # Optional (default: DEMO-2)
355+
.vortex/tests/manual/try-jira-notification.sh branch # Test branch deployment
356+
.vortex/tests/manual/try-jira-notification.sh pr # Test PR deployment
357+
358+
# JIRA authentication test (requires JIRA_TOKEN)
359+
export JIRA_TOKEN="your-api-token"
360+
.vortex/tests/manual/try-jira-auth.sh # Verify JIRA API access
361+
```
362+
363+
**When to Use**:
364+
365+
- During notification script refactoring to verify real output formatting
366+
- Before committing major notification changes
367+
- To debug integration issues with external services
368+
- After API updates to test compatibility
369+
370+
**Important Notes**:
371+
372+
- ⚠️ These send REAL notifications to live services (use test channels/projects)
373+
- 🔐 Never commit credentials to version control
374+
- 📚 See `.vortex/tests/manual/README.md` for comprehensive documentation
375+
- 🧪 Manual tests complement automated BATS tests (real services vs mocks)
376+
308377
## Installer Fixture System
309378

310379
### Architecture
@@ -710,6 +779,11 @@ Each system:
710779
├── phpunit/ # Workflow functional tests
711780
│ ├── Functional/ # End-to-end workflow tests
712781
│ └── Traits/ # Shared test functionality
782+
├── manual/ # Manual integration tests
783+
│ ├── try-slack-notification.sh # Slack webhook testing
784+
│ ├── try-jira-notification.sh # JIRA API testing
785+
│ ├── try-jira-auth.sh # JIRA authentication testing
786+
│ └── README.md # Manual testing documentation
713787
├── composer.json # PHP dependencies for template tests
714788
└── [test scripts] # Individual test executables
715789
```
@@ -769,6 +843,14 @@ Each system:
769843
- Follow prefix rules: all-or-nothing for output assertions
770844
- Prefer named arguments for complex parameters
771845
846+
**Manual Integration Tests**:
847+
848+
- Use manual scripts in `.vortex/tests/manual/` when refactoring notification integrations
849+
- Always test with real services before updating automated BATS tests
850+
- Verify message formatting in actual Slack/JIRA UI, not just script output
851+
- Keep credentials in environment variables, never commit to version control
852+
- Use test channels/projects to avoid cluttering production systems
853+
772854
## System-Specific Troubleshooting
773855
774856
### 1. Documentation Issues (.vortex/docs/)
@@ -832,6 +914,41 @@ UPDATE_FIXTURES=1 ./vendor/bin/phpunit --filter 'testInstall.*"scenario_name"'
832914
- **PHPUnit workflow tests**: Slower (integration level, ~minutes)
833915
- **Installer tests**: Slowest (full installation simulation, ~minutes)
834916
917+
### 4. Manual Integration Test Issues (.vortex/tests/manual/)
918+
919+
**Missing Credentials**:
920+
921+
```bash
922+
# Verify environment variables are set
923+
echo $SLACK_WEBHOOK_URL
924+
echo $JIRA_TOKEN
925+
926+
# If not set, export them
927+
export SLACK_WEBHOOK_URL="your-webhook-url"
928+
export JIRA_TOKEN="your-api-token"
929+
```
930+
931+
**Authentication Failures**:
932+
933+
- Use try-jira-auth.sh to diagnose JIRA authentication issues
934+
- Verify API token has required permissions (comment, transition, assign)
935+
- Check endpoint URL format (https://domain.atlassian.net)
936+
- Ensure token hasn't expired or been revoked
937+
938+
**Message Format Issues**:
939+
940+
- Compare actual output in Slack/JIRA with expected format
941+
- Check for JSON encoding issues in JIRA ADF format
942+
- Verify URL formatting (links vs inline cards)
943+
- Test both branch and PR scenarios to catch conditional logic issues
944+
945+
**Integration Failures**:
946+
947+
- Confirm services are accessible (not blocked by firewall/VPN)
948+
- Verify webhook URLs are valid and not revoked
949+
- Check issue keys exist and are accessible by user
950+
- Review service-specific rate limits or quotas
951+
835952
## Shell Script Development Patterns
836953

837954
### Script Structure Best Practices

0 commit comments

Comments
 (0)