Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 178 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
name: build

on:
workflow_call:
inputs:
machine:
type: string
default: 'all'
release:
type: boolean
default: false
cache:
type: boolean
default: false
sdk:
type: boolean
default: false
dry_run:
type: boolean
default: false

secrets:
YOCTOCACHE_KNOWN_HOST:
required: false
YOCTOCACHE_DEPLOY_KEY:
required: false
YOCTOCACHE_DEST:
required: false
YOCTOCACHE_PORT:
required: false

workflow_dispatch:
inputs:
machine:
type: choice
options:
- all
- daytona
- tank
default: 'all'
release:
type: boolean
default: false
cache:
type: boolean
default: false
sdk:
type: boolean
default: false
dry_run:
type: boolean
default: false

jobs:
image:
runs-on: ubuntu-latest

permissions:
contents: read

container:
image: joinframework/chronos-ci:latest
options: --privileged --user root --sysctl net.ipv6.conf.all.disable_ipv6=0

strategy:
fail-fast: false
matrix:
machine: ${{ inputs.machine == 'all' && fromJson('["daytona", "tank"]') || fromJson(format('["{0}"]', inputs.machine)) }}

defaults:
run:
shell: setpriv --reuid=chronos --regid=chronos --init-groups --inh-caps=+sys_admin --ambient-caps=+sys_admin env HOME=/home/chronos bash --noprofile --norc -eo pipefail {0}

steps:
- name: Checkout
uses: actions/checkout@v7.0.1
with:
submodules: recursive

- name: Set Workspace Ownership
shell: bash
run: chown -R chronos:chronos "$GITHUB_WORKSPACE"

- name: Setup Build Environment
run: |
source ./meta-chronos-distro/chronos-init-build-env
if [ "${{ inputs.release }}" = "true" ]; then
echo "EXTRA_IMAGE_FEATURES:remove = \"debug-tweaks chronos-debug\"" >> conf/local.conf
fi

- name: Build Image
run: |
source ./meta-chronos-distro/chronos-init-build-env
MACHINE=${{ matrix.machine }} bitbake --quiet chronos-image

# - name: Run Test Image
# run: |
# source ./meta-chronos-distro/chronos-init-build-env
# MACHINE=${{ matrix.machine }} bitbake chronos-image:do_testimage

- name: Build SDK
if: inputs.sdk
run: |
source ./meta-chronos-distro/chronos-init-build-env
MACHINE=${{ matrix.machine }} bitbake --quiet chronos-image:do_populate_sdk

- name: Setup Sync
if: inputs.cache
env:
KNOWN_HOST: ${{ secrets.YOCTOCACHE_KNOWN_HOST }}
DEPLOY_KEY: ${{ secrets.YOCTOCACHE_DEPLOY_KEY }}
run: |
mkdir -p "$HOME/.ssh"
chmod 700 "$HOME/.ssh"
printf '%s\n' "$KNOWN_HOST" >> "$HOME/.ssh/known_hosts"
printf '%s\n' "$DEPLOY_KEY" > "$HOME/.ssh/id_deploy"
chmod 600 "$HOME/.ssh/known_hosts" "$HOME/.ssh/id_deploy"

- name: Sync Sources
if: inputs.cache
env:
DEST: ${{ secrets.YOCTOCACHE_DEST }}
PORT: ${{ secrets.YOCTOCACHE_PORT }}
run: |
cd build/downloads
rsync -rlptD --quiet --mkpath ${{ inputs.dry_run && '--dry-run --stats' || '' }} \
--partial-dir=.rsync-partial-${{ matrix.machine }} \
--include='/uninative/***' \
--exclude='/*/' \
--exclude='*.tmp' \
--exclude='*.lock' \
--exclude='*.done' \
-e "ssh -p $PORT -i $HOME/.ssh/id_deploy -o IdentitiesOnly=yes -o UserKnownHostsFile=$HOME/.ssh/known_hosts -o StrictHostKeyChecking=yes" \
./ "$DEST/source-mirror/"

