Skip to content

Commit

Permalink
CI: add system build (#251)
Browse files Browse the repository at this point in the history
* incremental caching

* increase timeout to 40min; remove if: cache-hits

* rm that

* simplified to have one kernel cache

* [upload] tag for upload-artifact

* [upload] test

* custom key/restore for ccache

* removed if in get commit message

* timeout to 60min

* multiline support in LAST_COMMIT_MESSAGE

* Update .github/workflows/build.yaml

---------

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
  • Loading branch information
andiradulescu and adeebshihadeh authored Jul 21, 2024
1 parent 4b70df3 commit 8612508
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 23 deletions.
61 changes: 41 additions & 20 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,31 @@ permissions:

jobs:
build:
name: build kernel #and system
name: build kernel and system
runs-on: namespace-profile-arm64-8x16-2004-caching
timeout-minutes: 20
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
with:
lfs: true

- name: get kernel submodule ref
- name: Get commit message
run: |
{
echo 'LAST_COMMIT_MESSAGE<<EOF'
if [ "${{ github.event_name }}" == "push" ]; then
echo "${{ github.event.head_commit.message }}"
elif [ "${{ github.event_name }}" == "workflow_run" ]; then
echo "${{ github.event.workflow_run.head_commit.message }}"
elif [ "${{ github.event_name }}" == "pull_request" ]; then
echo "$(curl -s '${{ github.event.pull_request.commits_url }}' | jq -r '.[-1].commit.message')"
fi
echo EOF
} | tee -a $GITHUB_ENV
- name: Get kernel submodule ref
id: kernel-submodule
run: echo "ref=$(git ls-tree HEAD | awk '$4 == "agnos-kernel-sdm845"' | awk '{print $3}')" >> "$GITHUB_OUTPUT"
run: echo "ref=$(git ls-tree HEAD | awk '$4 == "agnos-kernel-sdm845"' | awk '{print $3}')" | tee -a $GITHUB_OUTPUT

- name: Checkout agnos-kernel-sdm845
uses: actions/checkout@v4
Expand All @@ -34,6 +48,13 @@ jobs:
ref: ${{ steps.kernel-submodule.outputs.ref }}
path: agnos-kernel-sdm845

- name: ccache
uses: hendrikmuhs/ccache-action@c92f40bee50034e84c763e33b317c77adaa81c92
with:
create-symlink: true
key: kernel-ccache-${{ steps.kernel-submodule.outputs.ref }}
restore-keys: kernel-ccache-

- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y bc img2simg

Expand All @@ -42,29 +63,29 @@ jobs:
with:
default: '2.7.18'

- name: Cache kernel build
uses: actions/cache@v4
id: cache-kernel
with:
key: kernel-${{ steps.kernel-submodule.outputs.ref }}
path: |
agnos-kernel-sdm845/out
restore-keys: kernel-

- name: Build kernel
run: ./build_kernel.sh

- uses: actions/upload-artifact@v4
- name: Upload artifact boot.img
uses: actions/upload-artifact@v4
if: "contains(env.LAST_COMMIT_MESSAGE, '[upload]')"
with:
name: boot.img
path: output/boot.img
- uses: actions/upload-artifact@v4

- name: Upload artifact kernel modules
uses: actions/upload-artifact@v4
if: "contains(env.LAST_COMMIT_MESSAGE, '[upload]')"
with:
name: kernel-modules
path: output/*.ko

#- run: ./build_system.sh
#- uses: actions/upload-artifact@v4
# with:
# name: system.img
# path: output/system.img
- name: Build system
run: ./build_system.sh

- name: Upload artifact system.img
uses: actions/upload-artifact@v4
if: "contains(env.LAST_COMMIT_MESSAGE, '[upload]')"
with:
name: system.img
path: output/system.img
6 changes: 3 additions & 3 deletions build_system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ SKIP_CHUNKS_IMAGE="$OUTPUT_DIR/system-skip-chunks.img"
# Create temp dir if non-existent
mkdir -p $BUILD_DIR $OUTPUT_DIR

# Copy kernel modules over
# Copy kernel modules
if ! ls $OUTPUT_DIR/*.ko >/dev/null 2>&1; then
echo "kernel modules missing. run ./build_kernel.sh first"
echo "Kernel modules missing. Run ./build_kernel.sh first"
exit 1
fi
cp $OUTPUT_DIR/wlan.ko $DIR/userspace/usr/comma
Expand All @@ -33,7 +33,7 @@ cp $OUTPUT_DIR/snd*.ko $DIR/userspace/usr/comma/sound/
# Download Ubuntu Base if not done already
if [ ! -f $UBUNTU_FILE ]; then
echo -e "${GREEN}Downloading Ubuntu: $UBUNTU_FILE ${NO_COLOR}"
curl -C - -o $UBUNTU_FILE $UBUNTU_BASE_URL/$UBUNTU_FILE --silent
curl -C - -o $UBUNTU_FILE $UBUNTU_BASE_URL/$UBUNTU_FILE --silent --remote-time
fi

# Register qemu multiarch
Expand Down

0 comments on commit 8612508

Please sign in to comment.