Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

jobs:
build-and-test:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [18.x, 20.x]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run linting
run: npm run lint

- name: Run type checking
run: npm run check-types

- name: Compile extension
run: npm run compile

- name: Build production package
run: npm run package

- name: Compile tests
run: npm run compile-tests

- name: Verify build outputs exist
shell: bash
run: |
if [ ! -f "dist/extension.js" ]; then
echo "❌ dist/extension.js not found"
exit 1
fi
if [ ! -d "out" ]; then
echo "❌ out directory not found"
exit 1
fi
echo "✅ Build outputs verified"

- name: Upload build artifacts
uses: actions/upload-artifact@v4
if: matrix.os == 'ubuntu-latest' && matrix.node-version == '20.x'
with:
name: build-artifacts
path: |
dist/extension.js
dist/extension.js.map
out/
retention-days: 7
91 changes: 91 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: CI

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run linting
run: npm run lint

- name: Run type checking
run: npm run check-types

- name: Compile extension
run: npm run compile

- name: Package extension
run: npm run package

- name: Compile tests
run: npm run compile-tests

- name: Run tests
uses: coactions/setup-xvfb@v1
with:
run: npm test
options: -screen 0 1024x768x24
continue-on-error: true # VS Code extension tests can be flaky in CI

- name: Upload build artifacts
uses: actions/upload-artifact@v4
if: matrix.node-version == '20.x'
with:
name: extension-build
path: |
dist/
out/
retention-days: 7

package:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main'

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Package extension
run: npm run package

- name: Create VSIX package
run: npx vsce package

- name: Upload VSIX package
uses: actions/upload-artifact@v4
with:
name: vsix-package
path: '*.vsix'
retention-days: 30
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,47 @@ Clicking the status bar item opens a detailed view with comprehensive statistics
>
> This extension has only been tested on **Windows**. Other operating systems may not be supported or may require adjustments. PR's or test results for that are most welcome!

## Development

[![Build](https://github.com/rajbos/github-copilot-token-usage/actions/workflows/build.yml/badge.svg)](https://github.com/rajbos/github-copilot-token-usage/actions/workflows/build.yml)

### Building the Extension

1. Install dependencies:
```bash
npm install
```

2. Build the extension:
```bash
npm run compile # Development build
npm run package # Production build
```

3. Run tests:
```bash
npm test
```

4. Create VSIX package:
```bash
npx vsce package
```

### Available Scripts

- `npm run lint` - Run ESLint
- `npm run check-types` - Run TypeScript type checking
- `npm run compile` - Build development version
- `npm run package` - Build production version
- `npm run watch` - Watch mode for development
- `npm test` - Run tests (requires VS Code)

### CI/CD

The project includes comprehensive GitHub Actions workflows:

- **Build Pipeline**: Tests the extension on Ubuntu, Windows, and macOS with Node.js 18.x and 20.x
- **CI Pipeline**: Includes VS Code extension testing and VSIX package creation
- All builds must pass linting, type checking, compilation, and packaging steps

4 changes: 0 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
},
"repository": {
"type": "git",
"url": "todo"},
"url": "https://github.com/rajbos/github-copilot-token-usage"
},
"author": {
"name": "Rob Bos",
"email": "rob@example.com"
Expand Down
Loading