Skip to content

Commit ec36dd3

Browse files
authored
chore: Cleanup (#7)
* chore: Cleanup * chore: Add temp tag * Add test .fleetControl for CI testing * chore: Use testing tag
1 parent 6db758f commit ec36dd3

File tree

17 files changed

+631
-896
lines changed

17 files changed

+631
-896
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
namespace: newrelic
2+
name: com.newrelic.my_agent
3+
version: 0.1.0
4+
variables:
5+
k8s:
6+
version:
7+
description: "My Agent init container version"
8+
type: string
9+
default: "latest"
10+
required: false
11+
podLabelSelector:
12+
description: "Pod label selector"
13+
type: yaml
14+
default: { }
15+
required: false
16+
namespaceLabelSelector:
17+
description: "Namespace label selector"
18+
type: yaml
19+
default: { }
20+
required: false
21+
env:
22+
description: "environment variables to pass to My agent"
23+
type: yaml
24+
default: [ ]
25+
required: false
26+
health_env:
27+
description: "environment variables to pass to health sidecar"
28+
type: yaml
29+
default: [ ]
30+
required: false
31+
health_version:
32+
description: "health sidecar image version"
33+
type: string
34+
default: "latest"
35+
required: false
36+
deployment:
37+
k8s:
38+
health:
39+
interval: 30s
40+
initial_delay: 30s
41+
objects:
42+
instrumentation:
43+
apiVersion: newrelic.com/v1beta1
44+
kind: Instrumentation
45+
metadata:
46+
name: ${nr-sub:agent_id}
47+
namespace: ${nr-ac:namespace_agents}
48+
spec:
49+
agent:
50+
language: My
51+
image: newrelic/newrelic-myagent-init:${nr-var:version}
52+
env: ${nr-var:env}
53+
healthAgent:
54+
image: newrelic/k8s-apm-agent-health-sidecar:${nr-var:health_version}
55+
env: ${nr-var:health_env}
56+
podLabelSelector: ${nr-var:podLabelSelector}
57+
namespaceLabelSelector: ${nr-var:namespaceLabelSelector}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
configurationDefinitions:
2+
- platform: kubernetes
3+
description: myagent agent configuration, provided by the user
4+
type: myagent-config
5+
version: 1.0.0
6+
format: json
7+
schema: ./schemas/myagent-config.json
8+
- platform: host
9+
description: myagent agent configuration, provided by the user
10+
type: myagent-config
11+
version: 1.0.0
12+
format: json
13+
schema: ./schemas/myagent-config.json
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://newrelic.com/schemas/myagent-configuration.json",
4+
"title": "New Relic My Agent Configuration Schema",
5+
"version": "1.0.0",
6+
"description": "Schema for New Relic My Agent configuration",
7+
"type": "object",
8+
"properties": {
9+
"common": {
10+
"type": "object",
11+
"description": "Common configuration settings shared across all environments",
12+
"properties": {
13+
"license_key": {
14+
"type": "string",
15+
"minLength": 1,
16+
"description": "New Relic license key",
17+
"examples": ["<%= license_key %>", "your_license_key_here"]
18+
},
19+
"agent_enabled": {
20+
"type": "boolean",
21+
"description": "Enable or disable the agent",
22+
"default": true
23+
},
24+
"app_name": {
25+
"type": "string",
26+
"minLength": 1,
27+
"description": "Application name as it will appear in New Relic",
28+
"examples": ["My Application"]
29+
},
30+
"log_level": {
31+
"type": "string",
32+
"enum": ["debug", "info", "warn", "error"],
33+
"description": "Log level for the agent"
34+
},
35+
"host": {
36+
"type": "string",
37+
"description": "New Relic collector host"
38+
},
39+
"labels": {
40+
"type": "string",
41+
"description": "Semicolon-separated list of key:value labels",
42+
"examples": ["Environment:Production;Team:Platform"]
43+
}
44+
},
45+
"required": ["license_key", "app_name"],
46+
"additionalProperties": false
47+
},
48+
"development": {
49+
"type": "object",
50+
"description": "Development environment specific configuration",
51+
"additionalProperties": true
52+
},
53+
"test": {
54+
"type": "object",
55+
"description": "Test environment specific configuration",
56+
"additionalProperties": true
57+
},
58+
"production": {
59+
"type": "object",
60+
"description": "Production environment specific configuration",
61+
"additionalProperties": true
62+
},
63+
"staging": {
64+
"type": "object",
65+
"description": "Staging environment specific configuration",
66+
"additionalProperties": true
67+
}
68+
},
69+
"required": ["common"],
70+
"additionalProperties": {
71+
"type": "object",
72+
"description": "Custom environment configuration",
73+
"additionalProperties": true
74+
}
75+
}

