-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add ci-related files. update utest * modify to auto-run different cases based on ci.test * Improve CI workflow * Separate builds and tests into different jobs * Separate input data from build image; instead, use it as a volume before running tests * Make ci subdirectory to contain ci-related files * add clean-up after utest run * add workflow manage files * move parsing in main.yml to a separate script file
- Loading branch information
1 parent
3fb6556
commit 407df4e
Showing
21 changed files
with
2,279 additions
and
789 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Dockerfile | ||
.git | ||
.gitignore | ||
tests/*.log | ||
tests/log_ut_linux.gnu |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
name: Pull Request Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
pull_request: | ||
branches: | ||
- develop | ||
|
||
jobs: | ||
setup: | ||
name: Set up | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
tn: ${{ steps.parse.outputs.tn }} | ||
bld: ${{ steps.parse.outputs.bld }} | ||
test: ${{ steps.parse.outputs.test }} | ||
img: ${{ steps.parse.outputs.img }} | ||
|
||
steps: | ||
- name: Checkout codes | ||
uses: actions/checkout@v2 | ||
|
||
- name: Parse cases | ||
id: parse | ||
run: | | ||
cd ${GITHUB_WORKSPACE}/tests/ci | ||
parsed_output=( $(./parse.sh) ) | ||
name_=${parsed_output[0]} | ||
bld_=${parsed_output[1]} | ||
test_=${parsed_output[2]} | ||
img_=${parsed_output[3]} | ||
echo "::set-output name=tn::$name_" | ||
echo "::set-output name=bld::$bld_" | ||
echo "::set-output name=test::$test_" | ||
echo "::set-output name=img::$img_" | ||
echo "test name : $name_" | ||
echo "build set : $bld_" | ||
echo "test set : $test_" | ||
echo "image name: $img_" | ||
build: | ||
name: Build (${{ matrix.bld_set }}) | ||
needs: setup | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: ${{ fromJson(needs.setup.outputs.bld) }} | ||
|
||
steps: | ||
- name: Checkout codes | ||
uses: actions/checkout@v2 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Build | ||
run: | | ||
printf '{\n "experimental": true\n}' | sudo tee /etc/docker/daemon.json >/dev/null | ||
sudo systemctl restart docker | ||
sleep 10 | ||
cd tests/ci && ./ci.sh -n ${{ needs.setup.outputs.tn }} -b ${{ matrix.bld_set }} | ||
- name: Free up disk space | ||
run: | | ||
sudo docker rmi $(sudo docker image ls | grep -E -m1 '<none>' | awk '{ print $3 }') | ||
sudo docker rmi $(sudo docker image ls | awk '/ci-test-base/ { print $3 }') | ||
- name: Prepare artifacts | ||
run: | | ||
cd tests/ci | ||
sudo docker save ${{ needs.setup.outputs.img }} | gzip >${{ needs.setup.outputs.img }}.tar.gz | ||
tar cvjf artifact.tar.bz2 ${{ needs.setup.outputs.img }}.tar.gz ci.sh ci.test | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ matrix.bld_set }}.artifact.tar.bz2 | ||
path: tests/ci/artifact.tar.bz2 | ||
|
||
utest: | ||
name: Unit test (${{ needs.setup.outputs.tn }}, ${{ matrix.test_set }}) | ||
needs: [setup,build] | ||
runs-on: ubuntu-latest | ||
#runs-on: self-hosted | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: ${{ fromJson(needs.setup.outputs.test) }} | ||
|
||
steps: | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: ${{ matrix.artifact }}.artifact.tar.bz2 | ||
|
||
- name: Prepare artifacts | ||
run: | | ||
tar xvjf artifact.tar.bz2 && rm -f artifact.tar.bz2 | ||
sudo docker load --input ${{ needs.setup.outputs.img }}.tar.gz && rm -f ${{ needs.setup.outputs.img }}.tar.gz | ||
- name: Run utest | ||
run: ./ci.sh -n ${{ needs.setup.outputs.tn }} -r ${{ matrix.test_set }} | ||
|
||
- name: Upload memory usage file | ||
if: ${{ always() }} | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: memory_stat_${{ matrix.test_set }} | ||
path: memory_stat | ||
|
||
- name: Clean up | ||
if: ${{ always() }} | ||
run: | | ||
rm -f ci.sh ci.test | ||
sudo docker rm my-container && sudo docker rmi ${{ needs.setup.outputs.img }}:latest | ||
sudo docker volume rm DataVolume |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Manage workflows | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["Pull Request Tests"] | ||
types: | ||
- requested | ||
|
||
jobs: | ||
job1: | ||
name: Job 1 | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout codes | ||
uses: actions/checkout@v2 | ||
|
||
- name: Check if skip-ci is requested | ||
run: | | ||
cd ${GITHUB_WORKSPACE}/tests/ci | ||
repo="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/actions/runs" | ||
tr_id=$(cat ${GITHUB_EVENT_PATH} | ./json_helper.py get_trigger_id) | ||
tr_br=$(cat ${GITHUB_EVENT_PATH} | ./json_helper.py get_trigger_br) | ||
check=$(cat ${GITHUB_EVENT_PATH} | ./json_helper.py check_skip) | ||
echo "::set-env name=TRIGGER_ID::${tr_id}" | ||
echo "::set-env name=TRIGGER_BR::${tr_br}" | ||
echo "skip-ci: ${check}" | ||
if [[ $check == yes ]]; then | ||
echo "skip-ci is requested" | ||
echo '::set-env name=CURR_JOB::cancelled' | ||
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" ${repo}/$tr_id/cancel | ||
else | ||
echo '::set-env name=CURR_JOB::running' | ||
fi | ||
- name: Cancel redundant jobs | ||
run: | | ||
echo "CURR_JOB is $CURR_JOB" | ||
echo "TRIGGER_ID is $TRIGGER_ID" | ||
echo "TRIGGER_BR is $TRIGGER_BR" | ||
export GITHUB_ACTOR | ||
export GITHUB_RUN_ID | ||
export TRIGGER_ID | ||
export TRIGGER_BR | ||
cd ${GITHUB_WORKSPACE}/tests/ci | ||
repo="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/actions/runs" | ||
cancel_ids=$(curl -H "Accept: application/vnd.github.v3+json" ${repo} | ./json_helper.py cancel_workflow) | ||
echo "cancel ids: $cancel_ids" | ||
if [[ $cancel_ids != '' ]]; then | ||
for i in $cancel_ids; do | ||
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" ${repo}/$i/cancel | ||
done | ||
fi | ||
if: ${{ env.CURR_JOB == 'running' }} |
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
Oops, something went wrong.