Skip to content

Check: Unit Tests (utest) #33

Check: Unit Tests (utest)

Check: Unit Tests (utest) #33

name: 'Check: Unit Tests (utest)'
on:
pull_request:
workflow_dispatch:
jobs:
run_tests:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.12.1
with:
access_token: ${{ github.token }}
- name: Clone repository
uses: actions/checkout@v4
- name: "Configure workflow"
run: |
bash ./buildscripts/ci/tools/make_build_number.sh
BUILD_NUMBER=$(cat ./build.artifacts/env/build_number.env)
echo "BUILD_NUMBER=$BUILD_NUMBER" | tee -a $GITHUB_ENV
echo "CCACHE_TIMESTAMP=$(date -u +"%F-%T")" | tee -a $GITHUB_ENV
- name: Restore ccache files
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.ccache
key: ${{github.workflow}}-ccache-${{ env.CCACHE_TIMESTAMP }}
restore-keys: ${{github.workflow}}-ccache-
- name: Setup ccache
run: |
sudo apt-get update && sudo apt-get install -y ccache
bash ./buildscripts/ci/tools/setup_ccache_config.sh
- name: Setup environment
run: |
bash ./buildscripts/ci/linux/setup.sh
- name: Build
run: |
mkdir -p build.artifacts/env
bash ./buildscripts/ci/linux/build_utest.sh -n ${{ env.BUILD_NUMBER }}
echo "============== ccache ==============="
ccache -s
- name: Free up disk space
# After building, too little disk space is left. Remove unnecessary tools to free up disk space.
run: |
sudo docker system prune -a -f
sudo rm -rf /usr/local/lib/android
- name: Run tests
run: |
bash ./buildscripts/ci/linux/runutests.sh
env:
ASAN_OPTIONS: "detect_leaks=0"
- name: Code coverage
run: |
HERE=$(pwd)
lcov --capture --directory "${HERE}/build.debug/" --output-file "${HERE}/coverage.info" --base-directory "${HERE}/MuseScore/"
lcov --remove "${HERE}/coverage.info" '/usr/*' '*/tests/*' '*/thirdparty/*' --output-file "${HERE}/filtered_coverage.info"
genhtml "${HERE}/filtered_coverage.info" --output-directory "${HERE}/coverage-report"
cp "${HERE}/filtered_coverage.info" "${HERE}/coverage-report/filtered_coverage.info"
7z a "${HERE}/coverage.7z" "${HERE}/coverage-report/*"
chmod a+rw "${HERE}/coverage.7z"
S3_URL='s3://extensions.musescore.org/test/code_coverage/coverage.7z'
bash ./buildscripts/ci/learn/push_file_to_s3.sh \
--s3_key '${{ secrets.S3_KEY }}' \
--s3_secret '${{ secrets.S3_SECRET }}' \
--s3_url "${S3_URL}" \
--file_path "${HERE}/coverage.7z"
python3 buildscripts/ci/linux/tools/lcov_badger.py "${HERE}/filtered_coverage.info" "${HERE}/coverage_badge.svg"
S3_URL='s3://extensions.musescore.org/test/code_coverage/coverage_badge.svg'
bash ./buildscripts/ci/learn/push_file_to_s3.sh \
--s3_key '${{ secrets.S3_KEY }}' \
--s3_secret '${{ secrets.S3_SECRET }}' \
--s3_url "${S3_URL}" \
--file_path "${HERE}/coverage_badge.svg"
- name: Upload coverage info on GitHub
uses: actions/upload-artifact@v4
with:
name: "coverage_badge"
path: "coverage_badge.svg"