refactor: passing linter for root bash scripts (#1569)

This commit is contained in:
Zac 2023-07-20 13:25:13 -05:00 committed by GitHub
parent d6b7880a05
commit b4318d78a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 96 additions and 73 deletions

View file

@ -1,8 +1,9 @@
#!/bin/bash
#!/usr/bin/env bash
# shellcheck disable=SC1091
set -ex
if [ -f "./remote-dependencies.tar" ]; then
if [[ -f "./remote-dependencies.tar" ]]; then
tar -xf ./remote-dependencies.tar ./vscode/remote/node_modules
fi

View file

@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash
# shellcheck disable=SC2129
set -e
@ -22,9 +23,9 @@ else
export SHOULD_DEPLOY="yes"
fi
if [[ "${GITHUB_ENV}" ]]; then
if [[ "${GITHUB_ENV}" ]]; then
echo "GITHUB_BRANCH=${GITHUB_BRANCH}" >> "${GITHUB_ENV}"
echo "SHOULD_BUILD=${SHOULD_BUILD}" >> "${GITHUB_ENV}"
echo "SHOULD_DEPLOY=${SHOULD_DEPLOY}" >> "${GITHUB_ENV}"
echo "SHOULD_BUILD=${SHOULD_BUILD}" >> "${GITHUB_ENV}"
echo "SHOULD_DEPLOY=${SHOULD_DEPLOY}" >> "${GITHUB_ENV}"
echo "VSCODE_QUALITY=${VSCODE_QUALITY}" >> "${GITHUB_ENV}"
fi

View file

@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash
# shellcheck disable=SC2129
set -e
@ -12,7 +13,7 @@ GITHUB_RESPONSE=$( curl -s -H "Authorization: token ${GITHUB_TOKEN}" "https://ap
LATEST_VERSION=$( echo "${GITHUB_RESPONSE}" | jq -c -r '.tag_name' )
if [[ "${LATEST_VERSION}" =~ ^([0-9]+\.[0-9]+\.[0-9]+) ]]; then
if [ "${MS_TAG}" != "${BASH_REMATCH[1]}" ]; then
if [[ "${MS_TAG}" != "${BASH_REMATCH[1]}" ]]; then
echo "New VSCode version, new build"
export SHOULD_BUILD="yes"
elif [[ "${NEW_RELEASE}" == "true" ]]; then
@ -22,7 +23,7 @@ if [[ "${LATEST_VERSION}" =~ ^([0-9]+\.[0-9]+\.[0-9]+) ]]; then
BODY=$( echo "${GITHUB_RESPONSE}" | jq -c -r '.body' )
if [[ "${BODY}" =~ \[([a-z0-9]+)\] ]]; then
if [ "${MS_COMMIT}" != "${BASH_REMATCH[1]}" ]; then
if [[ "${MS_COMMIT}" != "${BASH_REMATCH[1]}" ]]; then
echo "New VSCode Insiders version, new build"
export SHOULD_BUILD="yes"
fi
@ -46,7 +47,7 @@ contains() {
echo "${ASSETS}" | grep "${1}\""
}
if [ "${ASSETS}" != "null" ]; then
if [[ "${ASSETS}" != "null" ]]; then
# macos
if [[ "${OS_NAME}" == "osx" ]]; then
if [[ "${VSCODE_ARCH}" == "arm64" ]]; then
@ -366,6 +367,7 @@ else
export SHOULD_BUILD="yes"
fi
echo "SHOULD_BUILD=${SHOULD_BUILD}" >> "${GITHUB_ENV}"
echo "SHOULD_BUILD_APPIMAGE=${SHOULD_BUILD_APPIMAGE}" >> "${GITHUB_ENV}"
echo "SHOULD_BUILD_DEB=${SHOULD_BUILD_DEB}" >> "${GITHUB_ENV}"

View file

@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash
# shellcheck disable=SC2129
set -e
@ -12,28 +13,28 @@ if [[ -z "${RELEASE_VERSION}" ]]; then
if [[ "${VSCODE_LATEST}" == "yes" ]] || [[ ! -f "insider.json" ]]; then
UPDATE_INFO=$( curl --silent --fail https://update.code.visualstudio.com/api/update/darwin/insider/0000000000000000000000000000000000000000 )
else
export MS_COMMIT=$(jq -r '.commit' insider.json)
export MS_TAG=$(jq -r '.tag' insider.json)
MS_COMMIT=$( jq -r '.commit' insider.json )
MS_TAG=$( jq -r '.tag' insider.json )
fi
else
UPDATE_INFO=$( curl --silent --fail https://update.code.visualstudio.com/api/update/darwin/stable/0000000000000000000000000000000000000000 )
fi
if [[ -z "${MS_COMMIT}" ]]; then
export MS_COMMIT=$( echo "${UPDATE_INFO}" | jq -r '.version' )
export MS_TAG=$( echo "${UPDATE_INFO}" | jq -r '.name' )
MS_COMMIT=$( echo "${UPDATE_INFO}" | jq -r '.version' )
MS_TAG=$( echo "${UPDATE_INFO}" | jq -r '.name' )
if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
export MS_TAG="${MS_TAG/\-insider/}"
MS_TAG="${MS_TAG/\-insider/}"
fi
fi
date=$( date +%Y%j )
if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
export RELEASE_VERSION="${MS_TAG}.${date: -5}-insider"
RELEASE_VERSION="${MS_TAG}.${date: -5}-insider"
else
export RELEASE_VERSION="${MS_TAG}.${date: -5}"
RELEASE_VERSION="${MS_TAG}.${date: -5}"
fi
else
if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
@ -45,8 +46,8 @@ else
exit 1
fi
if [[ "${MS_TAG}" == "$(jq -r '.tag' insider.json)" ]]; then
export MS_COMMIT=$(jq -r '.commit' insider.json)
if [[ "${MS_TAG}" == "$( jq -r '.tag' insider.json )" ]]; then
MS_COMMIT=$( jq -r '.commit' insider.json )
else
echo "Error: No MS_COMMIT for ${RELEASE_VERSION}"
exit 1
@ -77,8 +78,8 @@ if [[ -z "${MS_TAG}" ]]; then
else
UPDATE_INFO=$( curl --silent --fail https://update.code.visualstudio.com/api/update/darwin/stable/0000000000000000000000000000000000000000 )
fi
export MS_COMMIT=$( echo "${UPDATE_INFO}" | jq -r '.version' )
export MS_TAG=$( echo "${UPDATE_INFO}" | jq -r '.name' )
MS_COMMIT=$( echo "${UPDATE_INFO}" | jq -r '.version' )
MS_TAG=$( echo "${UPDATE_INFO}" | jq -r '.name' )
elif [[ -z "${MS_COMMIT}" ]]; then
REFERENCE=$( git ls-remote --tags | grep -x ".*refs\/tags\/${MS_TAG}" | head -1 )
@ -86,8 +87,8 @@ elif [[ -z "${MS_COMMIT}" ]]; then
echo "Error: The following tag can't be found: ${MS_TAG}"
exit 1
elif [[ "${REFERENCE}" =~ ^([[:alnum:]]+)[[:space:]]+refs\/tags\/([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
export MS_COMMIT="${BASH_REMATCH[1]}"
export MS_TAG="${BASH_REMATCH[2]}"
MS_COMMIT="${BASH_REMATCH[1]}"
MS_TAG="${BASH_REMATCH[2]}"
else
echo "Error: The following reference can't be parsed: ${REFERENCE}"
exit 1
@ -108,3 +109,7 @@ if [[ "${GITHUB_ENV}" ]]; then
echo "MS_COMMIT=${MS_COMMIT}" >> "${GITHUB_ENV}"
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> "${GITHUB_ENV}"
fi
export MS_TAG
export MS_COMMIT
export RELEASE_VERSION

View file

@ -1,10 +1,10 @@
#!/bin/bash
#!/usr/bin/env bash
set -ex
GH_ARCH="amd64"
VERSION=`curl --retry 12 --retry-delay 30 "https://api.github.com/repos/cli/cli/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/' | cut -c2-`
VERSION=$( curl --retry 12 --retry-delay 30 "https://api.github.com/repos/cli/cli/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/' | cut -c2- )
curl --retry 12 --retry-delay 120 -sSL "https://github.com/cli/cli/releases/download/v${VERSION}/gh_${VERSION}_linux_${GH_ARCH}.tar.gz" -o "gh_${VERSION}_linux_${GH_ARCH}.tar.gz"

View file

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -e

View file

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
if [[ "${1}" == *patch ]]; then
FILE="../patches/${1}"
@ -17,7 +17,7 @@ fi
git apply --reject "../patches/helper/settings.patch"
read -p "Press any key when the conflict have been resolved..." -n1 -s
read -rp "Press any key when the conflict have been resolved..." -n1 -s
git restore .vscode/settings.json

View file

@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash
# shellcheck disable=SC1091
set -e
@ -29,7 +30,7 @@ if [[ "${OS_NAME}" == "osx" ]]; then
security create-keychain -p mysecretpassword "${KEYCHAIN}"
security set-keychain-settings -lut 21600 "${KEYCHAIN}"
security unlock-keychain -p mysecretpassword "${KEYCHAIN}"
security list-keychains -s `security list-keychains | xargs` "${KEYCHAIN}"
security list-keychains -s "$(security list-keychains | xargs)" "${KEYCHAIN}"
# security list-keychains -d user
# security show-keychain-info ${KEYCHAIN}

View file

@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash
# shellcheck disable=SC1091,2154
set -e
@ -21,10 +22,9 @@ cd vscode || { echo "'vscode' dir not found"; exit 1; }
{ set +x; } 2>/dev/null
for file in ../patches/*.patch; do
if [ -f "${file}" ]; then
if [[ -f "${file}" ]]; then
echo applying patch: "${file}";
git apply --ignore-whitespace "${file}"
if [ $? -ne 0 ]; then
if ! git apply --ignore-whitespace "${file}"; then
echo failed to apply patch "${file}" 1>&2
fi
fi
@ -32,10 +32,9 @@ done
if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
for file in ../patches/insider/*.patch; do
if [ -f "${file}" ]; then
if [[ -f "${file}" ]]; then
echo applying patch: "${file}";
git apply --ignore-whitespace "${file}"
if [ $? -ne 0 ]; then
if ! git apply --ignore-whitespace "${file}"; then
echo failed to apply patch "${file}" 1>&2
fi
fi
@ -43,10 +42,9 @@ if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
fi
for file in ../patches/user/*.patch; do
if [ -f "${file}" ]; then
if [[ -f "${file}" ]]; then
echo applying user patch: "${file}";
git apply --ignore-whitespace "${file}"
if [ $? -ne 0 ]; then
if ! git apply --ignore-whitespace "${file}"; then
echo failed to apply patch "${file}" 1>&2
fi
fi
@ -75,7 +73,8 @@ else
git checkout 102b347da0c92c29f9c67df22e864e70249cf086
npm install
export npm_config_node_gyp=`pwd`
npm_config_node_gyp=$( pwd )
export npm_config_node_gyp
cd ../..
fi
@ -84,14 +83,18 @@ else
fi
setpath() {
local jsonTmp
{ set +x; } 2>/dev/null
echo "$( cat "${1}.json" | jq --arg 'path' "${2}" --arg 'value' "${3}" 'setpath([$path]; $value)' )" > "${1}.json"
jsonTmp=$( jq --arg 'path' "${2}" --arg 'value' "${3}" 'setpath([$path]; $value)' "${1}.json" )
echo "${jsonTmp}" > "${1}.json"
set -x
}
setpath_json() {
local jsonTmp
{ set +x; } 2>/dev/null
echo "$( cat "${1}.json" | jq --arg 'path' "${2}" --argjson 'value' "${3}" 'setpath([$path]; $value)' )" > "${1}.json"
jsonTmp=$( jq --arg 'path' "${2}" --argjson 'value' "${3}" 'setpath([$path]; $value)' "${1}.json" )
echo "${jsonTmp}" > "${1}.json"
set -x
}
@ -165,20 +168,22 @@ else
setpath "product" "win32arm64UserAppId" "{{57FD70A5-1B8D-4875-9F40-C5553F094828}"
fi
echo "$( jq -s '.[0] * .[1]' product.json ../product.json )" > product.json
jsonTmp=$( jq -s '.[0] * .[1]' product.json ../product.json )
echo "${jsonTmp}" > ../product.json
unset jsonTmp
cat product.json
# package.json
cp package.json package.json.bak
setpath "package" "version" $( echo "${RELEASE_VERSION}" | sed -n -E "s/^(.*)\.([0-9]+)(-insider)?$/\1/p" )
setpath "package" "release" $( echo "${RELEASE_VERSION}" | sed -n -E "s/^(.*)\.([0-9]+)(-insider)?$/\2/p" )
setpath "package" "version" "$( echo "${RELEASE_VERSION}" | sed -n -E "s/^(.*)\.([0-9]+)(-insider)?$/\1/p" )"
setpath "package" "release" "$( echo "${RELEASE_VERSION}" | sed -n -E "s/^(.*)\.([0-9]+)(-insider)?$/\2/p" )"
replace 's|Microsoft Corporation|VSCodium|' package.json
# announcements
replace "s|\\[\\/\\* BUILTIN_ANNOUNCEMENTS \\*\\/\\]|$( cat ../announcements-builtin.json | tr -d '\n' )|" src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts
replace "s|\\[\\/\\* BUILTIN_ANNOUNCEMENTS \\*\\/\\]|$( tr -d '\n' < ../announcements-builtin.json )|" src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts
../undo_telemetry.sh

View file

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -e
@ -19,7 +19,7 @@ if [[ $( gh release view --repo "${ASSETS_REPOSITORY}" "${RELEASE_VERSION}" 2>&1
NOTES="update vscode to [${MS_COMMIT}](https://github.com/microsoft/vscode/tree/${MS_COMMIT})"
CREATE_OPTIONS=""
else
NOTES="update vscode to [${MS_TAG}](https://code.visualstudio.com/updates/v$( echo ${MS_TAG//./_} | cut -d'_' -f 1,2 ))"
NOTES="update vscode to [${MS_TAG}](https://code.visualstudio.com/updates/v$( echo "${MS_TAG//./_}" | cut -d'_' -f 1,2 ))"
CREATE_OPTIONS="--generate-notes"
fi

View file

@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash
# shellcheck disable=SC1091,SC2016
set -ex
@ -25,7 +26,7 @@ else
fi
export -f replace_with_debug
d1=`date +%s`
d1=$( date +%s )
if [[ "${OS_NAME}" == "linux" ]]; then
if [[ ${VSCODE_ARCH} == "x64" ]]; then
@ -39,6 +40,6 @@ else
./node_modules/@vscode/ripgrep/bin/rg --no-ignore --path-separator=// -l "${SEARCH}" . | xargs -I {} bash -c 'replace_with_debug "${1}" "{}"' _ "${REPLACEMENT}"
fi
d2=`date +%s`
d2=$( date +%s )
echo "undo_telemetry: $( echo $((${d2} - ${d1})) )s"
echo "undo_telemetry: $((d2 - d1))s"

View file

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -e
@ -12,7 +12,8 @@ if [[ -z "${GITHUB_TOKEN}" ]]; then
exit
fi
echo "$( cat "insider.json" | jq --arg 'tag' "${MS_TAG/\-insider/}" --arg 'commit' "${MS_COMMIT}" '. | .tag=$tag | .commit=$commit' )" > "insider.json"
jsonTmp=$( jq --arg 'tag' "${MS_TAG/\-insider/}" --arg 'commit' "${MS_COMMIT}" '. "insider.json" | .tag=$tag | .commit=$commit' )
echo "${jsonTmp}" > "insider.json" && unset jsonTmp
git config user.email "$( echo "${GITHUB_USERNAME}" | awk '{print tolower($0)}' )-ci@not-real.com"
git config user.name "${GITHUB_USERNAME} CI"
@ -20,7 +21,7 @@ git add .
CHANGES=$( git status --porcelain )
if [[ ! -z "${CHANGES}" ]]; then
if [[ -n "${CHANGES}" ]]; then
git commit -m "build(insider): update to commit ${MS_COMMIT:0:7}"
if ! git push origin insider --quiet; then

View file

@ -1,3 +1,5 @@
# shellcheck disable=SC1091,2148
DEFAULT_TRUE="'default': true"
DEFAULT_FALSE="'default': false"
DEFAULT_ON="'default': TelemetryConfiguration.ON"
@ -21,7 +23,7 @@ update_setting () {
local SETTING="${1}"
local LINE_NUM=0
while read -r line; do
local LINE_NUM=$(( $LINE_NUM + 1 ))
local LINE_NUM=$(( LINE_NUM + 1 ))
if [[ "${line}" == *"${SETTING}"* ]]; then
local IN_SETTING=1
fi

View file

@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash
# shellcheck disable=SC1091
set -e
@ -49,22 +50,23 @@ REPOSITORY_NAME="${VERSIONS_REPOSITORY/*\//}"
URL_BASE="https://github.com/${ASSETS_REPOSITORY}/releases/download/${RELEASE_VERSION}"
generateJson() {
local url name version productVersion sha1hash sha256hash timestamp
JSON_DATA="{}"
# generate parts
local url="${URL_BASE}/${ASSET_NAME}"
local name="${RELEASE_VERSION}"
local version="${BUILD_SOURCEVERSION}"
local productVersion="${RELEASE_VERSION}"
local timestamp=$(node -e 'console.log(Date.now())')
url="${URL_BASE}/${ASSET_NAME}"
name="${RELEASE_VERSION}"
version="${BUILD_SOURCEVERSION}"
productVersion="${RELEASE_VERSION}"
timestamp=$( node -e 'console.log(Date.now())' )
if [[ ! -f "assets/${ASSET_NAME}" ]]; then
echo "Downloading asset '${ASSET_NAME}'"
gh release download --repo "${ASSETS_REPOSITORY}" "${RELEASE_VERSION}" --dir "assets" --pattern "${ASSET_NAME}*"
fi
local sha1hash=$(cat "assets/${ASSET_NAME}.sha1" | awk '{ print $1 }')
local sha256hash=$(cat "assets/${ASSET_NAME}.sha256" | awk '{ print $1 }')
sha1hash=$( awk '{ print $1 }' "assets/${ASSET_NAME}.sha1" )
sha256hash=$( awk '{ print $1 }' "assets/${ASSET_NAME}.sha256" )
# check that nothing is blank (blank indicates something awry with build)
for key in url name version productVersion sha1hash timestamp sha256hash; do
@ -75,7 +77,7 @@ generateJson() {
done
# generate json
JSON_DATA=$(jq \
JSON_DATA=$( jq \
--arg url "${url}" \
--arg name "${name}" \
--arg version "${version}" \
@ -84,7 +86,7 @@ generateJson() {
--arg timestamp "${timestamp}" \
--arg sha256hash "${sha256hash}" \
'. | .url=$url | .name=$name | .version=$version | .productVersion=$productVersion | .hash=$hash | .timestamp=$timestamp | .sha256hash=$sha256hash' \
<<<'{}')
<<<'{}' )
}
updateLatestVersion() {
@ -168,7 +170,7 @@ git add .
CHANGES=$( git status --porcelain )
if [[ ! -z "${CHANGES}" ]]; then
if [[ -n "${CHANGES}" ]]; then
echo "Some changes have been found, pushing them"
dateAndMonth=$( date "+%D %T" )

View file

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# All common functions can be added to this file

View file

@ -1,13 +1,13 @@
#!/bin/bash
#!/usr/bin/env bash
if [[ -z "${BUILD_SOURCEVERSION}" ]]; then
if type -t "sha1sum" > /dev/null 2>&1; then
export BUILD_SOURCEVERSION=$( echo "${RELEASE_VERSION/-*/}" | sha1sum | cut -d' ' -f1 )
BUILD_SOURCEVERSION=$( echo "${RELEASE_VERSION/-*/}" | sha1sum | cut -d' ' -f1 )
else
npm install -g checksum
export BUILD_SOURCEVERSION=$( echo "${RELEASE_VERSION/-*/}" | checksum )
BUILD_SOURCEVERSION=$( echo "${RELEASE_VERSION/-*/}" | checksum )
fi
echo "BUILD_SOURCEVERSION=\"${BUILD_SOURCEVERSION}\""
@ -17,3 +17,5 @@ if [[ -z "${BUILD_SOURCEVERSION}" ]]; then
echo "BUILD_SOURCEVERSION=${BUILD_SOURCEVERSION}" >> "${GITHUB_ENV}"
fi
fi
export BUILD_SOURCEVERSION