-
Notifications
You must be signed in to change notification settings - Fork 6
117 lines (101 loc) · 3.26 KB
/
pr-preview.yml
File metadata and controls
117 lines (101 loc) · 3.26 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
name: PR Preview
on:
pull_request:
types: [opened, synchronize, reopened]
env:
CARGO_TERM_COLOR: always
jobs:
quick-check:
name: Quick Check
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-quick-${{ hashFiles('**/Cargo.lock') }}
- name: Check format
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --all-targets --all-features
- name: Check build
run: cargo check --all-features
- name: Run quick tests
run: cargo test --lib
changes:
name: Detect Changes
runs-on: ubuntu-latest
outputs:
src: ${{ steps.changes.outputs.src }}
docs: ${{ steps.changes.outputs.docs }}
workflows: ${{ steps.changes.outputs.workflows }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
src:
- 'src/**'
- 'Cargo.toml'
- 'Cargo.lock'
docs:
- '**.md'
- 'docs/**'
workflows:
- '.github/workflows/**'
test-if-needed:
name: Test if Source Changed
runs-on: ubuntu-latest
needs: changes
if: needs.changes.outputs.src == 'true'
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
- name: Run full test suite
run: cargo test --all-features
summary:
name: PR Preview Summary
runs-on: ubuntu-latest
needs: [quick-check, changes, test-if-needed]
if: always()
steps:
- name: Summary
run: |
echo "## PR Preview Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Quick Check**: ${{ needs.quick-check.result }}" >> $GITHUB_STEP_SUMMARY
if [[ "${{ needs.changes.outputs.src }}" == "true" ]]; then
echo "- **Full Tests**: ${{ needs.test-if-needed.result }}" >> $GITHUB_STEP_SUMMARY
else
echo "- **Full Tests**: Skipped (no source changes)" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Changed Files" >> $GITHUB_STEP_SUMMARY
if [[ "${{ needs.changes.outputs.src }}" == "true" ]]; then
echo "- ✅ Source code" >> $GITHUB_STEP_SUMMARY
fi
if [[ "${{ needs.changes.outputs.docs }}" == "true" ]]; then
echo "- 📚 Documentation" >> $GITHUB_STEP_SUMMARY
fi
if [[ "${{ needs.changes.outputs.workflows }}" == "true" ]]; then
echo "- ⚙️ GitHub Actions workflows" >> $GITHUB_STEP_SUMMARY
fi