-
Notifications
You must be signed in to change notification settings - Fork 0
182 lines (170 loc) · 6.52 KB
/
ci.yml
File metadata and controls
182 lines (170 loc) · 6.52 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: ci
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- id: calculate_hash
name: Calculate source file hash
run: |-
set -e
echo 'Calculating source file hash...'
TEMP_HASH_FILE="/tmp/source_files_for_hash"
rm -f "$TEMP_HASH_FILE"
find . -path './src/**/*.rs' -type f 2>/dev/null | sort >> "$TEMP_HASH_FILE" || true
find . -path './Cargo.toml' -type f 2>/dev/null | sort >> "$TEMP_HASH_FILE" || true
find . -path './Cargo.lock' -type f 2>/dev/null | sort >> "$TEMP_HASH_FILE" || true
if [ -s "$TEMP_HASH_FILE" ]; then
# Calculate hash of file contents
JOB_HASH=$(xargs -I{{}} sh -c 'cat "{{}}"' < "$TEMP_HASH_FILE" | sha256sum | cut -d' ' -f1)
echo "Hash calculated: $JOB_HASH"
echo "JOB_HASH=$JOB_HASH" >> $GITHUB_ENV
else
JOB_HASH="empty"
echo "No source files found, using empty hash"
echo "JOB_HASH=$JOB_HASH" >> $GITHUB_ENV
fi
shell: bash
- id: check_skip
name: Check if job should be skipped
run: |-
set -e
SKIP_CACHE_DIR="/tmp/cigen_skip_cache"
SKIP_MARKER="$SKIP_CACHE_DIR/job_${{JOB_HASH}}_amd64"
if [ -f "$SKIP_MARKER" ]; then
echo "✓ Job already completed successfully for this file hash. Skipping..."
exit 0
else
echo "→ No previous successful run found. Proceeding with job..."
mkdir -p "$SKIP_CACHE_DIR"
fi
shell: bash
- name: Format check
run: cargo fmt -- --check
- id: record_completion
name: Record job completion
run: |-
set -e
SKIP_CACHE_DIR="/tmp/cigen_skip_cache"
SKIP_MARKER="$SKIP_CACHE_DIR/job_${{JOB_HASH}}_amd64"
echo "Recording successful completion for hash ${{JOB_HASH}}"
mkdir -p "$SKIP_CACHE_DIR"
echo "$(date): Job completed successfully" > "$SKIP_MARKER"
shell: bash
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- id: calculate_hash
name: Calculate source file hash
run: |-
set -e
echo 'Calculating source file hash...'
TEMP_HASH_FILE="/tmp/source_files_for_hash"
rm -f "$TEMP_HASH_FILE"
find . -path './src/**/*.rs' -type f 2>/dev/null | sort >> "$TEMP_HASH_FILE" || true
find . -path './Cargo.toml' -type f 2>/dev/null | sort >> "$TEMP_HASH_FILE" || true
find . -path './Cargo.lock' -type f 2>/dev/null | sort >> "$TEMP_HASH_FILE" || true
find . -path './tests/**/*.rs' -type f 2>/dev/null | sort >> "$TEMP_HASH_FILE" || true
find . -path './tests/**/*.yml' -type f 2>/dev/null | sort >> "$TEMP_HASH_FILE" || true
find . -path './tests/**/*.trycmd' -type f 2>/dev/null | sort >> "$TEMP_HASH_FILE" || true
find . -path './examples/**/*.yml' -type f 2>/dev/null | sort >> "$TEMP_HASH_FILE" || true
find . -path './examples/**/*.yaml' -type f 2>/dev/null | sort >> "$TEMP_HASH_FILE" || true
if [ -s "$TEMP_HASH_FILE" ]; then
# Calculate hash of file contents
JOB_HASH=$(xargs -I{{}} sh -c 'cat "{{}}"' < "$TEMP_HASH_FILE" | sha256sum | cut -d' ' -f1)
echo "Hash calculated: $JOB_HASH"
echo "JOB_HASH=$JOB_HASH" >> $GITHUB_ENV
else
JOB_HASH="empty"
echo "No source files found, using empty hash"
echo "JOB_HASH=$JOB_HASH" >> $GITHUB_ENV
fi
shell: bash
- id: check_skip
name: Check if job should be skipped
run: |-
set -e
SKIP_CACHE_DIR="/tmp/cigen_skip_cache"
SKIP_MARKER="$SKIP_CACHE_DIR/job_${{JOB_HASH}}_amd64"
if [ -f "$SKIP_MARKER" ]; then
echo "✓ Job already completed successfully for this file hash. Skipping..."
exit 0
else
echo "→ No previous successful run found. Proceeding with job..."
mkdir -p "$SKIP_CACHE_DIR"
fi
shell: bash
- name: Run tests
run: cargo test --all-features
- id: record_completion
name: Record job completion
run: |-
set -e
SKIP_CACHE_DIR="/tmp/cigen_skip_cache"
SKIP_MARKER="$SKIP_CACHE_DIR/job_${{JOB_HASH}}_amd64"
echo "Recording successful completion for hash ${{JOB_HASH}}"
mkdir -p "$SKIP_CACHE_DIR"
echo "$(date): Job completed successfully" > "$SKIP_MARKER"
shell: bash
clippy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- id: calculate_hash
name: Calculate source file hash
run: |-
set -e
echo 'Calculating source file hash...'
TEMP_HASH_FILE="/tmp/source_files_for_hash"
rm -f "$TEMP_HASH_FILE"
find . -path './src/**/*.rs' -type f 2>/dev/null | sort >> "$TEMP_HASH_FILE" || true
find . -path './Cargo.toml' -type f 2>/dev/null | sort >> "$TEMP_HASH_FILE" || true
find . -path './Cargo.lock' -type f 2>/dev/null | sort >> "$TEMP_HASH_FILE" || true
if [ -s "$TEMP_HASH_FILE" ]; then
# Calculate hash of file contents
JOB_HASH=$(xargs -I{{}} sh -c 'cat "{{}}"' < "$TEMP_HASH_FILE" | sha256sum | cut -d' ' -f1)
echo "Hash calculated: $JOB_HASH"
echo "JOB_HASH=$JOB_HASH" >> $GITHUB_ENV
else
JOB_HASH="empty"
echo "No source files found, using empty hash"
echo "JOB_HASH=$JOB_HASH" >> $GITHUB_ENV
fi
shell: bash
- id: check_skip
name: Check if job should be skipped
run: |-
set -e
SKIP_CACHE_DIR="/tmp/cigen_skip_cache"
SKIP_MARKER="$SKIP_CACHE_DIR/job_${{JOB_HASH}}_amd64"
if [ -f "$SKIP_MARKER" ]; then
echo "✓ Job already completed successfully for this file hash. Skipping..."
exit 0
else
echo "→ No previous successful run found. Proceeding with job..."
mkdir -p "$SKIP_CACHE_DIR"
fi
shell: bash
- name: Clippy check
run: cargo clippy --all-targets --all-features -- -D warnings
- id: record_completion
name: Record job completion
run: |-
set -e
SKIP_CACHE_DIR="/tmp/cigen_skip_cache"
SKIP_MARKER="$SKIP_CACHE_DIR/job_${{JOB_HASH}}_amd64"
echo "Recording successful completion for hash ${{JOB_HASH}}"
mkdir -p "$SKIP_CACHE_DIR"
echo "$(date): Job completed successfully" > "$SKIP_MARKER"
shell: bash