-
Notifications
You must be signed in to change notification settings - Fork 8
splunk-app new ci #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shmuel44
wants to merge
2
commits into
master
Choose a base branch
from
sk_splunk-app
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| variables: | ||
| CURRENT_BRANCH_NAME: sk_splunk-app #"${INFRA_BRANCH}" | ||
|
|
||
| include: | ||
| - file: "/.gitlab/ci/splunk-app/.gitlab-ci.yml" | ||
| ref: sk_splunk-app #"${INFRA_BRANCH}" | ||
| project: "${CI_PROJECT_NAMESPACE}/infra" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| #!/bin/bash | ||
|
|
||
| CYAN="\e[0;36m" | ||
| CLEAR="\e[0m" | ||
| RED='\033[0;31m' | ||
| GREEN='\033[0;32m' | ||
| BLUE='\033[0;34m' | ||
| NC='\033[0m' | ||
|
|
||
| SECTION_START="\e[0Ksection_start:the_time:section_id\r\e[0K${CYAN}section_header${CLEAR}" | ||
| SECTION_END="\e[0Ksection_end:the_time:section_id\r\e[0K" | ||
|
|
||
| section_start() { | ||
| local section_header section_id start | ||
| start="$SECTION_START" | ||
| if [[ "$#" -eq 1 ]]; then | ||
| section_header="$1" | ||
| section_id="$(echo "$1" | tr -c '[:alnum:]\n\r' '_')" | ||
| elif [[ "$#" -eq 2 ]]; then | ||
| if [[ "$2" =~ -{0,2}collapsed ]]; then | ||
| start="${start/section_id/section_id[collapsed=true]}" | ||
| section_header="$1" | ||
| section_id="$(echo "$1" | tr -c '[:alnum:]\n\r' '_')" | ||
| else | ||
| section_header="$2" | ||
| section_id="$1" | ||
| fi | ||
| elif [[ "$#" -eq 3 && "$3" =~ /^-{0,2}collapsed$/ ]]; then | ||
| start="${start/section_id/section_id[collapsed=true]}" | ||
| section_header="$2" | ||
| section_id="$1" | ||
| else | ||
| echo "section_start should be called with 1-3 args but it was called with $# args" | ||
| echo "acceptable usages:" | ||
| echo " 1. section_start \"<section-header>\"" | ||
| echo " 2. section_start \"<section-start-id>\" \"<section-header>\"" | ||
| echo " 3. section_start \"<section-header>\" --collapse" | ||
| echo " 4. section_start \"<section-start-id>\" \"<section-header>\" --collapse" | ||
| echo "where <section-start-id> is only alphanumeric characters and underscore and" | ||
| echo "--collapse indicates that you would like those log steps to be collapsed in the job log output by default" | ||
| exit 9 | ||
| fi | ||
| start_time=$(date +%s) | ||
| start="$(echo "$start" | sed -e "s/the_time/$start_time/" -e "s/section_id/$section_id/" -e "s/section_header/$section_header/")" | ||
| echo -e "$start" | ||
| date +"[%Y-%m-%dT%H:%M:%S.%3N] section start" | ||
| } | ||
|
|
||
| section_end() { | ||
| local section_id end | ||
| date +"[%Y-%m-%dT%H:%M:%S.%3N] section end" | ||
| end="$SECTION_END" | ||
| if [[ "$#" -eq 1 ]]; then | ||
| section_id="$(echo "$1" | tr -c '[:alnum:]\n\r' '_')" | ||
| else | ||
| echo "section_end should be called with 1 arg but it was called with $# args" | ||
| echo "acceptable usage:" | ||
| echo " 1. section_end \"<section-start-id>\"" | ||
| echo " 2. section_end \"<section-header>\"" | ||
| echo "where <section-start-id> or <section-header> is the id of the section this marks the end of" | ||
| exit 9 | ||
| fi | ||
| end_time=$(date +%s) | ||
| end="$(echo "$end" | sed -e "s/the_time/$end_time/" -e "s/section_id/$section_id/")" | ||
| echo -e "$end" | ||
| } | ||
|
|
||
| job-done() { | ||
| mkdir -p "${PIPELINE_JOBS_FOLDER}" | ||
| echo "creating file ${PIPELINE_JOBS_FOLDER}/${CI_JOB_NAME}.txt" | ||
| echo "done" > "${PIPELINE_JOBS_FOLDER}/${CI_JOB_NAME}.txt" | ||
| echo "finished writing to file ${PIPELINE_JOBS_FOLDER}/${CI_JOB_NAME}.txt" | ||
| } | ||
|
|
||
| sleep-with-progress() { | ||
| local sleep_time=${1:-10} | ||
| local sleep_interval=${2:-1} | ||
| local sleep_message=${3:-"Sleeping... "} | ||
| local columns=${4:-$(tput cols)} | ||
| local sleep_step=$((sleep_time / sleep_interval)) | ||
| for ((i=0; i< sleep_step;i++)); do echo "${sleep_interval}";sleep "${sleep_interval}"; done | poetry run tqdm --total ${sleep_time} --unit seconds --leave --update --colour green -ncols ${columns} --desc "${sleep_message}" 1> /dev/null | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # | ||
| # Bootstraps a development environment. | ||
| # | ||
| # This includes: | ||
| # * install pre-commit hooks | ||
| # * setup virtualenv | ||
|
|
||
| function exit_on_error { | ||
| if [ "${1}" -ne 0 ]; then | ||
| echo "ERROR: ${2}, exiting with code ${1}" 1>&2 | ||
| exit "${1}" | ||
| fi | ||
| } | ||
|
|
||
| # poetry is installed in ~/.local/bin | ||
| PATH=~/.local/bin:$PATH | ||
|
|
||
| if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then | ||
| cat << __EOF__ | ||
| Setup development environment (run with no arguments): | ||
| * install pre-commit hooks (set NO_HOOKS=1 to skip) | ||
| __EOF__ | ||
| exit 0 | ||
| fi | ||
|
|
||
| if [ ! "${PWD}" == "$(git rev-parse --show-toplevel)" ]; then | ||
| cat >&2 <<__EOF__ | ||
| ERROR: this script must be run at the root of the source tree | ||
| __EOF__ | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "=======================" | ||
| if [ -z "${INSTALL_POETRY}" ]; then | ||
| if ! command -v poetry >/dev/null 2>&1; then | ||
| echo "ERROR: poetry is missing. Please run the following command to install it: | ||
| curl -sSL https://install.python-poetry.org | python3 -" 1>&2 | ||
| exit 1 | ||
| fi | ||
| else | ||
| should_install_poetry="yes" | ||
| if command -v poetry >/dev/null 2>&1; then | ||
| if [[ "$(poetry --version)" == "Poetry (version ${POETRY_VERSION})" ]]; then | ||
| echo "Poetry is already installed with the correct version: $(poetry --version)" | ||
| should_install_poetry="no" | ||
| else | ||
| echo "Poetry is already installed with a different version: $(poetry --version), required version: ${POETRY_VERSION}" | ||
| fi | ||
| else | ||
| echo "Poetry isn't installed" | ||
| fi | ||
| if [[ "${should_install_poetry}" == "yes" ]]; then | ||
| echo "Installing Poetry version:${POETRY_VERSION}" | ||
| curl -sSL https://install.python-poetry.org | python3 - --version "${POETRY_VERSION}" | ||
| error_code=$? | ||
| if ! command -v poetry >/dev/null 2>&1; then | ||
| exit_on_error $? "Poetry isn't installed" | ||
| fi | ||
| if [[ "$(poetry --version)" == "Poetry (version ${POETRY_VERSION})" ]]; then | ||
| echo "Poetry version ${POETRY_VERSION} installed successfully" | ||
| else | ||
| exit_on_error 1 "Poetry version $(poetry --version) doesn't match the required version: ${POETRY_VERSION}" | ||
| fi | ||
| if [ -n "${ARTIFACTS_FOLDER}" ] && [ "${error_code}" -ne 0 ]; then | ||
| cp "${PWD}"/poetry-installer-error-*.log "${ARTIFACTS_FOLDER}" | ||
| fi | ||
| exit_on_error $error_code "Failed to install Poetry version:${POETRY_VERSION}" | ||
| fi | ||
| fi | ||
|
|
||
| if [ -n "${NO_HOOKS}" ]; then | ||
| echo "Skipping hooks setup as environment variable NO_HOOKS is set" | ||
| else | ||
| GIT_HOOKS_DIR="${PWD}/.git/hooks" | ||
| if [ ! -e "${GIT_HOOKS_DIR}/pre-commit" ]; then | ||
| echo "Installing 'pre-commit' hooks" | ||
| poetry run pre-commit install | ||
| exit_on_error $? "Failed to install pre-commit hook" | ||
| else | ||
| echo "Skipping install of pre-commit hook as it already exists." | ||
| echo "If you want to re-install: 'rm ${GIT_HOOKS_DIR}/pre-commit' and then run this script again." | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| if [ -n "${CI}" ]; then | ||
| echo "Detected CI environment" | ||
| echo "Checking whether poetry files are valid" | ||
| poetry check --no-interaction | ||
| exit_on_error $? "Failed to check poetry files" | ||
| echo "Installing dependencies..." | ||
| poetry install --no-interaction | ||
| exit_on_error $? "Failed to install dependencies" | ||
| else | ||
| echo "Detected local environment" | ||
| echo "Check if poetry files are valid" | ||
| poetry check | ||
| exit_on_error $? "Failed to check poetry files" | ||
| echo "Installing dependencies..." | ||
| poetry install | ||
| exit_on_error $? "Failed to install dependencies" | ||
| fi | ||
|
|
||
| echo "==========================" | ||
| echo "Done setting up virtualenv with poetry" | ||
| echo "Activate the virtualenv by running: poetry shell" | ||
| echo "Deactivate by running: deactivate" | ||
| echo "=======================" | ||
|
|
||
| echo "Finished setting up the environment." | ||
| exit 0 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.