.github/workflows/test_action.yml

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,73 @@ jobs:
1313
name: Test Agent Repository Flow
1414
runs-on: ubuntu-latest
1515
steps:
16-
- name: Checkout
17-
uses: actions/checkout@v3
18-
19-
- name: Setup test files
20-
run: ln -s integration-test/agent-flow/.fleetControl .fleetControl
16+
- name: Checkout action repository
17+
uses: actions/checkout@v4
2118

2219
- name: Run Agent Metadata Action (with configs)
2320
uses: ./
2421
with:
2522
agent-type: 'myagent'
26-
version: '1.0.0'
23+
version: '0.0.0'
2724
cache: false
2825

2926
test-docs-flow:
3027
name: Test Documentation Flow (MDX Parsing)
3128
runs-on: ubuntu-latest
3229
steps:
33-
- name: Checkout
34-
uses: actions/checkout@v3
30+
- name: Checkout action repository
31+
uses: actions/checkout@v4
32+
33+
- name: Setup Go
34+
uses: actions/setup-go@v4
3535
with:
36-
fetch-depth: 0 # Fetch all history for git diff
36+
go-version-file: 'go.mod'
37+
cache: true
3738

38-
- name: Create mock PR event
39+
- name: Build action
40+
run: go build -o agent-metadata-action ./cmd/agent-metadata-action
41+
42+
- name: Setup temporary workspace with MDX files
3943
run: |
40-
BASE_SHA=$(git rev-parse origin/main 2>/dev/null || git rev-parse main)
44+
# Create a temporary directory for the test workspace
45+
TEMP_WORKSPACE="${{ runner.temp }}/test-workspace"
46+
mkdir -p "$TEMP_WORKSPACE"
47+
48+
# Initialize git repo in temp workspace
49+
cd "$TEMP_WORKSPACE"
50+
git init
51+
git config user.email "[email protected]"
52+
git config user.name "Test User"
53+
54+
# Create base commit (without MDX files)
55+
mkdir -p src/content/docs/release-notes
56+
git commit --allow-empty -m "Initial commit"
57+
BASE_SHA=$(git rev-parse HEAD)
58+
59+
# Copy integration-test MDX files and commit them
60+
cp -r "${{ github.workspace }}/integration-test/docs-flow/"* .
61+
git add .
62+
git commit -m "Add release notes"
63+
HEAD_SHA=$(git rev-parse HEAD)
64+
65+
# Create mock PR event
4166
cat > /tmp/pr-event.json <<EOF
4267
{
4368
"pull_request": {
4469
"base": {"sha": "${BASE_SHA}"},
45-
"head": {"sha": "${{ github.sha }}"}
70+
"head": {"sha": "${HEAD_SHA}"}
4671
}
4772
}
4873
EOF
4974
75+
echo "BASE_SHA: $BASE_SHA"
76+
echo "HEAD_SHA: $HEAD_SHA"
77+
echo "TEMP_WORKSPACE=$TEMP_WORKSPACE" >> $GITHUB_ENV
78+
5079
- name: Run Agent Metadata Action (metadata from MDX)
51-
uses: ./
52-
with:
53-
agent-type: 'myagent'
54-
version: '1.3.0'
55-
cache: false
5680
env:
5781
GITHUB_EVENT_PATH: '/tmp/pr-event.json'
82+
GITHUB_WORKSPACE: ${{ env.TEMP_WORKSPACE }}
83+
run: |
84+
cd ${{ env.TEMP_WORKSPACE }}
85+
${{ github.workspace }}/agent-metadata-action

0 commit comments

Comments
 (0)