Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 141 additions & 0 deletions .github/workflows/config-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: Alloy Mapped Fields Checker

on:
push:
branches: [ main ]
paths:
- 'pkg/**/*.go'

jobs:
check-config:
runs-on: ubuntu-latest
permissions:
issues: write
contents: read

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: false # Disable caching to avoid extraction conflicts
check-latest: true

- name: Run alloy field checker
id: field-checker
run: |
# First compile the checker to ensure it builds
cd tools/alloy-field-checker
go build -o field-checker
if [ $? -ne 0 ]; then
echo "Failed to build field checker"
exit 1
fi

# Move back to workspace root and run the checker
cd ../..
if [ ! -d "pkg" ]; then
echo "pkg directory not found in $(pwd)"
ls -la
exit 1
fi

tools/alloy-field-checker/field-checker 2>&1 | tee output.txt
if [ ${PIPESTATUS[0]} -ne 0 ]; then
# Create a normalized version of the output (remove line numbers which can change)
grep "unmapped fields:" output.txt > /dev/null && {
echo "has_unmapped=true" >> $GITHUB_OUTPUT
echo "unmapped_fields<<EOF" >> $GITHUB_OUTPUT
# Extract just the field names and struct names, ignore line numbers
grep -o "[a-zA-Z0-9]\+\.[a-zA-Z0-9]\+ (tag: [^)]\+)" output.txt | sort > normalized_output.txt
cat normalized_output.txt >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
} || {
echo "has_unmapped=false" >> $GITHUB_OUTPUT
}
else
echo "has_unmapped=false" >> $GITHUB_OUTPUT
fi

- name: Find existing issues
if: steps.field-checker.outputs.has_unmapped == 'true'
uses: actions/github-script@v7
id: find-issue
with:
script: |
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: []
});
const existingIssue = issues.data.find(issue =>
issue.title === 'Map missing Beyla options in Alloy component'
);
return existingIssue ? existingIssue.number : 0;
result-encoding: string

- name: Manage issue
if: steps.field-checker.outputs.has_unmapped == 'true'
uses: actions/github-script@v7
with:
script: |
const issueNumber = parseInt('${{ steps.find-issue.outputs.result }}');
const issueBody = `Unmapped configuration fields were detected in Beyla's Alloy component:

\`\`\`
${process.env.UNMAPPED_FIELDS}
\`\`\`

Please ensure all configuration fields are properly mapped in the Alloy configuration.

This issue was automatically generated by the config-checker workflow.`;

if (issueNumber > 0) {
// Update existing issue
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
body: issueBody
});
} else {
// Create new issue
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'Map missing Beyla options in Alloy component',
body: issueBody,
assignee: context.repo.owner
});
}
env:
UNMAPPED_FIELDS: ${{ steps.field-checker.outputs.unmapped_fields }}

- name: Close issue if no unmapped fields
if: steps.field-checker.outputs.has_unmapped == 'false'
uses: actions/github-script@v7
with:
script: |
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: []
});

const existingIssue = issues.data.find(issue =>
issue.title === 'Map missing Beyla options in Alloy component'
);

if (existingIssue) {
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: existingIssue.number,
state: 'closed',
state_reason: 'completed'
});
}
Loading
Loading