Skip to content

Commit

Permalink
BC-5468 removedcommented code
Browse files Browse the repository at this point in the history
  • Loading branch information
UzaeirKhan committed Nov 22, 2023
1 parent dea58e7 commit 82ae15d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 135 deletions.
95 changes: 0 additions & 95 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ jobs:
- name: Aggregate JSON Data into one File
id: read_variables
run: |
set -x
workflow=${{ github.workflow }}
workspace_path=${{ github.workspace }}
Expand All @@ -66,20 +65,12 @@ jobs:
brb_instance=""
default_instance=""
nbc_instance=""
# brb_instance=$(op document get cypress-json --vault cy-dev-brb | jq -r '.BRB')
# default_instance=$(op document get cypress-json --vault cy-dev-dbc | jq -r '.DEFAULT')
# nbc_instance=$(op document get cypress-json --vault cy-dev-nbc | jq -r '.NBC')
else
brb_instance=${{ inputs.cypress_brb }}
default_instance=${{ inputs.cypress_default }}
nbc_instance=${{ inputs.cypress_nbc }}
fi
# Ensure that the variables don't contain extra quotes
# brb_instance=$(echo "${brb_instance}" | tr -d '"')
# default_instance=$(echo "${default_instance}" | tr -d '"')
# nbc_instance=$(echo "${nbc_instance}" | tr -d '"')
chmod +x ${{ github.workspace }}/e2e-system-tests/scripts/aggregate-json-files.sh
${{ github.workspace }}/e2e-system-tests/scripts/aggregate-json-files.sh \
"${workflow}" \
Expand All @@ -88,92 +79,6 @@ jobs:
"${nbc_instance}" \
"${workspace_path}"
# instances=(brb dbc nbc)
# environments=(dev ref)
# cypress_brb=""
# cypress_default=""
# cypress_nbc=""
# workflow_name="${{ github.workflow }}"
# check_environment() {
# local url="$1"
# if [[ $url == *"staging"* || $url == *"schulportal"* ]]; then
# echo "ref"
# else
# echo "dev"
# fi
# }
# if [[ $workflow_name == *"manual"* ]]; then
# echo "This is a manual workflow"
# cypress_brb="${{ github.event.inputs.instance1 }}"
# cypress_nbc="${{ github.event.inputs.instance2 }}"
# cypress_default="${{ github.event.inputs.instance3 }}"
# check_cypress_brb=$(check_environment "$cypress_brb")
# check_cypress_default=$(check_environment "$cypress_default")
# check_cypress_nbc=$(check_environment "$cypress_nbc")
# echo "TAG=tag:stable:ci" >> $GITHUB_OUTPUT
# echo "$TAG"
# elif [[ $workflow_name == *"automatic"* || $workflow_name == *"scheduled"* ]]; then
# echo "This is an automatic or scheduled workflow"
# check_cypress_brb=""
# check_cypress_default=""
# check_cypress_nbc=""
# echo "TAG=tag:stable:ci" >> $GITHUB_OUTPUT
# echo "$TAG"
# else
# echo "This is a remote workflow"
# cypress_brb="${{ inputs.cypress_brb }}"
# cypress_default="${{ inputs.cypress_default }}"
# cypress_nbc="${{ inputs.cypress_nbc }}"
# check_cypress_brb=$(check_environment "$cypress_brb")
# check_cypress_default=$(check_environment "$cypress_default")
# check_cypress_nbc=$(check_environment "$cypress_nbc")
# echo "TAG=tag:stable:pr:ci" >> $GITHUB_OUTPUT
# echo "$TAG"
# fi
# if [[ $check_cypress_brb == "ref" || $check_cypress_default == "ref" || $check_cypress_nbc == "ref" ]]; then
# environment="ref"
# else
# environment="dev"
# fi
# file_paths=()
# declare -A key_value_pairs
# for instance in "${instances[@]}"; do
# if [[ $workflow_name == *"manual"* || $workflow_name == *"remote"* ]]; then
# file_path="${{ github.workspace }}/e2e-system-tests/env_variables/file-${environment}-${instance}.json"
# else
# file_path="${{ github.workspace }}/e2e-system-tests/env_variables/file-dev-${instance}.json"
# fi
# file_paths+=("$file_path")
# while IFS="=" read -r key value; do
# key_value_pairs["$key"]=$value
# done < <(jq -r 'to_entries | .[] | "\(.key)=\(.value)"' "$file_path")
# done
# json_output=$(jq -s 'reduce .[] as $item ({}; . + ($item | with_entries(.value |= tostring)))' "${file_paths[@]}")
# echo "$json_output" > ${{ github.workspace }}/e2e-system-tests/env_variables/combined_credentials.json
# aggregated_json_file="${{ github.workspace }}/e2e-system-tests/env_variables/combined_credentials.json"
# if [[ !($workflow_name == *"automatic"* || $workflow_name == *"scheduled"*) ]]; then
# updated_json=$(jq --arg brb "$cypress_brb" \
# --arg default "$cypress_default" \
# --arg nbc "$cypress_nbc" \
# '.BRB = $brb | .DEFAULT = $default | .NBC = $nbc' "$aggregated_json_file")
# echo "$updated_json" > "$aggregated_json_file"
# fi
- name: Clean up previous report
uses: cypress-io/github-action@v5
with:
Expand Down
52 changes: 12 additions & 40 deletions scripts/aggregate-json-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,6 @@ default_instance=$3
nbc_instance=$4
workspace_path=$5

