Skip to content

Commit d459998

Browse files
authored
Merge pull request #20 from github/improve/billing-logic-tests
Add billing logic test coverage
2 parents b715bd0 + f2d42c3 commit d459998

20 files changed

Lines changed: 1608 additions & 63 deletions

.github/workflows/deploy.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
push:
55
branches:
66
- main
7+
pull_request:
8+
branches:
9+
- main
710

811
permissions:
912
contents: read
@@ -19,10 +22,10 @@ jobs:
1922
runs-on: ubuntu-latest
2023
steps:
2124
- name: Checkout
22-
uses: actions/checkout@v4
25+
uses: actions/checkout@v6
2326

2427
- name: Setup Node.js
25-
uses: actions/setup-node@v4
28+
uses: actions/setup-node@v6
2629
with:
2730
node-version: '20'
2831
cache: 'npm'
@@ -33,18 +36,24 @@ jobs:
3336
- name: Lint
3437
run: npm run lint
3538

39+
- name: Test
40+
run: npm run test
41+
3642
- name: Build
3743
run: npm run build
3844

3945
- name: Setup Pages
46+
if: github.event_name == 'push'
4047
uses: actions/configure-pages@v5
4148

4249
- name: Upload artifact
50+
if: github.event_name == 'push'
4351
uses: actions/upload-pages-artifact@v3
4452
with:
4553
path: ./dist
4654

4755
deploy:
56+
if: github.event_name == 'push'
4857
environment:
4958
name: github-pages
5059
url: ${{ steps.deployment.outputs.page_url }}

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ A web application for previewing and comparing your future GitHub Copilot bills
2222
## Getting Started
2323

2424
### Prerequisites
25-
- Node.js 18+
25+
- Node.js 20+
2626
- npm or yarn
2727

2828
### Installation
@@ -47,6 +47,12 @@ npm run build
4747

4848
The production build will be created in the `dist/` directory.
4949

50+
### Test
51+
52+
```bash
53+
npm run test
54+
```
55+
5056
### Preview Production Build
5157

5258
```bash
@@ -60,7 +66,7 @@ npm run preview
6066
3. The app will parse the report and compare request-based and AI Credits-based billing signals
6167
4. Explore the visualizations and data views to preview how future bills may look after the AI Credits transition
6268

63-
Sample reports are available in the `examples/` directory. Older examples without `aic_quantity` still load, but AI Credits will remain `0` for those rows.
69+
If you don't have your own data yet, export a GitHub Copilot billing CSV from your organization that matches the current format, including the `aic_quantity` and `aic_gross_amount` columns.
6470

6571
## CSV Report Format
6672

@@ -82,8 +88,6 @@ The application expects CSV files with the following required columns:
8288
- `organization` - Organization slug
8389
- `cost_center_name` - Optional cost center identifier
8490

85-
Newer exports may also include these AI Credit columns:
86-
8791
- `aic_quantity` - AI Credits for the same usage row
8892
- `aic_gross_amount` - AI Credit gross cost for the same usage row
8993

docs/report-format.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,12 @@ Source examples: files in `examples/`. Some existing sample exports still use th
2121
| `total_monthly_quota` | number | Monthly quota for the user or plan applicable to the row. |
2222
| `organization` | string | Organization slug associated with the usage. |
2323
| `cost_center_name` | string | Optional cost center or tagging field. |
24-
## Optional AI Credit columns
25-
26-
| Column | Status | Notes |
27-
| --- | --- | --- |
2824
| `aic_quantity` | Present in newer previews | Same usage converted to AI Credits. |
2925
| `aic_gross_amount` | Present in newer previews | Used for AI Credit gross cost when present. |
30-
| `total_input_tokens` | Legacy / optional | Older token-oriented export field; ignored by the app. |
31-
| `total_output_tokens` | Legacy / optional | Older token-oriented export field; ignored by the app. |
32-
| `total_cache_creation_tokens` | Legacy / optional | Older token-oriented export field; ignored by the app. |
33-
| `total_cache_read_tokens` | Legacy / optional | Older token-oriented export field; ignored by the app. |
3426

3527
## Notes
3628
- Header row is single-lined; subsequent rows are usage records. Values are comma-separated, double-quoted where needed.
3729
- Monetary fields are decimals. `aic_quantity` may also be fractional.
3830
- The app streams the file, treats the first row as the header, and counts subsequent data rows without loading the entire file into memory.
39-
- Current calculations support both row types: on `requests` rows, `quantity` and `applied_cost_per_quantity` describe PRU usage while `aic_quantity` and `aic_gross_amount` remain reference/comparison values and stay `0` when those AI Credit fields are absent; on `ai-units` rows, Premium Requests and generic PRU gross/discount/net totals are counted as `0`, while AI Credits and AI Credit gross cost are taken from the AI-specific fields (`aic_quantity` / `aic_gross_amount`, with fallback to `quantity` / `gross_amount` only when those AI-specific fields are absent).
40-
- Reports without `aic_quantity` still load, but AI Credit summaries will display `0`.
31+
- Current calculations support both row types: on `requests` rows, `quantity` and `applied_cost_per_quantity` describe PRU usage while `aic_quantity` and `aic_gross_amount` remain reference/comparison values; on `ai-units` rows, Premium Requests and generic PRU gross/discount/net totals are counted as `0`, while AI Credits and AI Credit gross cost are taken from the AI-specific fields (`aic_quantity` / `aic_gross_amount`), with fallback to `quantity` / `gross_amount` only when those AI-specific fields are present but blank.
32+
- The current app expects the current CSV format, including `aic_quantity` and `aic_gross_amount`.

0 commit comments

Comments
 (0)