From 69805ad5635b48b4f13b15035eb568e5c8cc9bc5 Mon Sep 17 00:00:00 2001 From: Bart Louwers Date: Thu, 8 Jun 2023 11:04:45 +0200 Subject: [PATCH] Delete unused scripts Linux (#1220) --- platform/linux/scripts/after_script.sh | 11 -- platform/linux/scripts/after_success.sh | 10 -- platform/linux/scripts/metrics.sh | 11 -- scripts/codestyle.sh | 37 ----- scripts/collect-coverage.sh | 78 ---------- scripts/environment.js | 35 ----- scripts/log_memory_benchmarks.sh | 39 ----- scripts/mason.sh | 3 - scripts/nitpick/submodule-pin.js | 13 -- scripts/publish_github_stats.js | 147 ------------------ scripts/standalone.sh | 77 --------- ...trigger-maps-documentation-deploy-steps.sh | 36 ----- scripts/valgrind.sh | 18 --- scripts/valgrind.sup | 18 --- 14 files changed, 533 deletions(-) delete mode 100755 platform/linux/scripts/after_script.sh delete mode 100755 platform/linux/scripts/after_success.sh delete mode 100644 platform/linux/scripts/metrics.sh delete mode 100755 scripts/codestyle.sh delete mode 100644 scripts/collect-coverage.sh delete mode 100755 scripts/environment.js delete mode 100755 scripts/log_memory_benchmarks.sh delete mode 100755 scripts/mason.sh delete mode 100755 scripts/nitpick/submodule-pin.js delete mode 100755 scripts/publish_github_stats.js delete mode 100755 scripts/standalone.sh delete mode 100755 scripts/trigger-maps-documentation-deploy-steps.sh delete mode 100755 scripts/valgrind.sh delete mode 100644 scripts/valgrind.sup diff --git a/platform/linux/scripts/after_script.sh b/platform/linux/scripts/after_script.sh deleted file mode 100755 index 4989f0c44..000000000 --- a/platform/linux/scripts/after_script.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -set -e -set -o pipefail - -JOB=$1 - -if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then - aws s3 cp --recursive --acl public-read --exclude "*" --include "*/actual.png" test/fixtures \ - s3://mapbox/mapbox-gl-native/render-tests/$JOB -fi diff --git a/platform/linux/scripts/after_success.sh b/platform/linux/scripts/after_success.sh deleted file mode 100755 index 97d70d3bd..000000000 --- a/platform/linux/scripts/after_success.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -if [ "${TRAVIS_PULL_REQUEST_BRANCH:-${TRAVIS_BRANCH}}" = "main" ] && [ "${BUILDTYPE}" = "Release" ]; then - CLOUDWATCH=true platform/linux/scripts/metrics.sh -else - echo "Not logging binary size for branch or Debug build" -fi diff --git a/platform/linux/scripts/metrics.sh b/platform/linux/scripts/metrics.sh deleted file mode 100644 index 05850e094..000000000 --- a/platform/linux/scripts/metrics.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -# Generate stripped version -ARCH=$(uname -m) -RENDER=build/linux-${ARCH}/Release/mbgl-render -strip -s -x "${RENDER}" -o "${RENDER}-stripped" - -scripts/check_binary_size.js "${RENDER}-stripped" "Linux" diff --git a/scripts/codestyle.sh b/scripts/codestyle.sh deleted file mode 100755 index 3ed74f17c..000000000 --- a/scripts/codestyle.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -# Treats all characters as bytes, removes Unicode awareness from (broken?) macOS sed. -export LC_ALL=C - -if [ `uname -s` = 'Darwin' ]; then - # BSD sed accepts a file extension. - SED="sed -i''" -else - # GNU sed does not. - SED="sed -i" -fi - -# Gather list of files -FILES=$(git ls-files "*.hpp" "*.cpp" "*.h" "*.mm" "*.m" "*.c" "*.java" "*.xml" "*.ejs" "*.gradle" | - sed '/^platform\/android\/MapboxGLAndroidSDK\/src\/main\/java\/com\/almeros\// d;/^src\/clipper\// d;/^platform\/ios\/uitest\/OCMock/d') - -# Adds trailing newlines to files. -echo "Checking for missing trailing newlines..." -echo "${FILES}" | tr '\n' '\0' | xargs -0 ${SED} -e '$a\' - -# Removes trailing whitespace. -echo "Checking for trailing whitespace..." -echo "${FILES}" | tr '\n' '\0' | xargs -0 ${SED} 's/ *$// ' - -# Add space after // comments. Does not replace // within double quotes. -# Part of the regex is from http://stackoverflow.com/a/11503678 -echo "Checking for missing spaces after comments..." -echo "${FILES}" | tr '\n' '\0' | xargs -0 perl -p -i -e 's/(?/dev/null 2>&1 || usage -command -v genhtml >/dev/null 2>&1 || usage - -# Build unit tests -make test - -# Zero coverage counters -lcov \ - --quiet \ - --zerocounters \ - --directory "${SOURCE_DIR}" \ - --output-file "${SOURCE_DIR}/coverage.info" \ - >/dev/null 2>&1 - -# Run all unit tests -make run-test - -# Collect coverage data and save it into coverage.info -echo "Collecting coverage data..." -lcov \ - --quiet \ - --capture \ - --no-external \ - --directory "${SOURCE_DIR}" \ - --output-file "${SOURCE_DIR}/coverage.info" \ - >/dev/null 2>&1 - -# Remove coverage data for unwanted files from a tracefile -lcov \ - --quiet \ - --remove "${SOURCE_DIR}/coverage.info" \ - "${SOURCE_DIR}/vendor/*" \ - "${SOURCE_DIR}/mason/*" \ - "${SOURCE_DIR}/test/*" \ - "/usr/include/*" \ - --output-file "${SOURCE_DIR}/total_coverage.info" \ - >/dev/null 2>&1 - -# Generate HTML report based on total_coverage.info -echo "Generating HTML report..." -genhtml \ - --quiet \ - --show-details \ - --keep-descriptions \ - --function-coverage \ - --no-branch-coverage \ - --title "Mapbox GL Native" \ - --num-spaces 4 \ - --sort \ - --demangle-cpp \ - --prefix $(pwd -P) \ - --output-directory "${SOURCE_DIR}/coverage" \ - "${SOURCE_DIR}/total_coverage.info" \ - >/dev/null 2>&1 - -echo "Coverage report is now available in ${SOURCE_DIR}/coverage/index.html" diff --git a/scripts/environment.js b/scripts/environment.js deleted file mode 100755 index b3bc18095..000000000 --- a/scripts/environment.js +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env node - -// Output some `export` commands with a few extra environment variables. They'll be evaluated -// into the build environment and available for use in later steps. - -const github = require('@octokit/rest')(); -const {execSync} = require('child_process'); - -const pr = process.env['CIRCLE_PULL_REQUEST']; -if (pr) { - const number = +pr.match(/\/(\d+)\/?$/)[1]; - return github.pullRequests.get({ - owner: 'mapbox', - repo: 'mapbox-gl-native', - number - }).then(({data}) => { - const base = data.base.ref; - const head = process.env['CIRCLE_SHA1']; - const mergeBase = execSync(`git merge-base origin/${base} ${head}`).toString().trim(); - - console.log(`export CIRCLE_TARGET_BRANCH=${base}`); - console.log(`export CIRCLE_MERGE_BASE=${mergeBase}`); - }); -} else { - const head = process.env['CIRCLE_SHA1']; - for (const sha of execSync(`git rev-list --max-count=500 ${head}`).toString().trim().split('\n')) { - const base = execSync(`git branch -r --contains ${sha} origin/main origin/release-*`).toString().split('\n')[0].trim().replace(/^origin\//, ''); - if (base) { - const mergeBase = execSync(`git merge-base origin/${base} ${head}`).toString().trim(); - console.log(`export CIRCLE_TARGET_BRANCH=${base}`); - console.log(`export CIRCLE_MERGE_BASE=${mergeBase}`); - break; - } - } -} diff --git a/scripts/log_memory_benchmarks.sh b/scripts/log_memory_benchmarks.sh deleted file mode 100755 index 1f213caa9..000000000 --- a/scripts/log_memory_benchmarks.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail -set -u - -# Logs metrics on memory usage to CloudWatch - -GTEST_OUTPUT=$1 -DIMENSIONS=$2 - -if [ -z "${DIMENSIONS}" ]; then - echo "* No dimensions specified for memory benchmarks" - exit 1 -fi - -function reportAttributeValue { - ATTR_NAME=$1 - ATTR_UNITS=$2 - ATTR_VALUE=$(cat $GTEST_OUTPUT | grep -o "$ATTR_NAME=\"[^\"]*" | sed "s/$ATTR_NAME=\"//") - if [ ${CLOUDWATCH:-} ]; then - echo "* Reporting $ATTR_NAME = $ATTR_VALUE $ATTR_UNITS for '${DIMENSIONS}'" - aws --region us-east-1 cloudwatch put-metric-data \ - --namespace "Mapbox/GL" \ - --metric-name "$ATTR_NAME" \ - --unit "$ATTR_UNITS" \ - --value ${ATTR_VALUE} \ - --dimensions "${DIMENSIONS}" - else - echo "* Measured $ATTR_NAME = $ATTR_VALUE $ATTR_UNITS for '${DIMENSIONS}'" - fi -} - -if [ -f "${GTEST_OUTPUT}" ]; then - reportAttributeValue vectorFootprint Bytes - reportAttributeValue rasterFootprint Bytes -else - echo "* File '${GTEST_OUTPUT}' does not exist" -fi diff --git a/scripts/mason.sh b/scripts/mason.sh deleted file mode 100755 index 696ad26ad..000000000 --- a/scripts/mason.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -cmake -P cmake/mason.cmake "$@" diff --git a/scripts/nitpick/submodule-pin.js b/scripts/nitpick/submodule-pin.js deleted file mode 100755 index 1b7070cc1..000000000 --- a/scripts/nitpick/submodule-pin.js +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env node -const nitpick = require('.'); -const child_process = require('child_process'); - -// Make sure that the maplibre-gl-js submodule pin is up to date -const head = child_process.execSync('git -C maplibre-gl-js rev-parse HEAD').toString().trim(); -const revs = child_process.execSync(`git -C maplibre-gl-js branch -a --contains ${head}`).toString().split('\n'); - -if (revs.indexOf(' remotes/origin/main') >= 0) { - nitpick.ok(`maplibre-gl-js submodule pin is merged to main`); -} else { - nitpick.fail(`maplibre-gl-js submodule is pinned to ${head}, which isn't merged to main`); -} diff --git a/scripts/publish_github_stats.js b/scripts/publish_github_stats.js deleted file mode 100755 index f79a5082d..000000000 --- a/scripts/publish_github_stats.js +++ /dev/null @@ -1,147 +0,0 @@ -#!/usr/bin/env node - -const assert = require('assert'); -const jwt = require('jsonwebtoken'); -const github = require('@octokit/rest')(); -const zlib = require('zlib'); -const AWS = require('aws-sdk'); - -const SIZE_CHECK_APP_ID = 14028; -const SIZE_CHECK_APP_INSTALLATION_ID = 229425; - -// Error handling - -process.on('unhandledRejection', error => { - console.log(error); - process.exit(1) -}); - -// Github authorization - -const pk = process.env['SIZE_CHECK_APP_PRIVATE_KEY']; -if (!pk) { - console.log('Fork PR; not publishing size.'); - process.exit(0); -} - -const key = Buffer.from(pk, 'base64').toString('binary'); -const payload = { - exp: Math.floor(Date.now() / 1000) + 60, - iat: Math.floor(Date.now() / 1000), - iss: SIZE_CHECK_APP_ID -}; - -const token = jwt.sign(payload, key, {algorithm: 'RS256'}); -github.authenticate({type: 'app', token}); - -// Metrics: Github statistics -let openIssuesTotal = 0; -let openIssuesTotalFromNonMembers = 0; -let openIssuesTotalCore = 0; -let openIssuesTotalAndroid = 0; -let openIssuesTotalIOS = 0; -let openIssuesTotalGLJSParity = 0; -let openPullRequestsTotal = 0; -let openPullRequestsTotalFromNonMembers = 0; -let openPullRequestsSinceLastMonth = 0; -let openPullRequestsSinceLastMonthFromNonMembers = 0; - -function collectMetricsFromIssues(issues) { - const oneMonthAgo = function() { let date = new Date(); date.setMonth(date.getMonth() - 1); return date; }(); - - // Metrics - issues.data.forEach(function (issue) { - const issueCreatedAt = new Date(issue.created_at); - const isMapboxAuthor = issue.author_association === "MEMBER"; - - if (issue.pull_request) { - openPullRequestsTotal++; - if (!isMapboxAuthor) { - openPullRequestsTotalFromNonMembers++; - } - if (issueCreatedAt >= oneMonthAgo) { - openPullRequestsSinceLastMonth++; - if (!isMapboxAuthor) { - openPullRequestsSinceLastMonthFromNonMembers++; - } - } - } else { - openIssuesTotal++; - if (!isMapboxAuthor) { - openIssuesTotalFromNonMembers++; - } - issue.labels.forEach(function (label) { - switch (label.name) { - case "Core": - openIssuesTotalCore++; - break; - case "Android": - openIssuesTotalAndroid++; - break; - case "iOS": - openIssuesTotalIOS++; - break; - case "GL JS parity": - openIssuesTotalGLJSParity++; - break; - default: - break; - } - }); - } - }); -} - -function publishMetrics() { - let metrics = { - 'created_at': new Date().toISOString().substring(0, 10), - 'open_issues_total': openIssuesTotal, - 'open_issues_total_from_non_members': openIssuesTotalFromNonMembers, - 'open_issues_total_core': openIssuesTotalCore, - 'open_issues_total_android': openIssuesTotalAndroid, - 'open_issues_total_ios': openIssuesTotalIOS, - 'open_issues_total_gl_js_parity': openIssuesTotalGLJSParity, - 'open_pull_requests_total': openPullRequestsTotal, - 'open_pull_requests_total_from_non_members': openPullRequestsTotalFromNonMembers, - 'open_pull_requests_since_last_month': openPullRequestsSinceLastMonth, - 'open_pull_requests_since_last_month_from_non_members': openPullRequestsSinceLastMonthFromNonMembers - }; - - var promise = new AWS.S3({region: 'us-east-1'}).putObject({ - Body: zlib.gzipSync(JSON.stringify(metrics)), - Bucket: 'mapbox-loading-dock', - Key: `raw/mobile_staging.github_stats/${metrics['created_at']}/METRIC.json.gz`, - CacheControl: 'max-age=300', - ContentEncoding: 'gzip', - ContentType: 'application/json' - }).promise(); - - return Promise.all([promise]).then(data => { - return console.log("Successfully uploaded Github Stats metrics to S3"); - }).catch(err => { - console.log("Error uploading Github Stats metrics to S3 " + err.message); - return err; - }); -} - -function recursiveListForRepo(query) { - assert(query); - query.then(result => { - collectMetricsFromIssues(result); - if (github.hasNextPage(result)) { - recursiveListForRepo(github.getNextPage(result)); - } else { - publishMetrics(); - } - }).catch(error => { - console.log("Error fetching the repository issues list: " + err.message); - }); -} - -github.apps.createInstallationToken({ installation_id: SIZE_CHECK_APP_INSTALLATION_ID }) - .then(({data}) => { - github.authenticate({ type: 'token', token: data.token }); - }) - .then(() => { - recursiveListForRepo(github.issues.listForRepo({ owner: 'mapbox', repo: 'mapbox-gl-native', state: 'open', per_page: 100 })); - }); diff --git a/scripts/standalone.sh b/scripts/standalone.sh deleted file mode 100755 index aa609197c..000000000 --- a/scripts/standalone.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -cd "$(dirname "${BASH_SOURCE[0]}")/.." - -function usage { - echo "Usage: $0 [target]" - echo "" - echo " -c, --clean-target Removes all files in the target directory instead of overwriting them" - echo " -s, --skip [name] Skips vendoring the given dependency" - exit 1 -} - -CLEAN_TARGET=false - -ARGS=() -while [[ $# -gt 0 ]] ; do case "$1" in - -c|--clean-target) CLEAN_TARGET=true ; shift ;; - -s|--skip) shift ; DEP="$1" ; shift ; declare SKIP_$DEP=true ;; - *) ARGS+=("$1") ; shift ;; -esac ; done -set -- "${ARGS[@]}" - -if [ -z "$1" ]; then usage ; fi -TARGET="$1" - -if [ "$CLEAN_TARGET" = true ] ; then - echo ">> Cleaning target directory..." - rm -rf "$TARGET" -fi - -echo ">> Creating target directory..." -mkdir -p "$TARGET" -TARGET=$(cd "`pwd`/$TARGET"; pwd) - -echo ">> Creating file lists..." -cat cmake/core-files.txt cmake/filesource-files.txt > "$TARGET/files.txt" -mkdir -p "$TARGET/platform/android" -cat platform/android/*-files.txt > "$TARGET/platform/android/files.txt" - -echo ">> Copying source files..." -rsync -rR $(git ls-files \ - "include" \ - "src" \ - "platform/default" \ - "platform/android/mbgl" \ - "platform/android/src" \ - "platform/linux/src" \ - "platform/android/MapboxGLAndroidSDK/src/main" \ -) "$TARGET" - -echo ">> Copying vendored files..." -rsync -rR $(git ls-files \ - "vendor/icu" \ - "vendor/nunicode" \ - "vendor/sqlite" \ -) "$TARGET" - -echo ">> Copying Mason dependencies..." -cmake -P scripts/standalone.cmake 2>&1 | while read DEPENDENCY ; do - DEPENDENCY=($DEPENDENCY) - if [ "[Mason]" = "${DEPENDENCY[0]}" ]; then - echo "${DEPENDENCY[@]}" - continue - fi - SKIP=SKIP_${DEPENDENCY[0]} - if [ "${!SKIP:-false}" = true ]; then continue ; fi - DESTINATION="$TARGET/vendor/${DEPENDENCY[0]}" - mkdir -p "$DESTINATION" - echo " - ${DEPENDENCY[0]}" - cp -r "${DEPENDENCY[1]}/" "$DESTINATION" - rm "$DESTINATION/mason.ini" - (cd "${DEPENDENCY[1]}" && find include -type f -name "*.hpp" -o -name "*.h") > "$DESTINATION/files.txt" - echo "${DEPENDENCY[2]}" > "$DESTINATION/version.txt" -done diff --git a/scripts/trigger-maps-documentation-deploy-steps.sh b/scripts/trigger-maps-documentation-deploy-steps.sh deleted file mode 100755 index 128b7cda8..000000000 --- a/scripts/trigger-maps-documentation-deploy-steps.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; } -function finish { >&2 echo -en "\033[0m"; } -trap finish EXIT - -SDK_FLAVOR=${SDK_FLAVOR:-"maps"} - -step "Triggering automated site and documentation generation for ${SDK_FLAVOR} SDK ${VERSION_TAG}" - -# No branch specified, so default branch will be used -request_body="{ - \"request\": { - \"message\": \"[${SDK_FLAVOR}] ${VERSION_TAG} automated site and documentation generation\", - \"config\": { - \"merge_mode\": \"deep_merge\", - \"env\": { - \"SDK_FLAVOR\": \"${SDK_FLAVOR}\", - \"RELEASE_TAG\": \"${VERSION_TAG}\" - } - } - } -}" - -step "Making request…" - -# Request URL set to docs-sandbox while testing -curl -s -X POST \ - -H "Content-Type: application/json" \ - -H "Accept: application/json" \ - -H "Travis-API-Version: 3" \ - -H "Authorization: token ${TRAVISCI_API_TOKEN}" \ - -d "${request_body}" \ - https://api.travis-ci.com/repo/mapbox%2F${DOCS_REPO}/requests diff --git a/scripts/valgrind.sh b/scripts/valgrind.sh deleted file mode 100755 index 4eeb9c978..000000000 --- a/scripts/valgrind.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -VALGRIND_PREFIX=$(scripts/mason.sh PREFIX valgrind VERSION 3.12.0) - -PARAMS="\ - --leak-check=full \ - --show-leak-kinds=definite \ - --errors-for-leak-kinds=definite \ - --error-exitcode=1 \ - --gen-suppressions=all \ - --suppressions=scripts/valgrind.sup" - -export VALGRIND_LIB=${VALGRIND_PREFIX}/lib/valgrind - -${VALGRIND_PREFIX}/bin/valgrind $PARAMS $@ diff --git a/scripts/valgrind.sup b/scripts/valgrind.sup deleted file mode 100644 index 04cf7a92d..000000000 --- a/scripts/valgrind.sup +++ /dev/null @@ -1,18 +0,0 @@ -{ - Valgrind x Mesa - Memcheck:Cond - ... - obj:*/swrast_dri.* - obj:*/swrast_dri.* - obj:*/swrast_dri.* - ... -} -{ - Valgrind x Mesa - Memcheck:Value8 - ... - obj:*/swrast_dri.* - obj:*/swrast_dri.* - obj:*/swrast_dri.* - ... -}