Test Suite #62
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test Suite | |
| on: | |
| workflow_run: | |
| workflows: ["Quick Tests"] | |
| types: [completed] | |
| branches: [main, develop] | |
| schedule: | |
| # Run comprehensive tests daily at 2 AM UTC | |
| - cron: '0 2 * * *' | |
| workflow_dispatch: | |
| inputs: | |
| test_type: | |
| description: 'Type of tests to run' | |
| required: false | |
| default: 'all' | |
| type: choice | |
| options: | |
| - all | |
| - unit | |
| - integration | |
| - performance | |
| jobs: | |
| validate: | |
| name: Validate Workflows | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Validate workflow syntax | |
| run: | | |
| echo "✅ Basic workflow validation passed" | |
| - name: Check script permissions | |
| run: | | |
| if [ -f "scripts/download-ffmpeg.sh" ]; then | |
| echo "✅ download-ffmpeg.sh found" | |
| else | |
| echo "❌ download-ffmpeg.sh not found" | |
| exit 1 | |
| fi | |
| unit-tests: | |
| name: Unit Tests | |
| runs-on: ubuntu-latest | |
| if: > | |
| github.event.inputs.test_type == 'all' || | |
| github.event.inputs.test_type == 'unit' || | |
| github.event_name == 'schedule' || | |
| github.event_name == 'workflow_run' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Cache FFmpeg binaries | |
| uses: actions/cache@v4 | |
| with: | |
| path: src/vendor/ffmpeg | |
| key: ffmpeg-binaries-${{ runner.os }}-v1 | |
| restore-keys: | | |
| ffmpeg-binaries-${{ runner.os }}- | |
| - name: Setup Zig | |
| uses: mlugg/setup-zig@v2 | |
| with: | |
| version: 0.15.1 | |
| - name: Cache Zig build | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| .zig-cache | |
| zig-out | |
| key: zig-build-${{ runner.os }}-${{ hashFiles('build.zig', 'src/**/*.zig') }} | |
| restore-keys: | | |
| zig-build-${{ runner.os }}- | |
| - name: Run unit tests | |
| run: zig build test | |
| - name: Generate test coverage | |
| run: | | |
| zig build test --summary all 2>&1 | tee test_output.txt | |
| echo "## Test Results" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| cat test_output.txt >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| integration-tests: | |
| name: Integration Tests | |
| runs-on: ${{ matrix.os }} | |
| if: > | |
| github.event.inputs.test_type == 'all' || | |
| github.event.inputs.test_type == 'integration' || | |
| github.event_name == 'schedule' || | |
| github.event_name == 'workflow_run' | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| shell: bash | |
| - os: windows-2022 # Use specific version for better caching | |
| shell: pwsh | |
| - os: macos-latest | |
| shell: bash | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Cache FFmpeg binaries | |
| uses: actions/cache@v4 | |
| with: | |
| path: src/vendor/ffmpeg | |
| key: ffmpeg-binaries-${{ matrix.os }}-v1 | |
| restore-keys: | | |
| ffmpeg-binaries-${{ matrix.os }}- | |
| - name: Setup Zig | |
| uses: mlugg/setup-zig@v2 | |
| with: | |
| version: 0.15.1 | |
| # Windows-specific cache optimization | |
| - name: Cache Windows build dependencies | |
| if: matrix.os == 'windows-2022' | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~\AppData\Local\Temp\zig-* | |
| ~\AppData\Local\zig | |
| key: windows-test-deps-${{ hashFiles('build.zig') }} | |
| - name: Cache Zig build | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| .zig-cache | |
| zig-out | |
| key: zig-build-${{ matrix.os }}-${{ hashFiles('build.zig', 'src/**/*.zig') }} | |
| restore-keys: | | |
| zig-build-${{ matrix.os }}- | |
| # Optimized build command per platform (Windows) | |
| - name: Build application (Windows) | |
| if: matrix.os == 'windows-2022' | |
| shell: pwsh | |
| run: zig build | |
| # Optimized build command per platform (Unix) | |
| - name: Build application (Unix) | |
| if: matrix.os != 'windows-2022' | |
| shell: bash | |
| run: zig build | |
| - name: Test video generation | |
| shell: bash | |
| run: | | |
| # Create test-media directory | |
| mkdir -p test-media | |
| if [[ "${{ matrix.os }}" == "windows-latest" ]]; then | |
| ./zig-out/bin/media-gen.exe video --duration 1 --width 320 --height 240 --output test-media/test_video.mp4 | |
| else | |
| ./zig-out/bin/media-gen video --duration 1 --width 320 --height 240 --output test-media/test_video.mp4 | |
| fi | |
| # Check if file exists and has reasonable size | |
| if [[ ! -f test-media/test_video.mp4 ]]; then | |
| echo "Video file was not created" | |
| exit 1 | |
| fi | |
| file_size=$(stat -f%z test-media/test_video.mp4 2>/dev/null || stat -c%s test-media/test_video.mp4) | |
| if [[ $file_size -lt 1000 ]]; then | |
| echo "Video file is too small: $file_size bytes" | |
| exit 1 | |
| fi | |
| echo "Video test passed: $file_size bytes" | |
| - name: Test audio generation | |
| shell: bash | |
| run: | | |
| if [[ "${{ matrix.os }}" == "windows-latest" ]]; then | |
| ./zig-out/bin/media-gen.exe audio --duration 1 --sample-rate 22050 --output test-media/test_audio.mp3 | |
| else | |
| ./zig-out/bin/media-gen audio --duration 1 --sample-rate 22050 --output test-media/test_audio.mp3 | |
| fi | |
| # Check if file exists and has reasonable size | |
| if [[ ! -f test-media/test_audio.mp3 ]]; then | |
| echo "Audio file was not created" | |
| exit 1 | |
| fi | |
| file_size=$(stat -f%z test-media/test_audio.mp3 2>/dev/null || stat -c%s test-media/test_audio.mp3) | |
| if [[ $file_size -lt 1000 ]]; then | |
| echo "Audio file is too small: $file_size bytes" | |
| exit 1 | |
| fi | |
| echo "Audio test passed: $file_size bytes" | |
| - name: Test help command | |
| shell: bash | |
| run: | | |
| if [[ "${{ matrix.os }}" == "windows-latest" ]]; then | |
| ./zig-out/bin/media-gen.exe help | |
| else | |
| ./zig-out/bin/media-gen help | |
| fi | |
| - name: Test invalid command | |
| shell: bash | |
| run: | | |
| set +e # Don't exit on error | |
| if [[ "${{ matrix.os }}" == "windows-latest" ]]; then | |
| ./zig-out/bin/media-gen.exe invalid_command | |
| else | |
| ./zig-out/bin/media-gen invalid_command | |
| fi | |
| exit_code=$? | |
| if [[ $exit_code -eq 0 ]]; then | |
| echo "Expected non-zero exit code for invalid command" | |
| exit 1 | |
| fi | |
| echo "Invalid command test passed" | |
| performance-tests: | |
| name: Performance Tests | |
| runs-on: ubuntu-latest | |
| if: > | |
| github.event.inputs.test_type == 'all' || | |
| github.event.inputs.test_type == 'performance' || | |
| github.event_name == 'schedule' || | |
| github.event_name == 'workflow_run' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Cache FFmpeg binaries | |
| uses: actions/cache@v4 | |
| with: | |
| path: src/vendor/ffmpeg | |
| key: ffmpeg-binaries-${{ runner.os }}-v1 | |
| restore-keys: | | |
| ffmpeg-binaries-${{ runner.os }}- | |
| - name: Setup Zig | |
| uses: mlugg/setup-zig@v2 | |
| with: | |
| version: 0.15.1 | |
| - name: Cache Zig build | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| .zig-cache | |
| zig-out | |
| key: zig-build-perf-${{ runner.os }}-${{ hashFiles('build.zig', 'src/**/*.zig') }} | |
| restore-keys: | | |
| zig-build-perf-${{ runner.os }}- | |
| - name: Build application (embedded FFmpeg) | |
| run: zig build -Doptimize=ReleaseFast | |
| - name: Performance test - Video generation | |
| run: | | |
| mkdir -p test-media | |
| echo "Testing video generation performance..." | |
| time ./zig-out/bin/media-gen video --duration 3 --width 480 --height 360 \ | |
| --output test-media/perf_test_video.mp4 | |
| file_size=$(stat -c%s test-media/perf_test_video.mp4) | |
| echo "Generated video size: $file_size bytes" | |
| - name: Performance test - Audio generation | |
| run: | | |
| echo "Testing audio generation performance..." | |
| time ./zig-out/bin/media-gen audio --duration 3 --sample-rate 22050 --output test-media/perf_test_audio.mp3 | |
| file_size=$(stat -c%s test-media/perf_test_audio.mp3) | |
| echo "Generated audio size: $file_size bytes" |