Skip to content

Commit cc7eeeb

Browse files
committed
use custom properties key
1 parent 7b79bfa commit cc7eeeb

File tree

5 files changed

+58
-38
lines changed

5 files changed

+58
-38
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525

2626
- name: Run tests
2727
run: npm test
28+
29+
- name: Validate build
30+
run: npm run build
2831

2932
# Integration test (requires secrets - only run on main branch)
3033
integration-test:
@@ -33,18 +36,6 @@ jobs:
3336
steps:
3437
- uses: actions/checkout@v4
3538

36-
- name: Setup Node.js
37-
uses: actions/setup-node@v4
38-
with:
39-
node-version: '20'
40-
cache: 'npm'
41-
42-
- name: Install dependencies
43-
run: npm ci
44-
45-
- name: Build action
46-
run: npm run build
47-
4839
- name: Test the action
4940
uses: ./
5041
with:

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
project_key: ${{ vars.LAUNCHDARKLY_PROJECT_KEY }}
6060
days_ahead: '14'
6161
include_past_due: 'true'
62-
custom_property_name: 'flag-expiry-date'
62+
custom_property_key: 'flag.expiry.date'
6363

6464
- name: Comment on PR if flags are expiring
6565
if: ${{ fromJSON(steps.audit.outputs.total_count) > 0 }}
@@ -160,7 +160,7 @@ jobs:
160160
| `project_key` | LaunchDarkly project key | Yes | |
161161
| `days_ahead` | Number of days ahead to check for expiring flags | No | `7` |
162162
| `include_past_due` | Include flags that are past their expiry date | No | `true` |
163-
| `custom_property_name` | Name of the custom property containing the expiry date | No | `flag-expiry-date` |
163+
| `custom_property_key` | Name of the custom property containing the expiry date | No | `flag.expiry.date` |
164164

165165
## Outputs
166166

