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
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,23 @@ jobs:
- uses: actions/checkout@v6
- name: Check semver
uses: obi1kenobi/cargo-semver-checks-action@v2

replay:
strategy:
matrix:
include:
- name: diffy
repo_url: ''
commits: '0'
- name: rust-lang/cargo
repo_url: https://github.com/rust-lang/cargo
commits: '200'
- name: rust-lang/rust
repo_url: https://github.com/rust-lang/rust
commits: '30'
name: replay (${{ matrix.name }})
uses: ./.github/workflows/replay.yml
with:
name: ${{ matrix.name }}
repo_url: ${{ matrix.repo_url }}
commits: ${{ matrix.commits }}
29 changes: 29 additions & 0 deletions .github/workflows/replay-full.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Replay (Full History)

permissions:
contents: read

on:
push:
branches:
- master

jobs:
replay-full:
strategy:
matrix:
include:
- name: rust-lang/cargo
repo_url: https://github.com/rust-lang/cargo
- name: rust-lang/rustup
repo_url: https://github.com/rust-lang/rustup
- name: rust-lang/rust-analyzer
repo_url: https://github.com/rust-lang/rust-analyzer
- name: rust-lang/rust-clippy
repo_url: https://github.com/rust-lang/rust-clippy
name: ${{ matrix.name }}
uses: ./.github/workflows/replay.yml
with:
name: ${{ matrix.name }}
repo_url: ${{ matrix.repo_url }}
commits: '0'
74 changes: 74 additions & 0 deletions .github/workflows/replay.yml
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is handy and fun. See https://github.com/weihanglo/diffy/actions/workflows/replay.yml that I have run test against lots of different repository.

(https://github.com/llvm/llvm-project/ timed out though I ran it locally and passed!)

Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Replay

permissions:
contents: read

on:
workflow_call:
inputs:
name:
description: 'Display name (if set, job shows only parse_mode)'
required: false
default: ''
type: string
repo_url:
description: 'Git repository URL to clone and test against'
required: false
default: ''
type: string
commits:
description: 'Commits to replay: number (e.g., 200), range (e.g., abc..def), or 0 for all'
required: true
type: string

workflow_dispatch:
inputs:
repo_url:
description: 'Git repository URL to clone and test against'
required: true
type: string
commits:
description: 'Commits to replay: number (e.g., 200), range (e.g., abc..def), or 0 for all'
required: true
default: '200'
type: string

env:
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
CLICOLOR: 1
CI: 1

jobs:
replay:
runs-on: ubuntu-latest
strategy:
matrix:
parse_mode: [unidiff]
name: ${{ inputs.name && matrix.parse_mode || format('{0} ({1}, {2})', inputs.repo_url, matrix.parse_mode, inputs.commits) }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: ${{ inputs.repo_url && 1 || 0 }}
- if: inputs.repo_url != ''
env:
REPO_URL: ${{ inputs.repo_url }}
COMMITS: ${{ inputs.commits }}
run: |
set -euo pipefail
# Guard against non-numeric values when computing --depth.
# Range syntax (a..b) and "0" both require full history.
if [[ "$COMMITS" == *".."* || "$COMMITS" == "0" ]]; then
git clone "$REPO_URL" target/test-repo
elif [[ "$COMMITS" =~ ^[0-9]+$ ]]; then
git clone "$REPO_URL" --depth "$((COMMITS + 1))" target/test-repo
else
echo "invalid commits value: $COMMITS" >&2
exit 1
fi
- run: rustup toolchain install stable --profile minimal
- run: cargo test --release --test replay -- --ignored --nocapture
env:
DIFFY_TEST_REPO: ${{ inputs.repo_url == '' && '.' || 'target/test-repo' }}
DIFFY_TEST_COMMITS: ${{ inputs.commits }}
DIFFY_TEST_PARSE_MODE: ${{ matrix.parse_mode }}
52 changes: 52 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ color = ["dep:anstyle"]
anstyle = { version = "1.0.13", optional = true }

[dev-dependencies]
rayon = "1.10.0"
snapbox = { version = "0.6.24", features = ["dir"] }

[[example]]
Expand Down
Loading
Loading