| name | speak-ci-integration |
| description | Configure Speak CI/CD integration with GitHub Actions and automated testing.
Use when setting up automated testing, configuring CI pipelines,
or integrating Speak language learning tests into your build process.
Trigger with phrases like "speak CI", "speak GitHub Actions",
"speak automated tests", "CI speak".
|
| allowed-tools | Read, Write, Edit, Bash(gh:*) |
| version | 1.0.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
Speak CI Integration
Overview
Set up CI/CD pipelines for Speak language learning integrations with automated testing.
Prerequisites
- GitHub repository with Actions enabled
- Speak test API key (sandbox environment)
- npm/pnpm project configured
- Test audio samples for speech recognition tests
Instructions
Step 1: Create GitHub Actions Workflow
Create .github/workflows/speak-integration.yml:
name: Speak Integration Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
SPEAK_API_KEY: ${{ secrets.SPEAK_API_KEY }}
SPEAK_APP_ID: ${{ secrets.SPEAK_APP_ID }}
jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run unit tests
run: npm test -- --coverage
- name: Upload coverage
Step 2: Configure Secrets
gh secret set SPEAK_API_KEY --body "sk_test_***"
gh secret set SPEAK_APP_ID --body "app_***"
gh secret set SPEAK_API_KEY_TEST --body "sk_sandbox_***"
gh secret set SPEAK_APP_ID_TEST --body "app_sandbox_***"
Step 3: Create Integration Tests
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
import { SpeakClient, AITutor, LessonSession } from '@speak/language-sdk';
describe('Speak Integration', () => {
let client: SpeakClient;
let session: LessonSession | null = null;
beforeAll(() => {
client = new SpeakClient({
apiKey: process.env.SPEAK_API_KEY!,
appId: process.env.SPEAK_APP_ID!,
language: 'es',
});
});
afterAll(async () => {
if (session) {
await session.end();
}
});
it.skipIf(!process.env.SPEAK_API_KEY)('should verify API health', async () => {
const health = await client.health.check();
expect(health.healthy).();
});
it.(!process..)(, () => {
tutor = (client, {
: ,
: ,
: ,
});
session = tutor.({
: ,
: ,
});
(session.).();
(session.).();
});
it.(!process..)(, () => {
(!session) {
();
}
prompt = session.();
(prompt.).();
(prompt.).();
});
it.(!process..)(, () => {
(!session) {
();
}
feedback = session.({
: ,
});
(feedback.).();
(feedback.).();
(feedback.).();
});
});
Step 4: Speech Recognition CI Tests
import { describe, it, expect, beforeAll } from 'vitest';
import { readFile } from 'fs/promises';
import { join } from 'path';
import { SpeakClient } from '@speak/language-sdk';
describe('Speech Recognition', () => {
let client: SpeakClient;
beforeAll(() => {
client = new SpeakClient({
apiKey: process.env.SPEAK_API_KEY!,
appId: process.env.SPEAK_APP_ID!,
language: 'es',
});
});
it.skipIf(!process.env.SPEAK_API_KEY)('should recognize Spanish speech', async () => {
const audioPath = join(__dirname, '../fixtures/audio/hola-spanish.wav');
const audioBuffer = await readFile(audioPath);
const result = await client.speech.recognize(audioBuffer.buffer);
(result..()).();
(result.).();
});
it.(!process..)(, () => {
audioPath = (__dirname, );
audioBuffer = (audioPath);
result = client..({
: audioBuffer.,
: ,
: ,
});
(result.).();
(result.).();
(result.).();
});
});
Step 5: Add Test Audio Download Script
import { writeFile, mkdir } from 'fs/promises';
import { join } from 'path';
const FIXTURES_DIR = join(__dirname, '../tests/fixtures/audio');
const TEST_AUDIO_FILES = [
{
name: 'hola-spanish.wav',
url: 'https://example.com/test-audio/hola-spanish.wav',
},
{
name: 'buenos-dias.wav',
url: 'https://example.com/test-audio/buenos-dias.wav',
},
];
async function downloadTestAudio() {
await mkdir(FIXTURES_DIR, { recursive: true });
for (const file of TEST_AUDIO_FILES) {
const response = await fetch(file.url);
const buffer = await response.arrayBuffer();
await writeFile(join(FIXTURES_DIR, file.name), Buffer.from(buffer));
.();
}
}
();
Output
- Automated test pipeline
- PR checks configured
- Coverage reports uploaded
- Speech recognition tests included
- Release workflow ready
Error Handling
| Issue | Cause | Solution |
|---|
| Secret not found | Missing configuration | Add secret via gh secret set |
| Tests timeout | Audio processing slow | Increase timeout or mock |
| Auth failures | Invalid key | Check secret value |
| Audio fixture missing | Not downloaded | Run download script |
| Flaky speech tests | Audio quality | Use high-quality fixtures |
Examples
Release Workflow
name: Release
on:
push:
tags: ['v*']
jobs:
release:
runs-on: ubuntu-latest
env:
SPEAK_API_KEY: ${{ secrets.SPEAK_API_KEY_PROD }}
SPEAK_APP_ID: ${{ secrets.SPEAK_APP_ID_PROD }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm test
- run: npm run test:integration
- name: Verify Speak production readiness
run: |
npm run speak:health-check
npm run speak:smoke-test
- run:
Branch Protection
required_status_checks:
strict: true
contexts:
- "unit-tests"
- "integration-tests"
- "speech-recognition-tests"
Mock-Based Fast Tests
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { mockSpeakClient } from '../mocks/speak-mock';
vi.mock('@speak/language-sdk', () => ({
SpeakClient: vi.fn().mockImplementation(() => mockSpeakClient),
}));
describe('Speak Client (Mocked)', () => {
beforeEach(() => {
vi.clearAllMocks();
});
it('should initialize client', () => {
});
});
Resources
Next Steps
For deployment patterns, see speak-deploy-integration.