Skip to content

Commit d0f7265

Browse files
committed
Update github actions config
1 parent 029d7b7 commit d0f7265

9 files changed

Lines changed: 207 additions & 2 deletions

File tree

.github/scripts/timestamp.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import os
2+
import subprocess
3+
import sys
4+
5+
OUT_DIR = "../out"
6+
HASH_FILE = os.path.join(OUT_DIR, "hashes.txt")
7+
8+
def main():
9+
# 1. Load stored hashes from the previous build (restored from cache)
10+
stored_map = {} # path -> hash
11+
if os.path.exists(HASH_FILE):
12+
try:
13+
with open(HASH_FILE, "r") as f:
14+
for line in f:
15+
parts = line.strip().split(" ", 1)
16+
if len(parts) == 2:
17+
stored_map[parts[1]] = parts[0]
18+
except Exception as e:
19+
print(f"Warning: Could not read hashes.txt: {e}")
20+
21+
# 2. Get current files from git to compare
22+
# We expect to be running inside the linux submodule directory
23+
cmd = ["git", "ls-tree", "-r", "HEAD"]
24+
result = subprocess.run(cmd, capture_output=True, text=True)
25+
if result.returncode != 0:
26+
print("Error running git ls-tree")
27+
sys.exit(1)
28+
29+
lines = result.stdout.splitlines()
30+
new_hashes = []
31+
32+
# Timestamp for "unchanged" files: 2020-01-01 00:00:00 UTC
33+
# This ensures they are older than any build artifacts in 'out/'
34+
OLD_TIME = 1577836800
35+
36+
matched_count = 0
37+
total_count = 0
38+
39+
for line in lines:
40+
# git ls-tree output: <mode> <type> <hash> <path>
41+
try:
42+
meta, path = line.split("\t", 1)
43+
meta_parts = meta.split()
44+
if len(meta_parts) < 3: continue
45+
obj_hash = meta_parts[2]
46+
47+
# Save current state for the next build
48+
new_hashes.append(f"{obj_hash} {path}")
49+
total_count += 1
50+
51+
# If the file content hasn't changed since the cached build,
52+
# set its timestamp to the past so 'make' considers the cached object valid.
53+
if path in stored_map and stored_map[path] == obj_hash:
54+
try:
55+
os.utime(path, (OLD_TIME, OLD_TIME))
56+
matched_count += 1
57+
except OSError:
58+
pass
59+
except ValueError:
60+
continue
61+
62+
print(f"Restored timestamps for {matched_count}/{total_count} files.")
63+
64+
# 3. Write new hashes for the next build
65+
new_hashes.sort(key=lambda x: x.split(" ", 1)[1])
66+
try:
67+
with open(HASH_FILE, "w") as f:
68+
for item in new_hashes:
69+
f.write(item + "\n")
70+
except Exception as e:
71+
print(f"Error writing hashes.txt: {e}")
72+
73+
if __name__ == "__main__":
74+
main()

.github/workflows/ci.yml

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,87 @@ on:
66
jobs:
77
build:
88
runs-on: ubuntu-latest
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
arch: [x86_64, arm64, riscv, loongarch, arm]
13+
config: [generic.config]
14+
include:
15+
- arch: x86_64
16+
config: generic.config no-jump-label.config
917

