feature: add github actions for pull request #27
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build_Test | |
on: | |
pull_request: | |
branches: | |
- main | |
- dev | |
env: | |
DST_BASE: /data1/k230/github-actions/k230_linux_sdk | |
SUB_BASE: ${{ github.event.number }}_${{ github.run_id }} | |
TFTP_ROOT: /data1/tftp_server | |
NFS_ROOT: /data/nfs_server | |
HW_VER: v0.1 | |
defaults: | |
run: | |
shell: bash | |
concurrency: | |
group: ${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
build_image: | |
name: Build Image | |
runs-on: [self-hosted, k230_linux_sdk] | |
timeout-minutes: 45 | |
container: | |
image: ai.b-bug.org:5000/k230_sdk:latest | |
env: | |
CONF: ${{ matrix.hw_type }}_${{ matrix.hw_model }}_defconfig | |
volumes: | |
- /data:/data | |
- /data1:/data1 | |
options: --hostname runner | |
strategy: | |
matrix: | |
hw_type: ["k230"] | |
hw_model: ["canmv"] | |
outputs: | |
image_name: ${{ steps.save_image.outputs.image_name }} | |
image_md5: ${{ steps.save_tftp.outputs.image_md5 }} | |
image_path: ${{ steps.save_tftp.outputs.image_path }} | |
steps: | |
- name: Build Env Setup | |
id: build_env | |
run: | | |
echo '----------Build ENV Prepare----------' | |
mkdir -p ~/.ssh | |
chmod 700 ~/.ssh | |
echo $SHELL | |
echo -e "Host *\n StrictHostKeyChecking no" > ~/.ssh/config | |
echo "increate ssh timeout for github" | |
echo " ServerAliveInterval 30" >> ~/.ssh/config | |
echo " ServerAliveCountMax 60" >> ~/.ssh/config | |
echo " TCPKeepAlive yes" >> ~/.ssh/config | |
cat ~/.ssh/config | |
whoami | |
uptime | |
pwd | |
ls -alht | |
uname -a | |
cat /etc/issue | |
HW_TYPE=$(echo $CONF | awk -F '_' '{print $1}') | |
HW_MODEL=$(echo $CONF | awk -F "_" '{if ($3 == "v2") print $2"_"$3; else print $2}') | |
echo "HW_TYPE ${HW_TYPE}, HW_MODEL ${HW_MODEL}" | |
- name: Checkout Code | |
id: checkout_code | |
run: | | |
set -x | |
PR_REPO=${{ github.event.pull_request.head.repo.full_name }} | |
PR_BRANCH=${{ github.event.pull_request.head.ref }} | |
BASE_REPO=${{ github.repository }} | |
BASE_BRANCH=${{ github.event.pull_request.base.ref }} | |
echo "PR_REPO: ${PR_REPO}, PR_BRANCH: ${PR_BRANCH}" | |
echo "BASE_REPO: ${BASE_REPO}, BASE_BRANCH: ${BASE_BRANCH}" | |
echo "Cloning PR repository ${PR_REPO} branch ${PR_BRANCH}" | |
echo "clean dst dir" | |
pwd | |
ls -alht | |
rm -rf k230_linux_sdk | |
echo "set github proxy" | |
git config --global https.proxy ${{ secrets.GH_PROXY }} | |
git clone --depth=10 --branch=${PR_BRANCH} https://github.com/${PR_REPO} k230_linux_sdk || git clone --depth=10 --branch=${PR_BRANCH} https://github.com/${PR_REPO} k230_linux_sdk | |
cd k230_linux_sdk | |
git fetch origin ${PR_BRANCH} || exit 1 | |
git checkout ${PR_BRANCH} || exit 1 | |
ls -alht | |
pwd | |
- name: Build Image | |
id: build_image | |
run: | | |
pwd | |
cd k230_linux_sdk | |
echo "----------start to build linux sdk image----------" | |
time make CONF=${CONF} BR2_PRIMARY_SITE=${{ secrets.DL_SITE }} || exit 1 | |
echo "----------show linux sdk image build output----------" | |
pwd | |
du -h -d 2 output/${CONF}/ || exit 1 | |
ls -alht output/${CONF}/images || exit 1 | |
echo "----------remove img----------" | |
rm -rf output/${CONF}/images/sysimage-sdcard.img | |
echo "----------build sdk image done----------" | |
- name: Save Image | |
id: save_image | |
run: | | |
pwd | |
ls | |
HW_TYPE=$(echo $CONF | awk -F '_' '{print $1}') | |
HW_MODEL=$(echo $CONF | awk -F "_" '{if ($3 == "v2") print $2"_"$3; else print $2}') | |
echo "HW_TYPE ${HW_TYPE}, HW_MODEL ${HW_MODEL}" | |
cd k230_linux_sdk | |
ls | |
echo "----------save image----------" | |
SRC_DIR="./output/${CONF}/images" | |
echo "SRC_DIR: ${SRC_DIR}" | |
echo ${DST_BASE} | |
echo "set DST_DIR with different type based on docs/images/src" | |
DST_DIR="${DST_BASE}/images" | |
echo "DST_DIR: ${DST_DIR}" | |
echo "---create repo dir---" | |
sudo mkdir -p ${DST_DIR} | |
ls ${SRC_DIR} | |
ls -alht ${SRC_DIR} | |
tree ${SRC_DIR} | |
echo "----------Save build ----------" | |
SUB_DIR="${SUB_BASE}/${CONF}"; | |
echo "---create current image version dir---" | |
sudo mkdir -p ${DST_DIR}/${SUB_DIR}/ || exit 1 | |
echo "---save sdk build output---" | |
sudo cp -rf --sparse=always -L ${SRC_DIR}/${HW_TYPE}_${HW_MODEL}_*.img.gz ${DST_DIR}/${SUB_DIR}/ | |
echo "${DST_DIR}/${SUB_DIR}/" | |
ls "${DST_DIR}/${SUB_DIR}/" | |
image_name=$(ls "${DST_DIR}/${SUB_DIR}/") | |
echo "image_name: $image_name" | |
echo "image_name=$image_name" >> $GITHUB_OUTPUT | |
echo "add latest link for current build" | |
test -h ${DST_DIR}/latest && sudo rm ${DST_DIR}/latest | |
sudo ln -s ${DST_DIR}/${ver} ${DST_DIR}/latest || exit 1 | |
ls ${DST_DIR}/latest | |
echo "----------output URL----------" | |
echo "${DST_DIR}/${SUB_DIR}/" | sed "s/\/data1/https:\/\/ai\.b-bug\.org/g" | |
echo "----------save image done----------" | |
- name: Save image to TFTP | |
id: save_tftp | |
run: | | |
pwd | |
HW_TYPE=$(echo $CONF | awk -F '_' '{print $1}') | |
HW_MODEL=$(echo $CONF | awk -F "_" '{if ($3 == "v2") print $2"_"$3; else print $2}') | |
echo "HW_TYPE ${HW_TYPE}, HW_MODEL ${HW_MODEL}" | |
cd k230_linux_sdk | |
echo "start to save test image for config: ${CONF} ------"; | |
SRC_DIR="./output/${CONF}/images" | |
echo "SRC_DIR: ${SRC_DIR}" | |
echo ${TFTP_BASE}; | |
echo "set DST_DIR with different type based on docs/images/src"; | |
DST_DIR="${TFTP_BASE}/${HW_TYPE}/${HW_MODEL}_${HW_VER}"; | |
echo ${DST_DIR}; | |
SUB_DIR=${SUB_BASE}/${CONF} | |
echo "---create tftp dir---"; | |
sudo mkdir -p ${DST_DIR}/${SUB_DIR}/ || exit 1; | |
sudo cp -rf --sparse=always -L ${SRC_DIR}/${HW_TYPE}_${HW_MODEL}_*.img.gz ${DST_DIR}/${SUB_DIR} | |
image_md5=$(md5sum ${DST_DIR}/${SUB_DIR}/${HW_TYPE}_${HW_MODEL}_*.img.gz | awk '{print $1}') | |
image_path="${DST_DIR}/${SUB_DIR}/" | |
echo "image_md5: $image_md5" | |
echo "image_path: $image_path" | |
echo "image_md5=$image_md5" >> $GITHUB_OUTPUT | |
echo "image_path=$image_path" >> $GITHUB_OUTPUT | |
test_image: | |
name: Test Image | |
needs: build_image | |
timeout-minutes: 15 | |
runs-on: [self-hosted, k230_linux_sdk] | |
env: | |
CONF: ${{ matrix.hw_type }}_${{ matrix.hw_model }}_defconfig | |
container: | |
image: ai.b-bug.org:5000/k230_sdk:latest | |
volumes: | |
- /data:/data | |
- /data1:/data1 | |
options: --hostname runner | |
strategy: | |
matrix: | |
hw_type: ["k230"] | |
hw_model: ["canmv"] | |
steps: | |
- name: Run Test | |
id: run_test | |
run: | | |
echo "==============================" | |
echo "There is NO test job NOW" | |
echo "==============================" | |
echo "add this stage for future job" | |
echo "==============================" | |
echo "image name: ${{needs.build_image.outputs.image_name}}" | |
echo "image md5: ${{needs.build_image.outputs.image_md5}}" | |
echo "image path: ${{needs.build_image.outputs.image_path}}" | |
whoami | |
uptime | |
pwd | |
uname -a | |
cat /etc/issue | |
ls -alht | |
HW_TYPE=$(echo $CONF | awk -F '_' '{print $1}') | |
HW_MODEL=$(echo $CONF | awk -F "_" '{if ($3 == "v2") print $2"_"$3; else print $2}') | |
echo "HW_TYPE ${HW_TYPE}, HW_MODEL ${HW_MODEL}" |