forked from odudex/Kern
-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (76 loc) · 2.97 KB
/
Copy pathtest-each-commit.yml
File metadata and controls
86 lines (76 loc) · 2.97 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
name: Commit history checks
on:
pull_request:
jobs:
# First, enumerate the intermediate commits in the PR.
# Single-commit PRs are already fully covered by test-all-builds.yml,
# so there's nothing new to verify.
list-commits:
if: github.event.pull_request.commits > 1
runs-on: ubuntu-latest
outputs:
commits: ${{ steps.list.outputs.commits }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Trust workspace for git
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Fetch base branch
run: |
# NOT `--depth=1`: it marks the repo shallow at origin/master
# and `git log origin/master..HEAD~` can't walk past the
# boundary, returning the entire project history instead of
# the PR range. fetch-depth: 0 on actions/checkout already
# populated everything, so this is essentially free.
git fetch --no-tags --prune origin \
"+refs/heads/${GITHUB_BASE_REF}:refs/remotes/origin/${GITHUB_BASE_REF}"
- id: list
name: List intermediate commits
run: |
# HEAD is the PR tip -- already covered by test-all-builds.yml.
range="origin/${GITHUB_BASE_REF}..HEAD~"
# Emit "<full sha>\t<short sha> <subject>" per commit, then turn
# it into a JSON array of {sha, name} objects for matrix.include.
commits=$(git log --reverse --format='%H%x09%h %s' "$range" \
| jq -R -s -c '
split("\n")
| map(select(length > 0))
| map(split("\t"))
| map({sha: .[0], name: .[1]})
')
echo "Intermediate commits: $commits"
echo "commits=$commits" >> "$GITHUB_OUTPUT"
# Then run CI checks per commit in parallel inside the stable IDF image.
check-commit:
needs: list-commits
if: needs.list-commits.outputs.commits != '[]' && needs.list-commits.outputs.commits != ''
name: ${{ matrix.name }}
runs-on: ubuntu-latest
timeout-minutes: 360
container: espressif/idf:v6.0.1
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.list-commits.outputs.commits) }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ matrix.sha }}
submodules: 'recursive'
- name: Trust workspace for git
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Show commit
run: git log -1 --oneline
- name: Install clang-format
run: apt-get update && apt-get install -y clang-format
- name: Configure git identity (required by rebase)
run: |
git config user.email "ci@example.com"
git config user.name "CI"
- name: Run checks on each commit (excluding PR tip)
run: |
. $IDF_PATH/export.sh
bash scripts/ci-checks.sh