diff --git a/.github/workflows/check_unit_tests.yml b/.github/workflows/check_unit_tests.yml index afe6cce566..8a0a29d4cf 100644 --- a/.github/workflows/check_unit_tests.yml +++ b/.github/workflows/check_unit_tests.yml @@ -94,7 +94,8 @@ jobs: lcov --capture --directory "$(pwd)/build.debug/" --output-file coverage.info lcov --remove coverage.info '/usr/*' '*/tests/*' '*/thirdparty/*' '*/moc_*' '*framework/Headers/*' '*/hb-*' '*/Qt/*' --output-file filtered_coverage.info - python3 buildscripts/ci/linux/tools/lcov_badger.py filtered_coverage.info coverage_badge.svg + COVERAGE=$(lcov --summary filtered_coverage.info --ignore-errors inconsistent,corrupt,unsupported,empty,negative,mismatch,gcov | grep -oP 'lines\.+:\s+\K[0-9.]+') + python3 buildscripts/ci/linux/tools/lcov_badger.py "${COVERAGE}" coverage_badge.svg - name: Push to S3 if: ( github.event_name == 'schedule' || inputs.code_coverage ) && github.repository == 'musescore/muse_framework' diff --git a/buildscripts/ci/learn/make_playlists_info_file.sh b/buildscripts/ci/learn/make_playlists_info_file.sh index 8a793ffb51..8ba1d84b3a 100644 --- a/buildscripts/ci/learn/make_playlists_info_file.sh +++ b/buildscripts/ci/learn/make_playlists_info_file.sh @@ -44,5 +44,7 @@ cat $ARTIFACTS_DIR/playlist.json echo "=== Make playlist for YouTube ===" +python3 -c "import requests" 2>/dev/null || pip install requests + HERE="$(cd "$(dirname "$0")" && pwd)" python3 $HERE/make_youtube_playlist_info.py ${YOUTUBE_API_KEY} ${YOUTUBE_PLAYLIST_ID} ${ARTIFACTS_DIR}/playlist.json diff --git a/buildscripts/ci/linux/Dockerfile b/buildscripts/ci/linux/Dockerfile deleted file mode 100644 index be2606c80c..0000000000 --- a/buildscripts/ci/linux/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM library/ubuntu:18.04 -COPY setup.sh /setup.sh -RUN bash -ex setup.sh diff --git a/buildscripts/ci/linux/tools/lcov_badger.py b/buildscripts/ci/linux/tools/lcov_badger.py index 088f975f6f..a90d8207e8 100644 --- a/buildscripts/ci/linux/tools/lcov_badger.py +++ b/buildscripts/ci/linux/tools/lcov_badger.py @@ -1,9 +1,8 @@ -import io import sys -USAGE = "Usage: python lcov-badger.py (path-to-info-file) (path-for-output-svg)" +USAGE = "Usage: python lcov-badger.py (coverage-percent) (path-for-output-svg)" -SVG_TEMPLATE = """ +SVG_TEMPLATE = """ @@ -27,34 +26,16 @@ def create_svg(percent): return SVG_TEMPLATE.replace("{{PERCENT}}", str(percent)) -def extract_coverage(data): - lines = data.split("\n") - - lines_found = [float(line[3:]) for line in lines if line.startswith("LF:")] - lines_found_sum = sum(lines_found) - - lines_exec = [float(line[3:]) for line in lines if line.startswith("LH:")] - lines_exec_sum = sum(lines_exec) - - return int(round(lines_exec_sum / lines_found_sum * 100)) - if (len(sys.argv) != 3): print(USAGE) exit(-1) -source_path = sys.argv[1] +coverage = int(round(float(sys.argv[1]))) svg_path = sys.argv[2] -print("Reading coverage info from " + source_path) - -info = "" -with open(source_path, 'r') as info_file: - info = info_file.read() -coverage = extract_coverage(info) badge_data = create_svg(coverage) -print(repr(SVG_TEMPLATE)) - +print("Coverage: " + str(coverage) + "%") print("Creating a coverage badge " + svg_path) with open(svg_path, 'w') as badge_file: badge_file.write(badge_data) diff --git a/buildscripts/ci/release/make_previous_releases_notes.sh b/buildscripts/ci/release/make_previous_releases_notes.sh index 2f75627f10..dc87d843a3 100644 --- a/buildscripts/ci/release/make_previous_releases_notes.sh +++ b/buildscripts/ci/release/make_previous_releases_notes.sh @@ -42,9 +42,11 @@ while [[ "$#" -gt 0 ]]; do shift done +HERE="$(cd "$(dirname "$0")" && pwd)" + echo "=== Get release info ===" -bash ./buildscripts/ci/release/get_file_from_s3.sh \ +bash "$HERE"/get_file_from_s3.sh \ --s3_key "${S3_KEY}" \ --s3_secret "${S3_SECRET}" \ --s3_url "${S3_URL}" \ @@ -53,5 +55,4 @@ bash ./buildscripts/ci/release/get_file_from_s3.sh \ echo "=== Append release info to previous releases ===" -HERE="$(cd "$(dirname "$0")" && pwd)" python3 "$HERE"/append_release_to_previous_releases.py ${ARTIFACTS_DIR}/"${CURRENT_FILE_NAME}" ${ARTIFACTS_DIR}/"${PREVIOUS_FILE_NAME}" diff --git a/buildscripts/ci/tools/generateGitLog.sh b/buildscripts/ci/tools/generateGitLog.sh deleted file mode 100755 index 43cd207087..0000000000 --- a/buildscripts/ci/tools/generateGitLog.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: GPL-3.0-only -# MuseScore-Studio-CLA-applies -# -# MuseScore Studio -# Music Composition & Notation -# -# Copyright (C) 2021 MuseScore Limited and others -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 3 as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see .set -e - -options="--all -10" -messages_command="git log --pretty=tformat:'%s' ${options[@]}" -lines_command="git log --pretty=tformat:'%h - __XX123XX__ ' ${options[@]}" - -# damn bash arrays -OLDIFS=$IFS -IFS=$'\n' - -messages=($(bash -c "$messages_command")) -lines=($(bash -c "$lines_command")) - -IFS=$OLDIFS - -mlen=${#messages[@]} -llen=${#lines[@]} - -OUTPUT=${OUTPUT}"" - -echo $OUTPUT - diff --git a/buildscripts/ci/tools/s3_push_file.sh b/buildscripts/ci/tools/s3_push_file.sh index 1043505212..f422fd54a2 100644 --- a/buildscripts/ci/tools/s3_push_file.sh +++ b/buildscripts/ci/tools/s3_push_file.sh @@ -24,6 +24,7 @@ S3_SECRET="" S3_URL="" FILE_PATH="" +CACHE_CONTROL="" while [[ "$#" -gt 0 ]]; do case $1 in @@ -31,13 +32,21 @@ while [[ "$#" -gt 0 ]]; do --s3_secret) S3_SECRET="$2"; shift ;; --s3_url) S3_URL="$2"; shift ;; --file_path) FILE_PATH="$2"; shift ;; + --cache_control) CACHE_CONTROL="$2"; shift ;; *) echo "Unknown parameter passed: $1"; exit 1 ;; esac shift done -bash ./buildscripts/ci/tools/s3_install.sh --s3_key ${S3_KEY} --s3_secret ${S3_SECRET} +HERE="$(cd "$(dirname "$0")" && pwd)" + +bash "$HERE"/s3_install.sh --s3_key ${S3_KEY} --s3_secret ${S3_SECRET} echo "=== Publish to S3 ===" -s3cmd put --acl-public --guess-mime-type $FILE_PATH "$S3_URL" +EXTRA_ARGS=() +if [ -n "$CACHE_CONTROL" ]; then + EXTRA_ARGS+=(--add-header="Cache-Control: ${CACHE_CONTROL}") +fi + +s3cmd put --acl-public --guess-mime-type "${EXTRA_ARGS[@]}" $FILE_PATH "$S3_URL"