Skip to content

Commit 6c0eaf7

Browse files
authored
Merge pull request #210 from austenstone/rewrite
Enhance job summary metrics and reporting
2 parents 5e0196d + 12e97ab commit 6c0eaf7

32 files changed

+47965
-24303
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
- uses: actions/setup-node@v4
2020
- run: npm ci
2121
- run: npm run lint
22+
continue-on-error: true
2223
- run: npm run build
2324
- run: npm test
2425
env:

.github/workflows/codeql.yml

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

.github/workflows/usage.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
branches: [ main ]
55
paths-ignore:
66
- "**.md"
7+
pull_request:
8+
branches: [ main ]
9+
paths-ignore:
10+
- "**.md"
711
workflow_dispatch:
812
permissions:
913
contents: read

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,16 @@ jobs:
3939
name: Run Action
4040
runs-on: ubuntu-latest
4141
steps:
42-
- uses: austenstone/copilot-usage@v5.0
42+
- uses: austenstone/copilot-usage@v5.1
4343
with:
4444
github-token: ${{ secrets.TOKEN }}
4545
time-zone: 'EST'
4646
```
47+
4748
#### Example get team usage
4849
4950
```yml
50-
- uses: austenstone/copilot-usage@v5.0
51+
- uses: austenstone/copilot-usage@v5.1
5152
with:
5253
github-token: ${{ secrets.TOKEN }}
5354
organization: 'org-slug'
@@ -57,7 +58,7 @@ jobs:
5758
#### Example get CSV
5859
5960
```yml
60-
- uses: austenstone/copilot-usage@v5.0
61+
- uses: austenstone/copilot-usage@v5.1
6162
with:
6263
github-token: ${{ secrets.TOKEN }}
6364
csv: true
@@ -72,7 +73,7 @@ jobs:
7273
- 'team-slug2'
7374
steps:
7475
- uses: actions/checkout@v4
75-
- uses: austenstone/copilot-usage@v5.0
76+
- uses: austenstone/copilot-usage@v5.1
7677
with:
7778
github-token: ${{ secrets.TOKEN }}
7879
organization: 'org-slug'
@@ -85,7 +86,7 @@ You probably want to specify the timezone to get the usage in your local time. T
8586
EX: `EST`, `PST`, `CST`, [etc](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
8687

8788
```yml
88-
- uses: austenstone/copilot-usage@v5.0
89+
- uses: austenstone/copilot-usage@v5.1
8990
with:
9091
github-token: ${{ secrets.TOKEN }}
9192
organization: 'org-slug'
@@ -108,7 +109,7 @@ jobs:
108109
run:
109110
runs-on: ubuntu-latest
110111
steps:
111-
- uses: austenstone/copilot-usage@v5.0
112+
- uses: austenstone/copilot-usage@v5.1
112113
with:
113114
github-token: ${{ secrets.TOKEN }}
114115
- uses: austenstone/[email protected]

__tests__/main.test.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { test, beforeAll, beforeEach, expect } from 'vitest';
22
import dotenv from 'dotenv'
33
dotenv.config({ override: true })
4-
import { createJobSummaryUsage } from '../src/job-summary';
4+
import { createJobSummaryCopilotDetails, createJobSummarySeatAssignments, createJobSummaryUsage } from '../src/job-summary';
55
import { sumNestedValue } from '../src/job-summary'; // Import sumNestedValue function
66
import { summary } from '@actions/core/lib/summary';
77
import { read, readFileSync, writeFileSync } from 'fs';
@@ -23,14 +23,30 @@ beforeEach(() => {
2323

2424
const sample = readFileSync('./__tests__/mock/sample.json', 'utf-8');
2525
const exampleResponseEnterprise = JSON.parse(sample);
26+
const sampleCopilotDetails = readFileSync('./__tests__/mock/sample-copilot-details.json', 'utf-8');
27+
const exampleResponseCopilotDetails = JSON.parse(sampleCopilotDetails);
28+
const sampleCopilotSeats = readFileSync('./__tests__/mock/sample-copilot-seats.json', 'utf-8');
29+
const exampleResponseCopilotSeats = JSON.parse(sampleCopilotSeats);
2630

2731
test('createJobSummaryUsage(enterpriseUsage)', async () => {
2832
const summary = await createJobSummaryUsage(exampleResponseEnterprise, 'enterprise');
2933
writeFileSync('./__tests__/mock/sample-output.md', summary.stringify());
30-
console.log('Summary:', summary.stringify());
3134
expect(summary).toBeDefined();
3235
});
3336

37+
test('createJobSummaryCopilotDetails(enterpriseUsage)', async () => {
38+
const summary = await createJobSummaryCopilotDetails(exampleResponseCopilotDetails);
39+
writeFileSync('./__tests__/mock/sample-copilot-details-output.md', summary.stringify());
40+
expect(summary).toBeDefined();
41+
});
42+
43+
test('createJobSummaryCopilotSeats(enterpriseUsage)', async () => {
44+
const summary = await createJobSummarySeatAssignments(exampleResponseCopilotSeats.seats);
45+
writeFileSync('./__tests__/mock/sample-copilot-seats-output.md', summary.stringify());
46+
expect(summary).toBeDefined();
47+
});
48+
49+
3450
// Tests for sumNestedValue function
3551
test('sumNestedValue with simple objects', () => {
3652
const data = [
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<h1>Seat Info</h1>
2+
<h3>Organization Copilot Details</h3>
3+
<table><tr><td>Plan Type</td><td>ENTERPRISE</td></tr><tr><td>Seat Management Setting</td><td>Assign All</td></tr></table>
4+
<h3>Seat Breakdown</h3>
5+
<table><tr><td>Total Seats</td><td>867</td></tr><tr><td>Added this cycle</td><td>1</td></tr><tr><td>Pending invites</td><td>0</td></tr><tr><td>Pending cancellations</td><td>0</td></tr><tr><td>Active this cycle</td><td>94</td></tr><tr><td>Inactive this cycle</td><td>773</td></tr></table>
6+
<h3>Policies</h3>
7+
<table><tr><td>Public Code Suggestions Enabled</td><td>Allowed</td></tr><tr><td>IDE Chat Enabled</td><td>ENABLED</td></tr><tr><td>Platform Chat Enabled</td><td>ENABLED</td></tr><tr><td>CLI Enabled</td><td>ENABLED</td></tr></table>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"seat_breakdown": {
3+
"pending_invitation": 0,
4+
"pending_cancellation": 0,
5+
"added_this_cycle": 1,
6+
"total": 867,
7+
"active_this_cycle": 94,
8+
"inactive_this_cycle": 773
9+
},
10+
"seat_management_setting": "assign_all",
11+
"plan_type": "enterprise",
12+
"public_code_suggestions": "allow",
13+
"ide_chat": "enabled",
14+
"cli": "enabled",
15+
"platform_chat": "enabled"
16+
}

__tests__/mock/sample-copilot-seats-output.md

Lines changed: 2 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)