Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed May 11, 2024
1 parent 8251763 commit 851d2ca
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 13 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/scripts/unittest/calc_coverage.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
#!/bin/bash
# Copyright (c) 2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

source ../../change_color.sh
LOG_DIR=$1
coverage_compare="${LOG_DIR}/coverage_compare.html"
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/scripts/unittest/compare_coverage.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright (c) 2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

output_file=$1
coverage_pr_log=$2
coverage_base_log=$3
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/scripts/unittest/unittest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function pytest() {
mkdir -p ${coverage_log_dir}
ut_log_name="${LOG_DIR}/unit_test_$1.log"
export GLOG_minloglevel=2

genaieval_path=$(python -c 'import GenAIEval; import os; print(os.path.dirname(GenAIEval.__file__))')
find . -name "test*.py" | sed 's,\.\/,coverage run --source='"${genaieval_path}"' --append ,g' | sed 's/$/ --verbose/' >run.sh
coverage erase
Expand Down Expand Up @@ -74,11 +74,11 @@ function pytest() {
if [ $(grep -c "==ERROR:" ${ut_log_name}) != 0 ]; then
$BOLD_RED && echo "ERROR found in UT, please check the output..." && $RESET
exit 1
fi
fi
if [ $(grep -c "Segmentation fault" ${ut_log_name}) != 0 ]; then
$BOLD_RED && echo "Segmentation Fault found in UT, please check the output..." && $RESET
exit 1
fi
fi
if [ $(grep -c "ImportError:" ${ut_log_name}) != 0 ]; then
$BOLD_RED && echo "ImportError found in UT, please check the output..." && $RESET
exit 1
Expand All @@ -100,8 +100,8 @@ function main() {
if [[ $test_name == "PR-test" ]]; then
pytest "pr"
elif [[ $test_name == "baseline" ]]; then
pytest "base"
pytest "base"
fi
}

main
main
16 changes: 8 additions & 8 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,46 +81,46 @@ jobs:
run: |
docker exec ${{ env.CONTAINER_NAME }} \
bash -c "bash /GenAIEval/.github/workflows/scripts/unittest.sh --test_name=${{ matrix.test_name }}"

- name: Collect log
if: ${{ !cancelled() }}
run: |
docker exec ${{ env.CONTAINER_NAME }} \
bash -c "cd /GenAIEval && \
mv /log_dir . "

- name: Publish pipeline artifact
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: "UnitTest${{ matrix.test_name }}"
path: ${{ github.workspace }}/log_dir

Genreate-OptimizeUT-Report:
runs-on: ubuntu-latest
needs: [Unit-Test]
steps:
- name: Checkout out Repo
uses: actions/checkout@v4

- name: Download UT PR Log
uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/log_dir

- name: Display structure of downloaded files
run: cd ${{ github.workspace }}/log_dir && ls -R

- name: Calculate coverage
run: |
cd ${{ github.workspace }}/.github/workflows/script/unittest
/usr/bin/bash calc_coverage.sh ${{ github.workspace }}/log_dir

- name: Publish pipeline artifact
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: Unit Test
path: ${{ github.workspace }}/log_dir
retention-days: 5

0 comments on commit 851d2ca

Please sign in to comment.