@@ -179,7 +179,7 @@ Each flag object in the output arrays contains:
179179
"name": "My Feature Flag",
180180
"key": "my-feature-flag",
181181
"expiryDate": "2024-03-15",
182-
"customPropertyName": "flag-expiry-date",
182+
"custom_property_key": "flag.expiry.date",
183183
"customPropertyValue": "03/15/2024",
184184
"daysUntilExpiry": 5
185185
}
@@ -195,8 +195,8 @@ To use this action, your feature flags must have a custom property containing an
195195
2. Go to the flag's **Settings** tab
196196
3. Click **+ Add custom property**
197197
4. Create a new property with:
198-
- **Name**: `flag-expiry-date` (or your preferred name)
199-
- **Key**: `flag-expiry-date` (should match the action's `custom_property_name` input)
198+
- **Name**: `flag-expiry-date` (or your preferred name)
199+
- **Key**: `flag.expiry.date` (should match the action's `custom_property_key` input)
200200
- **Values**: Enter the expiry date in MM/DD/YYYY format (e.g., `03/15/2024`)
201201

202202
### Supported Date Formats

action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ inputs:
1717
description: 'Include flags that are past due (default: true)'
1818
required: false
1919
default: 'true'
20-
custom_property_name:
21-
description: 'Name of the custom property containing expiry date (default: flag-expiry-date)'
20+
custom_property_key:
21+
description: 'Name of the custom property containing expiry date (default: flag.expiry.date)'
2222
required: false
23-
default: 'flag-expiry-date'
23+
default: 'flag.expiry.date'
2424

2525
outputs:
2626
expiring_flags:

index.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ async function run() {
1111
const daysAheadInput = core.getInput('days_ahead') || '7';
1212
const daysAhead = parseInt(daysAheadInput, 10);
1313
const includePastDue = core.getInput('include_past_due') === 'true';
14-
const customPropertyName = core.getInput('custom_property_name') || 'flag-expiry-date';
14+
const customPropertyKey = core.getInput('custom_property_key') || 'flag.expiry.date';
1515

1616
// Validate inputs
1717
if (!apiKey.trim()) {
@@ -42,6 +42,35 @@ async function run() {
4242
// Filter flags with expiry dates
4343
const flagsWithExpiryDates = filterFlagsWithExpiryDates(flags, customPropertyName);
4444
core.info(`Found ${flagsWithExpiryDates.length} flags with expiry dates`);
45+
46+
// Debug: Show custom properties structure for troubleshooting
47+
if (flagsWithExpiryDates.length === 0) {
48+
core.info('🔍 No flags found with expiry dates. Checking custom properties structure...');
49+
50+
// Look for the specific flag from the screenshot
51+
const darkModeFlag = flags.find(flag => flag.key === 'ui.DarkMode');
52+
if (darkModeFlag) {
53+
core.info(`Found ui.DarkMode flag. Custom properties: ${JSON.stringify(darkModeFlag.customProperties)}`);
54+
} else {
55+
core.info('ui.DarkMode flag not found in API response');
56+
}
57+
58+
// Show sample of flags with custom properties
59+
flags.slice(0, 5).forEach(flag => {
60+
if (flag.customProperties && Object.keys(flag.customProperties).length > 0) {
61+
core.info(`Flag "${flag.name}" (${flag.key}) has custom properties: ${JSON.stringify(flag.customProperties)}`);
62+
}
63+
});
64+
65+
// Show all unique custom property keys found across all flags
66+
const allCustomPropertyKeys = new Set();
67+
flags.forEach(flag => {
68+
if (flag.customProperties) {
69+
Object.keys(flag.customProperties).forEach(key => allCustomPropertyKeys.add(key));
70+
}
71+
});
72+
core.info(`All custom property keys found: [${Array.from(allCustomPropertyKeys).join(', ')}]`);
73+
}
4574

4675
// Calculate date ranges
4776
const today = new Date();

test/index.test.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ describe('filterFlagsWithExpiryDates', () => {
7373
name: 'Flag with expiry',
7474
key: 'flag-with-expiry',
7575
customProperties: {
76-
'flag-expiry-date': {
77-
name: 'flag-expiry-date',
76+
'flag.expiry.date': {
77+
name: 'flag.expiry.date',
7878
value: ['03/15/2024']
7979
}
8080
}
@@ -98,8 +98,8 @@ describe('filterFlagsWithExpiryDates', () => {
9898
name: 'Flag with empty expiry value',
9999
key: 'flag-empty-expiry',
100100
customProperties: {
101-
'flag-expiry-date': {
102-
name: 'flag-expiry-date',
101+
'flag.expiry.date': {
102+
name: 'flag.expiry.date',
103103
value: []
104104
}
105105
}
@@ -111,19 +111,19 @@ describe('filterFlagsWithExpiryDates', () => {
111111
];
112112

113113
test('should filter flags with expiry dates correctly', () => {
114-
const result = filterFlagsWithExpiryDates(mockFlags, 'flag-expiry-date');
114+
const result = filterFlagsWithExpiryDates(mockFlags, 'flag.expiry.date');
115115
expect(result).toHaveLength(1);
116116
expect(result[0].name).toBe('Flag with expiry');
117117
});
118118

119119
test('should return empty array when no flags have expiry dates', () => {
120120
const flagsWithoutExpiry = mockFlags.slice(1); // Remove the flag with expiry
121-
const result = filterFlagsWithExpiryDates(flagsWithoutExpiry, 'flag-expiry-date');
121+
const result = filterFlagsWithExpiryDates(flagsWithoutExpiry, 'flag.expiry.date');
122122
expect(result).toHaveLength(0);
123123
});
124124

125125
test('should handle empty flags array', () => {
126-
const result = filterFlagsWithExpiryDates([], 'flag-expiry-date');
126+
const result = filterFlagsWithExpiryDates([], 'flag.expiry.date');
127127
expect(result).toHaveLength(0);
128128
});
129129

@@ -300,7 +300,7 @@ describe('run() integration tests', () => {
300300
'project_key': 'test-project',
301301
'days_ahead': '7',
302302
'include_past_due': 'true',
303-
'custom_property_name': 'flag-expiry-date'
303+
'custom_property_key': 'flag.expiry.date'
304304
};
305305
return inputs[name];
306306
});
@@ -318,8 +318,8 @@ describe('run() integration tests', () => {
318318
name: 'Feature Flag 1',
319319
key: 'feature-flag-1',
320320
customProperties: {
321-
'flag-expiry-date': {
322-
name: 'flag-expiry-date',
321+
'flag.expiry.date': {
322+
name: 'flag.expiry.date',
323323
value: [`${(tomorrow.getMonth() + 1).toString().padStart(2, '0')}/${tomorrow.getDate().toString().padStart(2, '0')}/${tomorrow.getFullYear()}`]
324324
}
325325
}
@@ -328,8 +328,8 @@ describe('run() integration tests', () => {
328328
name: 'Feature Flag 2',
329329
key: 'feature-flag-2',
330330
customProperties: {
331-
'flag-expiry-date': {
332-
name: 'flag-expiry-date',
331+
'flag.expiry.date': {
332+
name: 'flag.expiry.date',
333333
value: [`${(nextWeek.getMonth() + 1).toString().padStart(2, '0')}/${nextWeek.getDate().toString().padStart(2, '0')}/${nextWeek.getFullYear()}`]
334334
}
335335
}
@@ -462,7 +462,7 @@ describe('run() integration tests', () => {
462462
const inputs = {
463463
'launchdarkly_api_key': 'mock-api-key',
464464
'project_key': 'test-project',
465-
'custom_property_name': 'custom-expiry-field'
465+
'custom_property_key': 'custom.expiry.field'
466466
};
467467
return inputs[name];
468468
});
@@ -515,8 +515,8 @@ describe('run() integration tests', () => {
515515
name: 'Flag with Invalid Date',
516516
key: 'flag-invalid-date',
517517
customProperties: {
518-
'flag-expiry-date': {
519-
name: 'flag-expiry-date',
518+
'flag.expiry.date': {
519+
name: 'flag.expiry.date',
520520
value: ['invalid-date-format']
521521
}
522522
}
@@ -525,8 +525,8 @@ describe('run() integration tests', () => {
525525
name: 'Flag with Valid Date',
526526
key: 'flag-valid-date',
527527
customProperties: {
528-
'flag-expiry-date': {
529-
name: 'flag-expiry-date',
528+
'flag.expiry.date': {
529+
name: 'flag.expiry.date',
530530
value: [`${(validDate.getMonth() + 1).toString().padStart(2, '0')}/${validDate.getDate().toString().padStart(2, '0')}/${validDate.getFullYear()}`]
531531
}
532532
}

0 commit comments

Comments
 (0)