<commit_before>#!/bin/sh
set -e
set -u

# Install basic software used for checking github API rate limit
yum install -y epel-release
yum -y install curl jq expect

# define in env variable GITHUB_TOKEN only if it is defined
# else check if github rate limit is enough, else will abort requiring to set GITHUB_TOKEN value

if [ ! -z "${GITHUB_TOKEN-}" ]; then
    export GITHUB_TOKEN=$GITHUB_TOKEN;
    echo "Setting GITHUB_TOKEN value as provided";
else
    export GITHUB_LIMIT=$(curl -s 'https://api.github.com/rate_limit' | jq '.rate .remaining');
    echo "Current API rate limit https://api.github.com is ${GITHUB_LIMIT}";
    if [ "${GITHUB_LIMIT}" -lt 10 ]; then
        printf "\033[0;31m\n\n\nRate limit on https://api.github.com is reached so in order to build this image, ";
        printf "the build argument GITHUB_TOKEN needs to be provided so build will not fail.\n\n\n\033[0m";
        exit 1;
    else
        echo "GITHUB_TOKEN variable not set but https://api.github.com rate limit has enough slots";
    fi
fi

# Add yarn repo
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo
# Install nodejs/npm/yarn
curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -
yum install -y nodejs yarn

echo "npm version:"
npm --version
echo "nodejs version:"
node --version

# Include opendjk for Java support
yum install -y gcc-c++ make python git supervisor java-1.8.0-openjdk-devel bzip2

# Clone specific tag of a Theia version
git clone --branch v${THEIA_VERSION} https://github.com/theia-ide/theia ${HOME}/theia-source-code

# Apply patches (if any)
if [ -d "${HOME}/patches/${THEIA_VERSION}" ]; then
    echo "Applying patches for Theia version ${THEIA_VERSION}";
    for file in $(find "${HOME}/patches/${THEIA_VERSION}" -name '*.patch'); do
        echo "Patching with ${file}";
        cd ${HOME}/theia-source-code && patch -p1 < ${file};
    done
fi

# Compile Theia
cd ${HOME}/theia-source-code && yarn
<commit_msg>CHE-10827 Add patch to the target centos image<commit_after>#!/bin/sh
set -e
set -u

# Install basic software used for checking github API rate limit
yum install -y epel-release
yum -y install curl jq expect

# define in env variable GITHUB_TOKEN only if it is defined
# else check if github rate limit is enough, else will abort requiring to set GITHUB_TOKEN value

if [ ! -z "${GITHUB_TOKEN-}" ]; then
    export GITHUB_TOKEN=$GITHUB_TOKEN;
    echo "Setting GITHUB_TOKEN value as provided";
else
    export GITHUB_LIMIT=$(curl -s 'https://api.github.com/rate_limit' | jq '.rate .remaining');
    echo "Current API rate limit https://api.github.com is ${GITHUB_LIMIT}";
    if [ "${GITHUB_LIMIT}" -lt 10 ]; then
        printf "\033[0;31m\n\n\nRate limit on https://api.github.com is reached so in order to build this image, ";
        printf "the build argument GITHUB_TOKEN needs to be provided so build will not fail.\n\n\n\033[0m";
        exit 1;
    else
        echo "GITHUB_TOKEN variable not set but https://api.github.com rate limit has enough slots";
    fi
fi

# Add yarn repo
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo
# Install nodejs/npm/yarn
curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -
yum install -y nodejs yarn patch

echo "npm version:"
npm --version
echo "nodejs version:"
node --version

# Include opendjk for Java support
yum install -y gcc-c++ make python git supervisor java-1.8.0-openjdk-devel bzip2

# Clone specific tag of a Theia version
git clone --branch v${THEIA_VERSION} https://github.com/theia-ide/theia ${HOME}/theia-source-code

# Apply patches (if any)
if [ -d "${HOME}/patches/${THEIA_VERSION}" ]; then
    echo "Applying patches for Theia version ${THEIA_VERSION}";
    for file in $(find "${HOME}/patches/${THEIA_VERSION}" -name '*.patch'); do
        echo "Patching with ${file}";
        cd ${HOME}/theia-source-code && patch -p1 < ${file};
    done
fi

# Compile Theia
cd ${HOME}/theia-source-code && yarn

{'fraction_non_alphanumeric': 0.12509400852343946, 'fraction_numerical': 0.010779644021057909, 'mean_word_length': 3.3846153846153846, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 14, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5424679', 'n_tokens_mistral': 1369, 'n_tokens_neox': 1332, 'n_words': 460}