ratatui-image-8.1.1/.cargo_vcs_info.json 0000644 00000000136 00000000001 0013574 0 ustar { "git": { "sha1": "005539a5506eba1ffec44e54852694e2e9854a44" }, "path_in_vcs": "" } ratatui-image-8.1.1/.envrc 0000644 0000000 0000000 00000000012 10461020230 0013473 0 ustar 0000000 0000000 use flake ratatui-image-8.1.1/.github/workflows/ci.yaml 0000644 0000000 0000000 00000032231 10461020230 0017241 0 ustar 0000000 0000000 name: CI on: # Allows you to run this workflow manually from the Actions tab workflow_dispatch: push: branches: - master - ci pull_request: branches: - master pull_request_target: merge_group: workflow_call: concurrency: group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true env: CLICOLOR_FORCE: 1 jobs: ensure-readme-up-to-date: name: Ensure readme is up-to-date runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Install rust uses: actions-rs/toolchain@v1 with: toolchain: 1.88.0 profile: default override: true - uses: davidB/rust-cargo-make@v1 - name: Make readme run: cargo make readme - name: Ensure no changes run: git diff --exit-code . nix-flake-test: name: Flake check runs-on: ubuntu-latest steps: - name: Checkout Code uses: actions/checkout@v4 - name: Install Nix uses: cachix/install-nix-action@v24 - name: Cachix uses: cachix/cachix-action@v12 with: name: ratatui-image-ci authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - name: Flake check run: | nix flake show nix flake check --print-build-logs nix-build: name: Nix build runs-on: ubuntu-latest outputs: artifact_path: ${{ steps.upload-artifact.outputs.artifact_path }} steps: - name: Checkout Code uses: actions/checkout@v4 - name: Install Nix uses: cachix/install-nix-action@v24 - name: Cachix uses: cachix/cachix-action@v12 with: name: ratatui-image-ci authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - name: Build package run: | nix build . --print-build-logs nix-build-windows: name: Nix build (windows) runs-on: ubuntu-latest outputs: artifact_path: ${{ steps.upload-artifact.outputs.artifact_path }} steps: - name: Checkout Code uses: actions/checkout@v4 - name: Install Nix uses: cachix/install-nix-action@v24 - name: Cachix uses: cachix/cachix-action@v12 with: name: ratatui-image-ci authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - name: Build package run: | nix build .#windows --print-build-logs setup-terminals: name: Setup terminals list runs-on: ubuntu-latest outputs: terminals: ${{ steps.set-terminals.outputs.terminals }} steps: - name: Checkout Code uses: actions/checkout@v4 - name: Install Nix uses: cachix/install-nix-action@v24 - id: set-terminals run: | terminals=$(nix eval --raw --impure --expr 'let flake = builtins.getFlake (toString ./.); pkgs = flake.packages.x86_64-linux; terminals = builtins.filter (name: builtins.substring 0 15 name == "screenshot-test") (builtins.attrNames pkgs); in builtins.toJSON (map (t: builtins.substring 16 (-1) t) terminals)') echo "terminals=$terminals" >> $GITHUB_OUTPUT nix-flake-screenshots: name: Screenshot tests runs-on: ubuntu-latest needs: [nix-build, setup-terminals] permissions: contents: read strategy: matrix: terminal: ${{ fromJSON(needs.setup-terminals.outputs.terminals) }} steps: - name: Checkout Code uses: actions/checkout@v4 - name: Install Nix uses: cachix/install-nix-action@v24 - name: Cachix uses: cachix/cachix-action@v12 with: name: ratatui-image-ci authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - name: Run screenshot test for ${{ matrix.terminal }} run: | nix build .#screenshot-test-${{ matrix.terminal }} --print-build-logs - name: Upload screenshot artifact uses: actions/upload-artifact@v4 with: name: screenshot-${{ matrix.terminal }} path: result/screenshot-${{ matrix.terminal }}.png deploy-screenshots-branch: name: Deploy screenshots branch runs-on: ubuntu-latest needs: [nix-flake-screenshots, setup-terminals] if: github.event_name == 'pull_request_target' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) permissions: contents: read pull-requests: write # This is needed for PR comments steps: - name: Download all screenshot artifacts uses: actions/download-artifact@v4 with: pattern: screenshot-* path: screenshots - name: Download dify binary run: | curl -L https://github.com/jihchi/dify/releases/download/v0.7.4/dify-x86_64-unknown-linux-gnu-v0.7.4.tar.gz -o dify.tar.gz tar -xzf dify.tar.gz chmod +x dify - name: Download reference screenshots from master run: | mkdir -p reference-screenshots # Base URL for master branch screenshots BASE_URL="https://raw.githubusercontent.com/benjajaja/ratatui-image-screenshots/gh-pages/images" terminals='${{ needs.setup-terminals.outputs.terminals }}' terminal_list=$(echo "$terminals" | jq -r '.[]' | tr '\n' ' ') for terminal in $terminal_list; do echo "Downloading reference screenshot for ${terminal}..." curl -f -L "${BASE_URL}/screenshot-${terminal}.png" -o "reference-screenshots/screenshot-${terminal}.png" || echo "No reference screenshot found for ${terminal}" done - name: Create image diffs run: | mkdir -p diffs terminals='${{ needs.setup-terminals.outputs.terminals }}' terminal_list=$(echo "$terminals" | jq -r '.[]' | tr '\n' ' ') for terminal in $terminal_list; do if [ -f "screenshots/screenshot-${terminal}/screenshot-${terminal}.png" ] && [ -f "reference-screenshots/screenshot-${terminal}.png" ]; then echo "Creating diff for ${terminal}..." # Run dify and capture exit code (which indicates amount of difference) set +e # Disable exit on error temporarily ./dify "reference-screenshots/screenshot-${terminal}.png" "screenshots/screenshot-${terminal}/screenshot-${terminal}.png" diff_amount=$? set -e # Re-enable exit on error echo "Difference amount for ${terminal}: ${diff_amount}" # Check if diff.png was created and move it if [ -f "diff.png" ]; then mv diff.png "diffs/diff-${terminal}.png" echo "Created diff for ${terminal}" else echo "No diff.png file created for ${terminal}" fi else echo "Missing screenshot files for ${terminal}, skipping diff" if [ ! -f "screenshots/screenshot-${terminal}/screenshot-${terminal}.png" ]; then echo " Missing current screenshot" fi if [ ! -f "reference-screenshots/screenshot-${terminal}.png" ]; then echo " Missing reference screenshot" fi fi done - name: Organize screenshots for deployment run: | mkdir -p pages # Copy screenshots to pages directory terminals='${{ needs.setup-terminals.outputs.terminals }}' terminal_list=$(echo "$terminals" | jq -r '.[]' | tr '\n' ' ') for terminal in $terminal_list; do if [ -f "screenshots/screenshot-${terminal}/screenshot-${terminal}.png" ]; then cp "screenshots/screenshot-${terminal}/screenshot-${terminal}.png" "pages/screenshot-${terminal}.png" echo "Copied screenshot for ${terminal}" fi done # Copy diff images to pages directory for terminal in $terminal_list; do if [ -f "diffs/diff-${terminal}.png" ]; then cp "diffs/diff-${terminal}.png" "pages/diff-${terminal}.png" echo "Copied diff for ${terminal}" fi done - name: Deploy to external repo uses: peaceiris/actions-gh-pages@v3 with: personal_token: ${{ secrets.PAT }} external_repository: benjajaja/ratatui-image-screenshots publish_dir: ./pages publish_branch: pr-${{ github.event.pull_request.number }} force_orphan: true - name: Create combined comment run: | terminals='${{ needs.setup-terminals.outputs.terminals }}' terminal_list=$(echo "$terminals" | jq -r '.[]' | tr '\n' ' ') # Base URL for raw GitHub content BASE_URL="https://raw.githubusercontent.com/benjajaja/ratatui-image-screenshots/pr-${{ github.event.pull_request.number }}" # Initialize comment body echo "Merge of ${{ github.sha }} to \`master\`" > comment_body.txt echo "" >> comment_body.txt echo "Screenshots from all terminal emulators:" >> comment_body.txt echo "" >> comment_body.txt for terminal in $terminal_list; do echo "### ${terminal}" >> comment_body.txt echo "" >> comment_body.txt echo "" >> comment_body.txt # Check if diff image exists by trying to fetch it diff_url="${BASE_URL}/diff-${terminal}.png" if curl -f -s -I "$diff_url" > /dev/null 2>&1; then echo "**Image diff vs master:**" >> comment_body.txt echo "" >> comment_body.txt echo "" >> comment_body.txt else echo "**No diff available** (no changes detected)" >> comment_body.txt echo "" >> comment_body.txt fi done - name: Comment on PR with all screenshots uses: marocchino/sticky-pull-request-comment@v2 with: path: comment_body.txt deploy-screenshots-master: name: Deploy master screenshots to external repo runs-on: ubuntu-latest needs: [nix-flake-screenshots, setup-terminals] if: | (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') && github.event_name != 'pull_request_target' permissions: contents: read steps: - name: Checkout uses: actions/checkout@v4 - name: Download all screenshot artifacts uses: actions/download-artifact@v4 with: pattern: screenshot-* path: screenshots merge-multiple: false - name: Organize screenshots for Pages run: | mkdir -p pages/images # Move screenshot images to pages/images directory terminals='${{ needs.setup-terminals.outputs.terminals }}' terminal_list=$(echo "$terminals" | jq -r '.[]' | tr '\n' ' ') for terminal in $terminal_list; do if [ -f "screenshots/screenshot-${terminal}/screenshot-${terminal}.png" ]; then cp "screenshots/screenshot-${terminal}/screenshot-${terminal}.png" "pages/images/screenshot-${terminal}.png" echo "Copied screenshot for ${terminal}" else echo "Warning: Screenshot file not found for ${terminal}" fi done # Create an index page with timestamp timestamp=$(date -u '+%Y-%m-%d %H:%M:%S UTC') cat > pages/index.html << EOF
Screenshots from various terminal emulators
Last updated: ${timestamp}
EOF # Add screenshots to index using local images for terminal in $terminal_list; do echo "
" >> pages/index.html
else
echo "No screenshot available
" >> pages/index.html fi echo "