echo "-----------------------------"
echo "Workflow is:"$workflow_name
echo "-----------------------------"
echo "Working Directory:"$workspace_path
echo "-----------------------------"
echo "BRB Instance:"$brb_instance
echo "-----------------------------"
echo "Nbc Instance:"$nbc_instance
echo "-----------------------------"
echo "Default Instance:"$default_instance

# cypress_brb=""
# cypress_default=""
# cypress_nbc=""
# workflow_name="${{ github.workflow }}"

check_environment() {
local url="$1"

Expand All @@ -37,33 +21,22 @@ check_environment() {

if [[ $workflow_name == *"manual"* ]]; then
echo "This is a manual workflow"
# cypress_brb="${{ github.event.inputs.instance1 }}"
# cypress_nbc="${{ github.event.inputs.instance2 }}"
# cypress_default="${{ github.event.inputs.instance3 }}"
brb_env=$(check_environment "$brb_instance")
default_env=$(check_environment "$default_instance")
nbc_env=$(check_environment "$nbc_instance")
echo "TAG=tag:stable:ci" >> $GITHUB_OUTPUT
echo "TAG=tag:stable:ci" >>$GITHUB_OUTPUT
echo "$TAG"
elif [[ $workflow_name == *"automatic"* || $workflow_name == *"scheduled"* ]]; then
echo "This is an automatic or scheduled workflow"
brb_env=""
default_env=""
nbc_env=""
echo "TAG=tag:stable:ci" >> $GITHUB_OUTPUT
echo "TAG=tag:stable:ci" >>$GITHUB_OUTPUT
echo "$TAG"
else
echo "This is a remote workflow"
# cypress_brb="${{ inputs.cypress_brb }}"
# cypress_default="${{ inputs.cypress_default }}"
# cypress_nbc="${{ inputs.cypress_nbc }}"
brb_env=$(check_environment "$brb_instance")
default_env=$(check_environment "$default_instance")
nbc_env=$(check_environment "$nbc_instance")
echo "TAG=tag:stable:pr:ci" >> $GITHUB_OUTPUT
echo "TAG=tag:stable:pr:ci" >>$GITHUB_OUTPUT
echo "$TAG"
fi

brb_env=$(check_environment "$brb_instance")
default_env=$(check_environment "$default_instance")
nbc_env=$(check_environment "$nbc_instance")

if [[ $brb_env == "ref" || $default_env == "ref" || $nbc_env == "ref" ]]; then
environment="ref"
else
Expand Down Expand Up @@ -91,13 +64,12 @@ json_output=$(jq -s 'reduce .[] as $item ({}; . + ($item | with_entries(.value |

aggregated_json_file="$workspace_path/e2e-system-tests/env_variables/combined_credentials.json"

echo "$json_output" > "$aggregated_json_file"

echo "$json_output" >"$aggregated_json_file"

if [[ !($workflow_name == *"automatic"* || $workflow_name == *"scheduled"*) ]]; then
updated_json=$(jq --arg brb "$brb_instance" \
--arg default "$default_instance" \
--arg nbc "$nbc_instance" \
'.BRB = $brb | .DEFAULT = $default | .NBC = $nbc' "$aggregated_json_file")
echo "$updated_json" > "$aggregated_json_file"
--arg default "$default_instance" \
--arg nbc "$nbc_instance" \
'.BRB = $brb | .DEFAULT = $default | .NBC = $nbc' "$aggregated_json_file")
echo "$updated_json" >"$aggregated_json_file"
fi

0 comments on commit 82ae15d

Please sign in to comment.