Skip to content

Commit f4eaf54

Browse files
committed
feat(ci-cd): Move refactored cake build project and workflows from master (AWS v4 updates) branch to sdkv3-lts branch
1 parent 9fa4e71 commit f4eaf54

26 files changed

+1857
-507
lines changed
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
# Update Test Results Badge Action
2+
3+
A reusable GitHub Action that updates test result badges by uploading test data to GitHub Gist files and displaying badge URLs for README files.
4+
5+
## Purpose
6+
7+
This action simplifies the process of maintaining dynamic test result badges by:
8+
9+
- Creating structured JSON data from test results
10+
- Uploading the data to platform-specific files in a single GitHub Gist
11+
- Providing ready-to-use badge URLs for documentation
12+
13+
## Usage
14+
15+
```yaml
16+
- name: "Update Test Results Badge"
17+
uses: ./.github/actions/update-test-badge
18+
with:
19+
platform: "Linux"
20+
gist_id: "472c59b7c2a1898c48a29f3c88897c5a"
21+
filename: "test-results-linux.json"
22+
gist_token: ${{ secrets.GIST_SECRET }}
23+
test_passed: 1099
24+
test_failed: 0
25+
test_skipped: 0
26+
test_url_html: "https://github.com/owner/repo/runs/12345"
27+
commit_sha: ${{ github.sha }}
28+
run_id: ${{ github.run_id }}
29+
repository: ${{ github.repository }}
30+
server_url: ${{ github.server_url }}
31+
```
32+
33+
## Gist Structure
34+
35+
This action uses a **single Gist** with **multiple files** for different platforms:
36+
37+
```
38+
Gist ID: 472c59b7c2a1898c48a29f3c88897c5a
39+
├── test-results-linux.json
40+
├── test-results-windows.json
41+
└── test-results-macos.json
42+
```
43+
44+
## Inputs
45+
46+
| Input | Description | Required | Default |
47+
|-------|-------------|----------|---------|
48+
| `platform` | Platform name (Linux, Windows, macOS) || - |
49+
| `gist_id` | GitHub Gist ID for storing test results || - |
50+
| `filename` | Filename for platform-specific JSON (e.g., test-results-linux.json) || - |
51+
| `gist_token` | GitHub token with gist permissions || - |
52+
| `test_passed` | Number of passed tests || - |
53+
| `test_failed` | Number of failed tests || - |
54+
| `test_skipped` | Number of skipped tests || - |
55+
| `test_url_html` | URL to test results page || `''` |
56+
| `commit_sha` | Git commit SHA || - |
57+
| `run_id` | GitHub Actions run ID || - |
58+
| `repository` | Repository in owner/repo format || - |
59+
| `server_url` | GitHub server URL || - |
60+
| `api_domain` | Badge API domain for URLs || `your-api-domain` |
61+
62+
## Outputs
63+
64+
This action produces:
65+
66+
- **Gist File Update**: Updates the platform-specific file in the single Gist
67+
- **Console Output**: Displays badge URLs ready for README usage
68+
- **Debug Info**: Shows HTTP status and error details
69+
70+
## Generated JSON Format
71+
72+
The action creates JSON data in this format for each platform file:
73+
74+
```json
75+
{
76+
"platform": "Linux",
77+
"passed": 1099,
78+
"failed": 0,
79+
"skipped": 0,
80+
"total": 1099,
81+
"url_html": "https://github.com/owner/repo/runs/12345",
82+
"timestamp": "2025-01-16T10:30:00Z",
83+
"commit": "abc123def456",
84+
"run_id": "12345678",
85+
"workflow_run_url": "https://github.com/owner/repo/actions/runs/12345678"
86+
}
87+
```
88+
89+
## Error Handling
90+
91+
- **Non-essential**: Uses `continue-on-error: true` to prevent workflow failures
92+
- **Graceful degradation**: Provides detailed error messages without stopping execution
93+
- **HTTP status reporting**: Shows API response codes for debugging
94+
- **File-specific updates**: Only updates the specific platform file, doesn't affect other platform data
95+
96+
## Integration with Badge API
97+
98+
This action is designed to work with the LocalStack .NET Client Badge API that:
99+
100+
- Reads from the updated Gist files
101+
- Generates shields.io-compatible badge JSON
102+
- Provides redirect endpoints to test result pages
103+
104+
## Matrix Integration Example
105+
106+
```yaml
107+
env:
108+
BADGE_GIST_ID: "472c59b7c2a1898c48a29f3c88897c5a"
109+
110+
strategy:
111+
matrix:
112+
include:
113+
- os: ubuntu-22.04
114+
name: "Linux"
115+
filename: "test-results-linux.json"
116+
- os: windows-latest
117+
name: "Windows"
118+
filename: "test-results-windows.json"
119+
- os: macos-latest
120+
name: "macOS"
121+
filename: "test-results-macos.json"
122+
123+
steps:
124+
- name: "Update Test Results Badge"
125+
uses: ./.github/actions/update-test-badge
126+
with:
127+
platform: ${{ matrix.name }}
128+
gist_id: ${{ env.BADGE_GIST_ID }}
129+
filename: ${{ matrix.filename }}
130+
gist_token: ${{ secrets.GIST_SECRET }}
131+
# ... other inputs
132+
```
133+
134+
## Required Setup
135+
136+
1. **Create single GitHub Gist** with platform-specific files:
137+
- `test-results-linux.json`
138+
- `test-results-windows.json`
139+
- `test-results-macos.json`
140+
2. **Generate GitHub PAT** with `gist` scope
141+
3. **Add to repository secrets** as `GIST_SECRET`
142+
4. **Deploy Badge API** to consume the Gist data
143+
144+
## Badge URLs Generated
145+
146+
The action displays ready-to-use markdown for README files:
147+
148+
```markdown
149+
[![Test Results (Linux)](https://your-api-domain/badge/tests/linux)](https://your-api-domain/redirect/tests/linux)
150+
```
151+
152+
## Advantages of Explicit Filename Configuration
153+
154+
-**No String Manipulation**: Eliminates brittle string transformation logic
155+
-**Declarative**: Filenames are explicitly declared in workflow configuration
156+
-**Predictable**: No risk of unexpected filename generation
157+
-**Reusable**: Action works with any filename structure
158+
-**Debuggable**: Easy to see exactly what files will be created
159+
-**Flexible**: Supports any naming convention without code changes
160+
161+
## Advantages of Single Gist Approach
162+
163+
-**Simplified Management**: One Gist to manage instead of three
164+
-**Atomic Operations**: All platform data in one place
165+
-**Better Organization**: Clear file structure with descriptive names
166+
-**Easier Debugging**: Single location to check all test data
167+
-**Cost Efficient**: Fewer API calls and resources
168+
169+
## Troubleshooting
170+
171+
**Common Issues:**
172+
173+
- **403 Forbidden**: Check `GIST_SECRET` permissions
174+
- **404 Not Found**: Verify `gist_id` is correct
175+
- **JSON Errors**: Ensure `jq` is available in runner
176+
- **File Missing**: Gist files are created automatically on first update
177+
178+
**Debug Steps:**
179+
180+
1. Check action output for HTTP status codes
181+
2. Verify Gist exists and is publicly accessible
182+
3. Confirm token has proper `gist` scope
183+
4. Check individual file URLs: `https://gist.githubusercontent.com/{gist_id}/raw/test-results-{platform}.json`
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: 'Update Test Results Badge'
2+
description: 'Updates test results badge data in GitHub Gist and displays badge URLs'
3+
author: 'LocalStack .NET Team'
4+
5+
inputs:
6+
platform:
7+
description: 'Platform name (Linux, Windows, macOS)'
8+
required: true
9+
gist_id:
10+
description: 'GitHub Gist ID for storing test results'
11+
required: true
12+
filename:
13+
description: 'Filename for the platform-specific JSON file (e.g., test-results-linux.json)'
14+
required: true
15+
gist_token:
16+
description: 'GitHub token with gist permissions'
17+
required: true
18+
test_passed:
19+
description: 'Number of passed tests'
20+
required: true
21+
test_failed:
22+
description: 'Number of failed tests'
23+
required: true
24+
test_skipped:
25+
description: 'Number of skipped tests'
26+
required: true
27+
test_url_html:
28+
description: 'URL to test results page'
29+
required: false
30+
default: ''
31+
commit_sha:
32+
description: 'Git commit SHA'
33+
required: true
34+
run_id:
35+
description: 'GitHub Actions run ID'
36+
required: true
37+
repository:
38+
description: 'Repository in owner/repo format'
39+
required: true
40+
server_url:
41+
description: 'GitHub server URL'
42+
required: true
43+
api_domain:
44+
description: 'Badge API domain for displaying URLs'
45+
required: false
46+
default: 'your-api-domain'
47+
48+
runs:
49+
using: 'composite'
50+
steps:
51+
- name: 'Update Test Results Badge Data'
52+
shell: bash
53+
run: |
54+
# Use explicit filename from input
55+
FILENAME="${{ inputs.filename }}"
56+
57+
# Calculate totals
58+
TOTAL=$((${{ inputs.test_passed }} + ${{ inputs.test_failed }} + ${{ inputs.test_skipped }}))
59+
60+
# Create JSON payload for badge API
61+
cat > test-results.json << EOF
62+
{
63+
"platform": "${{ inputs.platform }}",
64+
"passed": ${{ inputs.test_passed }},
65+
"failed": ${{ inputs.test_failed }},
66+
"skipped": ${{ inputs.test_skipped }},
67+
"total": ${TOTAL},
68+
"url_html": "${{ inputs.test_url_html }}",
69+
"timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
70+
"commit": "${{ inputs.commit_sha }}",
71+
"run_id": "${{ inputs.run_id }}",
72+
"workflow_run_url": "${{ inputs.server_url }}/${{ inputs.repository }}/actions/runs/${{ inputs.run_id }}"
73+
}
74+
EOF
75+
76+
echo "📊 Generated test results JSON for ${{ inputs.platform }}:"
77+
cat test-results.json | jq '.' 2>/dev/null || cat test-results.json
78+
79+
# Upload to single Gist with platform-specific filename
80+
echo "📤 Uploading to Gist: ${{ inputs.gist_id }} (file: ${FILENAME})"
81+
82+
# Create gist update payload - only update the specific platform file
83+
cat > gist-payload.json << EOF
84+
{
85+
"files": {
86+
"${FILENAME}": {
87+
"content": $(cat test-results.json | jq -R -s '.')
88+
}
89+
}
90+
}
91+
EOF
92+
93+
# Update Gist using GitHub API
94+
HTTP_STATUS=$(curl -s -X PATCH \
95+
-H "Accept: application/vnd.github.v3+json" \
96+
-H "Authorization: token ${{ inputs.gist_token }}" \
97+
"https://api.github.com/gists/${{ inputs.gist_id }}" \
98+
-d @gist-payload.json \
99+
-w "%{http_code}" \
100+
-o response.json)
101+
102+
if [ "$HTTP_STATUS" -eq 200 ]; then
103+
echo "✅ Successfully updated Gist file ${FILENAME} (HTTP $HTTP_STATUS)"
104+
else
105+
echo "⚠️ Failed to update Gist file ${FILENAME} (HTTP $HTTP_STATUS)"
106+
echo "Response:"
107+
cat response.json 2>/dev/null || echo "No response body"
108+
fi
109+
110+
- name: 'Display Badge URLs'
111+
shell: bash
112+
run: |
113+
PLATFORM_LOWER=$(echo "${{ inputs.platform }}" | tr '[:upper:]' '[:lower:]')
114+
FILENAME="${{ inputs.filename }}"
115+
116+
echo "🎯 Badge URL for ${{ inputs.platform }}:"
117+
echo ""
118+
echo "**${{ inputs.platform }} Badge:**"
119+
echo "[![Test Results (${{ inputs.platform }})](https://${{ inputs.api_domain }}/badge/tests/${PLATFORM_LOWER})](https://${{ inputs.api_domain }}/redirect/tests/${PLATFORM_LOWER})"
120+
echo ""
121+
echo "**Raw URLs:**"
122+
echo "- Badge: https://${{ inputs.api_domain }}/badge/tests/${PLATFORM_LOWER}"
123+
echo "- Redirect: https://${{ inputs.api_domain }}/redirect/tests/${PLATFORM_LOWER}"
124+
echo "- Gist: https://gist.github.com/${{ inputs.gist_id }}"
125+
echo "- Gist File: https://gist.githubusercontent.com/Blind-Striker/${{ inputs.gist_id }}/raw/${FILENAME}"

.github/nuget.config

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<clear />
5+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
6+
<add key="github-packages" value="https://nuget.pkg.github.com/localstack-dotnet/index.json" />
7+
</packageSources>
8+
<packageSourceMapping>
9+
<!-- All standard packages from nuget.org -->
10+
<packageSource key="nuget.org">
11+
<package pattern="*" />
12+
</packageSource>
13+
<!-- Only LocalStack packages from GitHub Packages -->
14+
<packageSource key="github-packages">
15+
<package pattern="LocalStack.*" />
16+
</packageSource>
17+
</packageSourceMapping>
18+
</configuration>

.github/workflows/build-macos.yml

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)