1018
steps:
1119
- uses: actions/checkout@v4
12-
- name: Run a one-line script
13-
run: echo "Hello, GitHub Actions!"
20+
with:
21+
submodules: true
22+
- name: Install dependencies
23+
run: |
24+
sudo apt-get update
25+
sudo apt-get install -y build-essential libncurses-dev bison flex libssl-dev libelf-dev bc clang lld llvm
26+
- name: Install Rust
27+
uses: dtolnay/rust-toolchain@stable
28+
with:
29+
components: rust-src
30+
- name: Install bindgen
31+
run: cargo install bindgen-cli
32+
- name: Configure kernel
33+
run: |
34+
mkdir -p out
35+
make -C linux O=../out LLVM=1 ARCH=${{ matrix.arch }} allnoconfig
36+
37+
MERGE_LIST="configs/${{ matrix.arch }}.config"
38+
for conf in ${{ matrix.config }}; do
39+
MERGE_LIST="$MERGE_LIST configs/$conf"
40+
done
41+
42+
linux/scripts/kconfig/merge_config.sh -m -O out out/.config $MERGE_LIST
43+
make -C linux O=../out LLVM=1 ARCH=${{ matrix.arch }} olddefconfig
44+
cp out/.config config
45+
- name: Print kernel configuration
46+
run: cat config
47+
- name: Load from cache
48+
uses: actions/cache@v4
49+
with:
50+
path: out
51+
key: kernel-${{ matrix.arch }}-${{ matrix.config }}-${{ hashFiles('out/.config') }}-${{ github.sha }}
52+
restore-keys: |
53+
kernel-${{ matrix.arch }}-${{ matrix.config }}-${{ hashFiles('out/.config') }}-
54+
- name: Set up incremental compilation
55+
run: |
56+
cmp -s config out/.config || cp config out/.config
57+
cd linux && python3 ../.github/scripts/timestamp.py
58+
- name: Check Rust availability
59+
run: make -C linux O=../out LLVM=1 ARCH=${{ matrix.arch }} rustavailable
60+
- name: Build kernel
61+
run: |
62+
make -C linux O=../out LLVM=1 ARCH=${{ matrix.arch }} -j$(nproc)
63+
- name: Build rustdoc
64+
run: |
65+
make -C linux O=../out LLVM=1 ARCH=${{ matrix.arch }} rustdoc
66+
67+
rustfmt:
68+
runs-on: ubuntu-latest
69+
steps:
70+
- uses: actions/checkout@v4
71+
with:
72+
submodules: true
73+
- name: Install dependencies
74+
run: |
75+
sudo apt-get update
76+
sudo apt-get install -y build-essential libncurses-dev bison flex libssl-dev libelf-dev bc clang lld llvm
77+
- uses: dtolnay/rust-toolchain@stable
78+
with:
79+
components: rustfmt, rust-src
80+
- name: Check formatting
81+
run: make -C linux LLVM=1 rustfmt
82+
83+
checkpatch:
84+
runs-on: ubuntu-latest
85+
steps:
86+
- uses: actions/checkout@v4
87+
with:
88+
submodules: true
89+
fetch-depth: 2
90+
- name: Run checkpatch
91+
working-directory: linux
92+
run: ./scripts/checkpatch.pl --git HEAD

configs/arm.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CONFIG_MMU=y
2+
CONFIG_RUST=y
3+
CONFIG_DRM_TYR=m
4+
CONFIG_ARCH_MULTI_V7=y

configs/arm64.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CONFIG_MMU=y
2+
CONFIG_RUST=y
3+
CONFIG_DRM_TYR=m

configs/generic.config

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
CONFIG_ANDROID_BINDER_IPC_RUST=y
2+
3+
CONFIG_PCI=y
4+
CONFIG_COMPAT=y
5+
CONFIG_JUMP_LABEL=y
6+
CONFIG_RUST_FW_LOADER_ABSTRACTIONS=y
7+
CONFIG_KUNIT=y
8+
CONFIG_RUST_KERNEL_DOCTESTS=y
9+
10+
CONFIG_DRM=y
11+
CONFIG_DRM_NOVA=m
12+
CONFIG_NOVA_CORE=m
13+
14+
CONFIG_AMCC_QT2025_PHY=m
15+
CONFIG_BLK_DEV_RUST_NULL=m
16+
17+
CONFIG_AX88796B_PHY=m
18+
CONFIG_AX88796B_RUST_PHY=y
19+
20+
CONFIG_SAMPLE_RUST_CONFIGFS=m
21+
CONFIG_SAMPLE_RUST_MINIMAL=m
22+
CONFIG_SAMPLE_RUST_MISC_DEVICE=m
23+
CONFIG_SAMPLE_RUST_PRINT=m
24+
CONFIG_SAMPLE_RUST_DMA=m
25+
CONFIG_SAMPLE_RUST_DEBUGFS=m
26+
CONFIG_SAMPLE_RUST_DEBUGFS_SCOPED=m
27+
CONFIG_SAMPLE_RUST_DRIVER_I2C=m
28+
CONFIG_SAMPLE_RUST_I2C_CLIENT=m
29+
CONFIG_SAMPLE_RUST_DRIVER_PCI=m
30+
CONFIG_SAMPLE_RUST_DRIVER_PLATFORM=m
31+
CONFIG_SAMPLE_RUST_DRIVER_USB=m
32+
CONFIG_SAMPLE_RUST_DRIVER_FAUX=m
33+
CONFIG_SAMPLE_RUST_DRIVER_AUXILIARY=m
34+
CONFIG_SAMPLE_RUST_HOSTPROGS=y

configs/loongarch.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CONFIG_MMU=y
2+
CONFIG_RUST=y
3+

configs/no-jump-label.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# CONFIG_JUMP_LABEL is not set

configs/riscv.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CONFIG_MMU=y
2+
CONFIG_RUST=y
3+
4+
CONFIG_PWM_TH1520=m

configs/x86_64.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CONFIG_MMU=y
2+
CONFIG_RUST=y
3+

0 commit comments

Comments
 (0)