Repository navigation
128 lines (113 loc) · 4 KB
/
Copy pathgit-core-compat.yml
File metadata and controls
128 lines (113 loc) · 4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Git Core Compatibility
permissions:
contents: read
env:
GIT_COMPAT_URL: https://github.com/git/git.git
GIT_COMPAT_REF: v2.54.0
GIT_COMPAT_SHA: 94f057755b7941b321fd11fec1b2e3ca5313a4e0
GIT_COMPAT_CLEAN_SOURCE: "1"
on:
pull_request:
paths:
- 'src/**'
- 'tests/**'
- 'Cargo.toml'
- 'Cargo.lock'
- 'Taskfile.yml'
- 'flake.nix'
- 'flake.lock'
- '.github/workflows/git-core-compat.yml'
push:
branches: [main]
paths:
- 'src/**'
- 'tests/**'
- 'Cargo.toml'
- 'Cargo.lock'
- 'Taskfile.yml'
- 'flake.nix'
- 'flake.lock'
- '.github/workflows/git-core-compat.yml'
merge_group:
branches: [main]
jobs:
git-core-tests:
name: Run core Git tests with git-ai
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # master
with:
toolchain: stable
- name: Cache dependencies
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ubuntu-cargo-${{ hashFiles('Cargo.lock') }}
restore-keys: |
ubuntu-cargo-
- name: Cache git source
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: /tmp/git-core-tests
key: git-source-${{ runner.os }}-${{ env.GIT_COMPAT_SHA }}
- name: Clone git source
run: |
set -euo pipefail
if [ -L /tmp/git-core-tests ]; then
echo "::error::/tmp/git-core-tests is a symlink"
exit 1
fi
if [ -L /tmp/git-core-tests/.git ]; then
echo "::error::/tmp/git-core-tests/.git is a symlink"
exit 1
fi
if [ ! -d /tmp/git-core-tests/.git ]; then
if [ -e /tmp/git-core-tests ]; then
echo "::error::/tmp/git-core-tests exists but is not a Git checkout"
exit 1
fi
git clone --depth 1 --branch "$GIT_COMPAT_REF" "$GIT_COMPAT_URL" /tmp/git-core-tests
else
echo "Using cached git source"
fi
if git -C /tmp/git-core-tests remote get-url origin >/dev/null 2>&1; then
git -C /tmp/git-core-tests remote set-url origin "$GIT_COMPAT_URL"
else
git -C /tmp/git-core-tests remote add origin "$GIT_COMPAT_URL"
fi
git -C /tmp/git-core-tests fetch --depth 1 origin "$GIT_COMPAT_REF"
git -C /tmp/git-core-tests checkout --force --detach FETCH_HEAD
actual_sha="$(git -C /tmp/git-core-tests rev-parse HEAD)"
if [ "$actual_sha" != "$GIT_COMPAT_SHA" ]; then
echo "::error::Expected $GIT_COMPAT_REF to resolve to $GIT_COMPAT_SHA, got $actual_sha"
exit 1
fi
git -C /tmp/git-core-tests reset --hard "$GIT_COMPAT_SHA"
git -C /tmp/git-core-tests clean -ffdx
git -C /tmp/git-core-tests rev-parse HEAD
git -C /tmp/git-core-tests describe --tags --always --dirty
- name: Build git-ai
run: cargo build --release --bin git-ai
- name: Run core Git compatibility tests
timeout-minutes: 10
env:
PYTHONUNBUFFERED: "1"
run: python3 tests/git-compat/run-core-tests.py
- name: Clean git source before cache save
run: |
set -euo pipefail
if [ -L /tmp/git-core-tests ] || [ -L /tmp/git-core-tests/.git ] || [ ! -d /tmp/git-core-tests/.git ]; then
echo "::error::/tmp/git-core-tests is not a normal Git checkout"
exit 1
fi
git -C /tmp/git-core-tests reset --hard "$GIT_COMPAT_SHA"
git -C /tmp/git-core-tests clean -ffdx