11# Update Test Results Badge Action
22
3- A reusable GitHub Action that updates test result badges by uploading test data to GitHub Gists and displaying badge URLs for README files.
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.
44
55## Purpose
66
77This action simplifies the process of maintaining dynamic test result badges by:
8-
98- Creating structured JSON data from test results
10- - Uploading the data to platform-specific GitHub Gists
9+ - Uploading the data to platform-specific files in a single GitHub Gist
1110- Providing ready-to-use badge URLs for documentation
1211
1312## Usage
@@ -17,7 +16,8 @@ This action simplifies the process of maintaining dynamic test result badges by:
1716 uses : ./.github/actions/update-test-badge
1817 with :
1918 platform : " Linux"
20- gist_id : " c149767013f99f00791256d9036ef71b"
19+ gist_id : " 472c59b7c2a1898c48a29f3c88897c5a"
20+ filename : " test-results-linux.json"
2121 gist_token : ${{ secrets.GIST_SECRET }}
2222 test_passed : 1099
2323 test_failed : 0
@@ -29,12 +29,24 @@ This action simplifies the process of maintaining dynamic test result badges by:
2929 server_url : ${{ github.server_url }}
3030` ` `
3131
32+ ## Gist Structure
33+
34+ This action uses a **single Gist** with **multiple files** for different platforms:
35+
36+ ` ` `
37+ Gist ID : 472c59b7c2a1898c48a29f3c88897c5a
38+ ├── test-results-linux.json
39+ ├── test-results-windows.json
40+ └── test-results-macos.json
41+ ```
42+
3243## Inputs
3344
3445| Input | Description | Required | Default |
3546| -------| -------------| ----------| ---------|
3647| ` platform ` | Platform name (Linux, Windows, macOS) | ✅ | - |
3748| ` gist_id ` | GitHub Gist ID for storing test results | ✅ | - |
49+ | ` filename ` | Filename for platform-specific JSON (e.g., test-results-linux.json) | ✅ | - |
3850| ` gist_token ` | GitHub token with gist permissions | ✅ | - |
3951| ` test_passed ` | Number of passed tests | ✅ | - |
4052| ` test_failed ` | Number of failed tests | ✅ | - |
@@ -49,14 +61,13 @@ This action simplifies the process of maintaining dynamic test result badges by:
4961## Outputs
5062
5163This action produces:
52-
53- - **Gist Update**: Updates the specified Gist with test result JSON
64+ - ** Gist File Update** : Updates the platform-specific file in the single Gist
5465- ** Console Output** : Displays badge URLs ready for README usage
5566- ** Debug Info** : Shows HTTP status and error details
5667
5768## Generated JSON Format
5869
59- The action creates JSON data in this format :
70+ The action creates JSON data in this format for each platform file :
6071
6172``` json
6273{
@@ -78,46 +89,53 @@ The action creates JSON data in this format:
7889- ** Non-essential** : Uses ` continue-on-error: true ` to prevent workflow failures
7990- ** Graceful degradation** : Provides detailed error messages without stopping execution
8091- ** HTTP status reporting** : Shows API response codes for debugging
92+ - ** File-specific updates** : Only updates the specific platform file, doesn't affect other platform data
8193
8294## Integration with Badge API
8395
8496This action is designed to work with the LocalStack .NET Client Badge API that:
85-
86- - Reads from the updated Gists
97+ - Reads from the updated Gist files
8798- Generates shields.io-compatible badge JSON
8899- Provides redirect endpoints to test result pages
89100
90101## Matrix Integration Example
91102
92103``` yaml
104+ env :
105+ BADGE_GIST_ID : " 472c59b7c2a1898c48a29f3c88897c5a"
106+
93107strategy :
94108 matrix :
95109 include :
96110 - os : ubuntu-22.04
97111 name : " Linux"
98- gist_id : "c149767013f99f00791256d9036ef71b "
112+ filename : " test-results-linux.json "
99113 - os : windows-latest
100114 name : " Windows"
101- gist_id : "3640d86bbf37520844f737e6a76b4d90 "
115+ filename : " test-results-windows.json "
102116 - os : macos-latest
103117 name : " macOS"
104- gist_id : "db58d93cf17ee5db079d06e3bfa4c069 "
118+ filename : " test-results-macos.json "
105119
106120steps :
107121 - name : " Update Test Results Badge"
108122 uses : ./.github/actions/update-test-badge
109123 with :
110124 platform : ${{ matrix.name }}
111- gist_id: ${{ matrix.gist_id }}
125+ gist_id : ${{ env.BADGE_GIST_ID }}
126+ filename : ${{ matrix.filename }}
112127 gist_token : ${{ secrets.GIST_SECRET }}
113128 # ... other inputs
114129```
115130
116131## Required Setup
117132
118- 1. **Create GitHub Gists** for each platform
133+ 1 . ** Create single GitHub Gist** with platform-specific files:
134+ - ` test-results-linux.json `
135+ - ` test-results-windows.json `
136+ - ` test-results-macos.json `
1191372 . ** Generate GitHub PAT** with ` gist ` scope
120- 3. **Add to repository secrets** as `GIST_TOKEN `
138+ 3 . ** Add to repository secrets** as ` GIST_SECRET `
1211394 . ** Deploy Badge API** to consume the Gist data
122140
123141## Badge URLs Generated
@@ -128,17 +146,33 @@ The action displays ready-to-use markdown for README files:
128146[](https://your-api-domain/redirect/tests/linux)
129147```
130148
149+ ## Advantages of Explicit Filename Configuration
150+
151+ - ✅ ** No String Manipulation** : Eliminates brittle string transformation logic
152+ - ✅ ** Declarative** : Filenames are explicitly declared in workflow configuration
153+ - ✅ ** Predictable** : No risk of unexpected filename generation
154+ - ✅ ** Reusable** : Action works with any filename structure
155+ - ✅ ** Debuggable** : Easy to see exactly what files will be created
156+ - ✅ ** Flexible** : Supports any naming convention without code changes
157+
158+ ## Advantages of Single Gist Approach
159+
160+ - ✅ ** Simplified Management** : One Gist to manage instead of three
161+ - ✅ ** Atomic Operations** : All platform data in one place
162+ - ✅ ** Better Organization** : Clear file structure with descriptive names
163+ - ✅ ** Easier Debugging** : Single location to check all test data
164+ - ✅ ** Cost Efficient** : Fewer API calls and resources
165+
131166## Troubleshooting
132167
133168** Common Issues:**
134-
135- - **403 Forbidden**: Check `GIST_TOKEN` permissions
169+ - ** 403 Forbidden** : Check ` GIST_SECRET ` permissions
136170- ** 404 Not Found** : Verify ` gist_id ` is correct
137171- ** JSON Errors** : Ensure ` jq ` is available in runner
172+ - ** File Missing** : Gist files are created automatically on first update
138173
139174** Debug Steps:**
140-
1411751 . Check action output for HTTP status codes
1421762 . Verify Gist exists and is publicly accessible
1431773 . Confirm token has proper ` gist ` scope
144- 4. Test Gist update manually with curl
178+ 4 . Check individual file URLs: ` https://gist.githubusercontent.com/{gist_id}/raw/test-results-{platform}.json `
0 commit comments