Skip to content

add add-reviewers.yml automatically adds reviewers to pull requests #6

add add-reviewers.yml automatically adds reviewers to pull requests

add add-reviewers.yml automatically adds reviewers to pull requests #6

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the workflow will run
on:
pull_request:
types: [opened, reopened, synchronize]
# reusable
workflow_call:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
CI:
runs-on: ubuntu-latest
steps:
- name: Get Repo Name
run: |
echo "REPO_NAME=$(basename ${{ github.repository }})" >> $GITHUB_ENV
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Download and install repo
run: |
mkdir ~/bin
echo 'export PATH=~/bin:$PATH' >> $HOME/.bashrc
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
- name: Clean up disk space
run: |
sudo apt-get clean
sudo rm -rf /var/lib/apt/lists/*
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
sudo rm -rf /etc/apt/sources.list.d/* /usr/local/lib/android /etc/mysql /etc/php /opt/hostedtoolcache/CodeQL
sudo docker image prune --all --force
sudo docker builder prune -a
sudo docker system prune -af
sudo -E apt-get -y purge azure-cli* docker* ghc* zulu* hhvm* llvm* firefox* google* dotnet* aspnetcore* powershell* openjdk* adoptopenjdk* mysql* php* mongodb* moby* snap* || true
sudo -E apt-get -qq update
sudo -E apt-get -qq install libfuse-dev $(curl -fsSL git.io/depends-ubuntu-2204)
sudo -E apt-get -qq autoremove --purge
sudo -E apt-get -qq clean
df -h
- name: Verify repo installation
run: |
~/bin/repo --version
- name: Get PR source branch name
id: get_branch_name
run: |
PR_BRANCH=$(jq -r '.pull_request.head.ref' "$GITHUB_EVENT_PATH")
echo "branch_name=$PR_BRANCH" >> $GITHUB_OUTPUT
- name: Repo Init
run: |
~/bin/repo init -u https://github.com/open-vela/manifests -b ${{ github.event.pull_request.base.ref }} -m openvela.xml --depth=1 --git-lfs
echo "REPO_INIT=true" >> $GITHUB_ENV
- name: Repo Sync
run: |
df -h
~/bin/repo sync -c -d --no-tags -j12
df -h
- name: Fetch PR
if: ${{ github.event_name == 'pull_request' }}
run: |
current_path=$(pwd)
echo "REPO_ROOT=$current_path" >> $GITHUB_ENV
echo $(ls -atl)
git config --global user.email "[email protected]"
git config --global user.name "openvela-robot"
if [ ${{ env.REPO_NAME }} == "manifests" ]; then
cd .repo/manifests
echo "git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-branch"
git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-branch
echo "git cherry-pick $(git rev-list --reverse HEAD..pr-branch)"
set +e
cp_pr_result=$(git cherry-pick $(git rev-list --reverse HEAD..pr-branch) 2>&1)
cp_pr_code=$?
echo $cp_pr_result
safe_cp_pr_result=$(echo "$cp_pr_result" | tr -d '\n' | tr -d '\r' | sed 's/[]\$`"\\]//g') # 格式化结果
echo "CP_PR_RESULT=$safe_cp_pr_result" >> $GITHUB_ENV
echo "CP_PR_CODE=$cp_pr_code" >> $GITHUB_ENV
cd -
~/bin/repo sync -c -d --no-tags -j12
echo "REPO_SYNC_CODE=$?" >> $GITHUB_ENV
else
manifest_content=$(cat .repo/manifests/openvela.xml)
echo $manifest_content
REPO_PATH=$(cat .repo/manifests/openvela.xml | grep "\"${{ env.REPO_NAME }}\"" | awk -F'"' '{print $2}')
echo $REPO_PATH
cd $REPO_PATH
echo "git fetch openvela pull/${{ github.event.pull_request.number }}/head:pr-branch"
git fetch openvela pull/${{ github.event.pull_request.number }}/head:pr-branch
echo "git cherry-pick $(git rev-list --reverse HEAD..pr-branch)"
set +e
cp_pr_result=$(git cherry-pick $(git rev-list --reverse HEAD..pr-branch) 2>&1)
cp_pr_code=$?
echo $cp_pr_result
safe_cp_pr_result=$(echo "$cp_pr_result" | tr -d '\n' | tr -d '\r' | sed 's/[]\$`"\\]//g') # 格式化结果
echo "CP_PR_RESULT=$safe_cp_pr_result" >> $GITHUB_ENV
echo "CP_PR_CODE=$cp_pr_code" >> $GITHUB_ENV
cd -
fi
continue-on-error: true
- name: check cherry-pick pr result
run: |
if [ -n "${{ env.REPO_SYNC_CODE }}" ] && [ ${{ env.REPO_SYNC_CODE }} != 0 ]; then
echo "repo sync after cherry-pick manifest PR failed."
exit 1
else
echo "repo sync after cherry-pick manifest PR success."
fi
if [ ${{ env.CP_PR_CODE }} == 0 ]; then
echo "cherry-pick PR success and continue."
else
echo "${{ env.CP_PR_RESULT }}" | grep "is a merge"
if [ $? -eq 0 ]; then
echo "There's merge commit in your PR. Please use rebase insteadof merge."
exit 1
else
echo "cherry-pick PR failed with error message: ${{ env.CP_PR_RESULT }}"
exit 1
fi
fi
- name: Docker Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker Pull
run: docker pull ghcr.io/open-vela/openvela-ci-linux
- name: Run CI tasks inside Docker container
run: |
docker run --rm \
-v ${{ github.workspace }}:/workspace \
-w /workspace \
ghcr.io/open-vela/openvela-ci-linux:latest \
/bin/bash -c "ls -atl && ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap -e -Werror -j8"
- name: Upload goldfish-armeabi-v7a-ap Artifact
uses: actions/upload-artifact@v3
with:
name: goldfish-armeabi-v7a-ap_${{ env.REPO_NAME }}-${{ github.event.pull_request.number }}
path: nuttx/nuttx
- name: Clean
run: |
echo 'export PATH=~/bin:$PATH' >> $HOME/.bashrc
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
sudo ~/bin/repo forall -v -c git clean -dfx; git reset --hard HEAD
continue-on-error: true
- name: Run test build inside Docker container
run: |
docker run --rm \
-v ${{ github.workspace }}:/workspace \
-w /workspace \
ghcr.io/open-vela/openvela-ci-linux:latest \
/bin/bash -c "./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap-citest -e -Werror -j8"
- name: Run autotest tasks inside Docker container
run: |
docker run --rm \
-v ${{ github.workspace }}:/workspace \
-w /workspace \
ghcr.io/open-vela/openvela-ci-linux:latest \
/bin/bash -c "cd tests/scripts/script && pytest -m 'common or goldfish_armeabi_v7a_ap' ./ -B goldfish-armeabi-v7a-ap -L /workspace -P /workspace -F /tmp -R qemu -v --disable-warnings --count=1 --json=/workspace/autotest.json"
- name: Check autotest result
id: autotest_result
run: |
cd ${{ github.workspace }}
mkdir output
cp nuttx/nuttx ./*.log ./autotest.json output
failed=$(cat autotest.json | jq '.report.summary.failed')
if [ "$failed" != "null" ] && [ "$failed" != "0" ]; then
echo "autotest failed: $failed"
result="failed"
else
echo "autotest passed"
result="success"
fi
echo "::set-output name=AUTOTEST_RESULT::${result}"
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: goldfish-armeabi-v7a-ap-citest_${{ env.REPO_NAME }}-${{ github.event.pull_request.number }}
path: output/
- name: Exit with autotest exit code
run: |
if [ ${{ steps.autotest_result.outputs.AUTOTEST_RESULT }} == "success" ]; then
exit 0;
else
exit 1;
fi