Skip to content

Commit 54ed5d8

Browse files
mvicknrclaude
andauthored
chore: More CDD updates (#5)
* chore: More CDD updates Co-Authored-By: Claude <noreply@anthropic.com> * chore: Fix mistakes * chore: Update automated test to include all inputs * chore: Fix Claude issues * chore: Moving files * chore: Fixing path * chore: Updating so test files can be found * chore: Removing docs test for now * chore: Remove extra input params - get from files instead * fix: Allow .fleetControl to be missing in docs case * fix: Fixes for the 2 use cases --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9279116 commit 54ed5d8

File tree

28 files changed

+1586
-531
lines changed

28 files changed

+1586
-531
lines changed

.github/workflows/test_action.yml

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,49 @@ on:
99
- '**'
1010

1111
jobs:
12-
action-test:
12+
test-agent-flow:
13+
name: Test Agent Repository Flow
1314
runs-on: ubuntu-latest
1415
steps:
1516
- name: Checkout
1617
uses: actions/checkout@v3
1718

18-
- name: Run Agent Metadata Action
19+
- name: Setup test files
20+
run: ln -s integration-test/agent-flow/.fleetControl .fleetControl
21+
22+
- name: Run Agent Metadata Action (with configs)
1923
uses: ./
2024
with:
2125
agent-type: 'myagent'
2226
version: '1.0.0'
2327
cache: false
28+
29+
test-docs-flow:
30+
name: Test Documentation Flow (MDX Parsing)
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v3
35+
with:
36+
fetch-depth: 0 # Fetch all history for git diff
37+
38+
- name: Create mock PR event
39+
run: |
40+
BASE_SHA=$(git rev-parse origin/main 2>/dev/null || git rev-parse main)
41+
cat > /tmp/pr-event.json <<EOF
42+
{
43+
"pull_request": {
44+
"base": {"sha": "${BASE_SHA}"},
45+
"head": {"sha": "${{ github.sha }}"}
46+
}
47+
}
48+
EOF
49+
50+
- name: Run Agent Metadata Action (metadata from MDX)
51+
uses: ./
52+
with:
53+
agent-type: 'myagent'
54+
version: '1.3.0'
55+
cache: false
56+
env:
57+
GITHUB_EVENT_PATH: '/tmp/pr-event.json'

CLAUDE.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export GITHUB_WORKSPACE=/path/to/repo
7070

7171
**cmd/agent-metadata-action/main.go**: Application entry point
7272
- Loads workspace path via `config.LoadEnv()` (returns empty string if not set)
73-
- Loads metadata via `config.LoadMetadata()` (version, features, bugs, security)
73+
- Loads metadata via `config.LoadMetadata()` (version, features, bugs, security, deprecations, supportedOperatingSystems, eol)
7474
- If workspace is set (agent repo flow):
7575
- Reads configuration definitions via `config.ReadConfigurationDefinitions()`
7676
- Reads agent control via `config.LoadAndEncodeAgentControl()`
@@ -96,13 +96,16 @@ export GITHUB_WORKSPACE=/path/to/repo
9696
3. **metadata.go**: Version and changelog metadata
9797
- `LoadMetadata()`: Loads version and changelog info from environment variables
9898
- `LoadVersion()`: Reads `INPUT_VERSION` with validation (format: X.Y.Z)
99-
- `parseCommaSeparated()`: Parses comma-separated lists (features, bugs, security)
99+
- `parseCommaSeparated()`: Parses comma-separated lists (features, bugs, security, deprecations, supportedOperatingSystems)
100+
- Reads `INPUT_EOL` for end-of-life date
100101

101102
**internal/models**: Data structures with validation
102-
- `ConfigurationDefinition`: Configuration with 8 required fields (validated via custom `UnmarshalYAML`)
103-
- Fields: slug, name, version, platform, description, type, format, schema
103+
- `ConfigurationDefinition`: Configuration with 6 required fields (validated via custom `UnmarshalYAML`)
104+
- Fields: version, platform, description, type, format, schema
104105
- Custom unmarshaler validates all fields are present before accepting
105106
- `Metadata`: Version and changelog info (version required, validated via custom `UnmarshalYAML`)
107+
- Required: version
108+
- Optional: features, bugs, security, deprecations, supportedOperatingSystems, eol
106109
- `AgentControl`: Agent control content (platform and content required, validated via custom `UnmarshalJSON`)
107110
- `ConfigFile`: Root YAML structure containing `configurationDefinitions` array
108111
- `AgentMetadata`: Complete metadata structure (configurationDefinitions + metadata + agentControl)
@@ -160,11 +163,11 @@ The action expects to run after `actions/checkout` which sets the `GITHUB_WORKSP
160163
- Multiple layers of validation prevent escaping the designated directory
161164

162165
### Validation
163-
- **All configuration fields are required**: name, slug, version, platform, description, type, format, schema
166+
- **All configuration fields are required**: version, platform, description, type, format, schema
164167
- **Version format validation**: Must match `X.Y.Z` (three numeric components)
165168
- **Empty array rejection**: `configurationDefinitions` cannot be an empty array
166169
- **Validation timing**: All validation happens during YAML/JSON unmarshaling via custom unmarshalers
167-
- **Error messages**: Clear, contextual errors (e.g., "platform is required for config 'MyConfig'")
170+
- **Error messages**: Clear, contextual errors (e.g., "platform is required for config with type 'mytype' and version '1.0.0'")
168171

169172
### Schema Handling
170173
- Schema files are automatically loaded and **base64-encoded**

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ Add this action to your workflow after checking out your repository:
1818
1919
## Usage
2020
21-
This action reads the `.fleetControl/configurationDefinitions.yml` file from your repository and outputs the configuration definitions. The action expects the file to be present after the repository has been checked out.
21+
This action reads the `.fleetControl/configurationDefinitions.yml` file from your repository and saves the agent information in New Relic.
22+
The action expects the file to be present after the repository has been checked out. If you do not want to use this action,
23+
you can call New Relic directly to add the agent information.
2224

2325
### Example Workflow For Releasing a New Agent Version
2426

@@ -40,7 +42,8 @@ jobs:
4042
- name: Read agent metadata
4143
uses: newrelic/agent-metadata-action@v1
4244
with:
43-
version: 1.0.0 # only required if different from ref tag
45+
agent-type: dotnet # Required: The type of agent (e.g., dotnet, java, python)
46+
version: 1.0.0 # Required
4447
cache: true # Optional: Enable Go build cache (default: true)
4548
```
4649

@@ -62,7 +65,14 @@ jobs:
6265
- name: Read agent metadata
6366
uses: newrelic/agent-metadata-action@v1
6467
with:
65-
version: 1.0.0 # required in the docs case
68+
agent-type: java # Required: The type of agent (e.g., dotnet, java, python)
69+
version: 1.0.0 # required
70+
features: feature1,feature2 # Optional: Comma-separated list of features
71+
bugs: bug-123,bug-456 # Optional: Comma-separated list of bug fixes
72+
security: CVE-2024-1234 # Optional: Comma-separated list of security fixes
73+
deprecations: deprecated-feature1 # Optional: Comma-separated list of deprecations
74+
supportedOperatingSystems: linux,windows,darwin # Optional: Comma-separated list of supported OSes
75+
eol: 2025-12-31 # Optional: End of life date
6676
cache: true # Optional: Enable Go build cache (default: true)
6777
```
6878

@@ -72,17 +82,15 @@ The action expects a YAML file at `.fleetControl/configurationDefinitions.yml` w
7282

7383
```yaml
7484
configurationDefinitions:
75-
- name: "Configuration Name"
76-
slug: "config-slug"
77-
platform: "kubernetes" # or "host"
85+
- platform: "kubernetes" # or "host"
7886
description: "Description of the configuration"
7987
type: "config-type"
8088
version: "1.0.0"
8189
format: "json"
8290
schema: "./schemas/config-schema.json"
8391
```
8492

85-
**All fields are required.** The action validates each configuration entry and will fail with a clear error message if any required field is missing.
93+
**All fields are required.** The action validates each configuration entry and will fail with a clear error message if any required field is missing (version, platform, description, type, format, schema).
8694

8795
**Schema files** are automatically base64-encoded and embedded in the output. Schema paths must be relative to the `.fleetControl` directory and cannot use directory traversal (`..`) for security.
8896

action.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,6 @@ inputs:
99
description: 'Agent version in strict semver format MAJOR.MINOR.PATCH (ex. 1.2.3)'
1010
required: true
1111
default: ''
12-
features:
13-
description: 'Comma-separated list of features to include in the agent (ex. feature1,feature2)'
14-
required: false
15-
default: ''
16-
bugs:
17-
description: 'Comma-separated list of bugs to exclude from the agent (ex. bug1,bug2)'
18-
required: false
19-
default: ''
20-
security:
21-
description: 'Comma-separated list of security fixes (ex. fix1,fix2)'
22-
required: false
23-
default: ''
2412
cache:
2513
description: 'Enable Go build cache'
2614
required: false
@@ -40,9 +28,6 @@ runs:
4028
env:
4129
INPUT_AGENT_TYPE: ${{ inputs.agent-type }}
4230
INPUT_VERSION: ${{ inputs.version }}
43-
INPUT_FEATURES: ${{ inputs.features }}
44-
INPUT_BUGS: ${{ inputs.bugs }}
45-
INPUT_SECURITY: ${{ inputs.security }}
4631
run: |
4732
set -e
4833
cd ${{ github.action_path }}

cmd/agent-metadata-action/main.go

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,53 @@ import (
1010
)
1111

1212
func main() {
13-
// Validate agent type here for now - may move once there is code to call InstrumentationMetadata service
14-
if err := validateAgentType(); err != nil {
13+
if err := run(); err != nil {
1514
fmt.Fprintf(os.Stderr, "::error::%v\n", err)
1615
os.Exit(1)
1716
}
17+
}
18+
19+
func run() error {
20+
// Validate agent type here for now - may move once there is code to call InstrumentationMetadata service
21+
if err := validateAgentType(); err != nil {
22+
return err
23+
}
1824

19-
workspace := config.LoadEnv()
25+
workspace := config.GetWorkspace()
26+
27+
// Workspace is required
28+
if workspace == "" {
29+
return fmt.Errorf("Error: GITHUB_WORKSPACE is required but not set")
30+
}
31+
32+
// Validate workspace directory exists
33+
if _, err := os.Stat(workspace); err != nil {
34+
return fmt.Errorf("Error reading configs: workspace directory does not exist: %s", workspace)
35+
}
2036

2137
metadata, err := config.LoadMetadata()
2238
if err != nil {
23-
fmt.Fprintf(os.Stderr, "::error::Error loading metadata: %v\n", err)
24-
os.Exit(1)
39+
return fmt.Errorf("Error loading metadata: %w", err)
2540
}
2641
fmt.Printf("::debug::Agent version: %s\n", metadata.Version)
2742
fmt.Printf("::debug::Features: %v\n", metadata.Features)
2843
fmt.Printf("::debug::Bugs: %v\n", metadata.Bugs)
2944
fmt.Printf("::debug::Security: %v\n", metadata.Security)
3045

31-
// If GITHUB_WORKSPACE is set, read configuration definitions (agent repo flow)
32-
if workspace != "" {
46+
// Check if .fleetControl directory exists to determine flow (agent repo vs docs)
47+
fleetControlPath := workspace + "/.fleetControl"
48+
if _, err := os.Stat(fleetControlPath); err == nil {
49+
// Scenario 1: Agent repo flow - .fleetControl directory exists
3350
fmt.Printf("::debug::Reading config from workspace: %s\n", workspace)
3451

3552
configs, err := config.ReadConfigurationDefinitions(workspace)
3653
if err != nil {
37-
fmt.Fprintf(os.Stderr, "::error::Error reading configs: %v\n", err)
38-
os.Exit(1)
54+
return fmt.Errorf("Error reading configs: %w", err)
3955
}
4056

4157
agentControl, err := config.LoadAndEncodeAgentControl(workspace)
4258
if err != nil {
43-
fmt.Fprintf(os.Stderr, "::error::Error reading agent control: %v\n", err)
44-
os.Exit(1)
59+
return fmt.Errorf("Error reading agent control: %w", err)
4560
}
4661

4762
fmt.Println("::notice::Successfully read configs file")
@@ -56,11 +71,13 @@ func main() {
5671
// @todo use the AgentMetadata object to call the InstrumentationMetadata service to add/update the agent in NGEP
5772
printJSON("Agent Metadata", agentMetadata)
5873
} else {
59-
// Docs workflow: only output metadata
60-
fmt.Println("::notice::Running in metadata-only mode (no workspace provided)")
74+
// Scenario 2: Docs workflow
75+
fmt.Println("::notice::Running in metadata-only mode (.fleetControl not found, using MDX files)")
6176
// @todo use the INPUT_AGENT_TYPE along with the metadata to call the InstrumentationMetadata service for updating the agent in NGEP with extra metadata
6277
printJSON("Metadata", metadata)
6378
}
79+
80+
return nil
6481
}
6582

6683
func validateAgentType() error {

0 commit comments

Comments
 (0)