-
Notifications
You must be signed in to change notification settings - Fork 2
214 lines (191 loc) · 9.99 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# 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