|
1 | | -# Github Usage Report Library |
| 1 | +# GitHub Usage Report Library |
2 | 2 |
|
3 | | -A simple library to parse a Github usage report. |
| 3 | +A TypeScript library to read and process GitHub usage data from CSV files. |
4 | 4 |
|
5 | | -See [Viewing your GitHub Actions usage](https://docs.github.com/en/billing/managing-billing-for-github-actions/viewing-your-github-actions-usage) for instructions on how to generate a Github usage report. |
| 5 | +## Features |
6 | 6 |
|
7 | | -## 🔨 Build |
| 7 | +- Parse GitHub Actions usage reports from CSV files |
| 8 | +- Support for both streaming (async) and direct (sync) file reading |
| 9 | +- TypeScript support with full type definitions |
| 10 | +- Optional line-by-line processing callbacks |
| 11 | + |
| 12 | +## Installation |
| 13 | + |
| 14 | +```bash |
| 15 | +npm install |
8 | 16 | ``` |
9 | | -npm run build |
| 17 | + |
| 18 | +## Usage |
| 19 | + |
| 20 | +### Reading a Usage Report (Async) |
| 21 | + |
| 22 | +```typescript |
| 23 | +import { readGithubUsageReportFile } from './src/index'; |
| 24 | + |
| 25 | +// Basic usage |
| 26 | +const report = await readGithubUsageReportFile('path/to/usage-report.csv'); |
| 27 | +console.log(`Report covers ${report.days} days from ${report.startDate} to ${report.endDate}`); |
| 28 | + |
| 29 | +// With line-by-line callback |
| 30 | +const report = await readGithubUsageReportFile('path/to/usage-report.csv', (line) => { |
| 31 | + console.log(`Processing: ${line.date} - ${line.product}`); |
| 32 | +}); |
10 | 33 | ``` |
11 | 34 |
|
12 | | -## 🧪 Test |
| 35 | +### Reading a Usage Report (Sync) |
| 36 | + |
| 37 | +```typescript |
| 38 | +import { readGithubUsageReportFileSync } from './src/index'; |
| 39 | + |
| 40 | +const report = await readGithubUsageReportFileSync('path/to/usage-report.csv'); |
| 41 | +console.log(`Total lines: ${report.lines.length}`); |
13 | 42 | ``` |
14 | | -npm test |
| 43 | + |
| 44 | +### Report Structure |
| 45 | + |
| 46 | +The library returns a `UsageReport` object with the following structure: |
| 47 | + |
| 48 | +```typescript |
| 49 | +{ |
| 50 | + startDate: Date, // First date in the report |
| 51 | + endDate: Date, // Last date in the report |
| 52 | + days: number, // Number of days covered |
| 53 | + lines: UsageReportLine[] // Array of parsed usage data |
| 54 | +} |
15 | 55 | ``` |
16 | 56 |
|
17 | | -## 🏃 Run |
| 57 | +## Getting Your GitHub Usage Report |
| 58 | + |
| 59 | +To generate a GitHub usage report: |
| 60 | + |
| 61 | +1. Go to your GitHub organization or personal account settings |
| 62 | +2. Navigate to "Billing and plans" → "Actions" |
| 63 | +3. Click "Usage" and export your data as CSV |
| 64 | + |
| 65 | +See [Viewing your GitHub Actions usage](https://docs.github.com/en/billing/managing-billing-for-github-actions/viewing-your-github-actions-usage) for detailed instructions. |
| 66 | + |
| 67 | +## Development |
| 68 | + |
| 69 | +### 🔨 Build |
| 70 | +```bash |
| 71 | +npm run build |
18 | 72 | ``` |
| 73 | + |
| 74 | +### 🧪 Test |
| 75 | +```bash |
| 76 | +npm test |
| 77 | +``` |
| 78 | + |
| 79 | +### 🏃 Run |
| 80 | +```bash |
19 | 81 | npm start |
20 | 82 | ``` |
21 | 83 |
|
22 | | -## 🧹 Lint |
| 84 | +### 🧹 Lint |
| 85 | +```bash |
| 86 | +npm run lint |
23 | 87 | ``` |
24 | | -npm lint |
25 | | -``` |
| 88 | + |
| 89 | +## License |
| 90 | + |
| 91 | +This project is open source. |
0 commit comments