- name: Sync Cache
if: inputs.cache
env:
DEST: ${{ secrets.YOCTOCACHE_DEST }}
PORT: ${{ secrets.YOCTOCACHE_PORT }}
run: |
cd build/sstate-cache
rsync -rlptD --quiet --mkpath ${{ inputs.dry_run && '--dry-run --stats' || '' }} --delete --delete-after \
--partial-dir=.rsync-partial \
--exclude='/.rsync-partial/' \
-e "ssh -p $PORT -i $HOME/.ssh/id_deploy -o IdentitiesOnly=yes -o UserKnownHostsFile=$HOME/.ssh/known_hosts -o StrictHostKeyChecking=yes" \
./ "$DEST/sstate-mirror/${{ matrix.machine }}/"

- name: Collect Artifacts
if: inputs.release
run: |
mkdir -p artifacts/${{ matrix.machine }}
cp build/tmp/deploy/images/${{ matrix.machine }}/*.rootfs.ext4.gz artifacts/${{ matrix.machine }}/
if [ -f "build/tmp/deploy/images/${{ matrix.machine }}/bzImage" ]; then
cp "build/tmp/deploy/images/${{ matrix.machine }}/bzImage" "artifacts/${{ matrix.machine }}/"
else
cp "build/tmp/deploy/images/${{ matrix.machine }}/Image.gz" "artifacts/${{ matrix.machine }}/"
fi
if [ "${{ inputs.sdk }}" = "true" ]; then
cp build/tmp/deploy/sdk/*.sh artifacts/${{ matrix.machine }}/
fi

- name: Upload Artifacts to GitHub
if: inputs.release
uses: actions/upload-artifact@v7.0.1
with:
name: ${{ matrix.machine }}-artifacts
path: artifacts/${{ matrix.machine }}/
if-no-files-found: error

- name: Cleanup Workspace
if: always()
run: |
rm -rf -- "$GITHUB_WORKSPACE"/*
rm -rf -- "$GITHUB_WORKSPACE"/.[!.]* "$GITHUB_WORKSPACE"/..?*
if [ "${{ inputs.cache }}" = "true" ]; then
shred -u "$HOME/.ssh/id_deploy" 2>/dev/null || rm -f "$HOME/.ssh/id_deploy"
fi
24 changes: 24 additions & 0 deletions .github/workflows/cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: cache

on:
schedule:
- cron: "0 13 * * 0"

workflow_dispatch:

jobs:
cache:
uses: ./.github/workflows/build.yml

permissions:
contents: read

secrets:
YOCTOCACHE_KNOWN_HOST: ${{ secrets.YOCTOCACHE_KNOWN_HOST }}
YOCTOCACHE_DEPLOY_KEY: ${{ secrets.YOCTOCACHE_DEPLOY_KEY }}
YOCTOCACHE_DEST: ${{ secrets.YOCTOCACHE_DEST }}
YOCTOCACHE_PORT: ${{ secrets.YOCTOCACHE_PORT }}

with:
cache: true
sdk: true
22 changes: 22 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: cd

on:
push:
branches: [ main ]

workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
deploy:
uses: ./.github/workflows/build.yml

permissions:
contents: read

with:
release: true
sdk: true
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: ci

on:
pull_request:
branches: [ main ]

workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check:
uses: ./.github/workflows/build.yml

permissions:
contents: read
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
.cproject
.project

build/
build*/
__pycache__/
4 changes: 2 additions & 2 deletions meta-chronos-distro/conf/distro/include/chronos.inc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ BB_HASHSERVE = ""
# cache
INHERIT += "own-mirrors"
BB_GENERATE_MIRROR_TARBALLS = "1"
SOURCE_MIRROR_URL ?= "https://yocto.dorale.fr/source-mirror/"
SSTATE_MIRRORS ?= "file://.* https://yocto.dorale.fr/sstate-mirror/${MACHINE}/PATH;downloadfilename=PATH"
SOURCE_MIRROR_URL ?= "https://yocto.joinframework.net/source-mirror/"
SSTATE_MIRRORS ?= "file://.* https://yocto.joinframework.net/sstate-mirror/${MACHINE}/PATH;downloadfilename=PATH"

# users
USERADDEXTENSION = "useradd-staticids"
Expand Down
Loading