Skip to content
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

TI Script Updates #1648

Merged
merged 11 commits into from
Dec 13, 2024
Merged

TI Script Updates #1648

merged 11 commits into from
Dec 13, 2024

Conversation

saquino0827
Copy link
Contributor

@saquino0827 saquino0827 commented Dec 9, 2024

Description

  • Updates the README for script/README
  • Updates the set up scripts to choose a gradle vs docker setup for the reportstream setup script

#1658

scripts/README.md Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Dec 9, 2024

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Portability Issue
The use of 'sed -i' command with an empty string as an argument for in-place editing might not work on non-Mac Unix systems, such as Linux, where 'sed -i' expects a suffix for backup.

Error Handling
There is no error handling for the case where the Docker container might not be running or the 'docker ps' command fails.

sed -i '' "s|__TI_API_URL__|${TI_LCL_API_URL}|g" "settings/STLTs/Flexion/flexion.yml"
sed -i '' "s|__TI_API_HOST__|$(extract_host_from_url "${TI_LCL_API_URL}")|g" "settings/STLTs/Flexion/flexion.yml"
if [[ ! -z $LOCAL_DOCKER_IMAGE_NAME ]]; then
sed -i '' "s|__TI_API_URL__|${TI_DOCKER_LCL_API_URL_RS_CONFIG}|g" "settings/STLTs/Flexion/flexion.yml"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using a more portable syntax for the 'sed' command to ensure compatibility across different Unix systems. For example, explicitly specify a backup extension and then remove the backup file if needed. [important]

scripts/setup/setup-reportstream.sh Outdated Show resolved Hide resolved
scripts/setup/setup-reportstream.sh Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Dec 9, 2024

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Score
General
Improve the portability of the sed command across different Unix-like systems

Ensure that the sed command uses a portable syntax for in-place editing without
creating a backup, as the current syntax might not work on all Unix-like systems.

scripts/setup/setup-reportstream.sh [46-50]

-sed -i '' "s|__TI_API_URL__|${TI_DOCKER_LCL_API_URL_RS_CONFIG}|g" "settings/STLTs/Flexion/flexion.yml"
+sed -i'' -e "s|__TI_API_URL__|${TI_DOCKER_LCL_API_URL_RS_CONFIG}|g" "settings/STLTs/Flexion/flexion.yml"
 ...
Suggestion importance[1-10]: 7

Why: The suggestion to modify the sed command syntax to ensure compatibility across different Unix-like systems is relevant and enhances the script's robustness. The suggested change correctly addresses the existing code and improves its portability, which is crucial for scripts intended to be run in various environments.

7

scripts/README.md Outdated Show resolved Hide resolved
scripts/README.md Outdated Show resolved Hide resolved
scripts/README.md Show resolved Hide resolved
scripts/setup/setup-reportstream.sh Outdated Show resolved Hide resolved
@saquino0827 saquino0827 marked this pull request as ready for review December 11, 2024 20:34
@basiliskus
Copy link
Contributor

@saquino0827 I just tried this PR and it's not working for me. The if statement is true, and it adds the docker host name, but that doesn't work in my case. I'm wondering if we should just add a note in the docs for people to update their hostname to whatever works in their environment instead of trying to set it automatically. We could still have two separate api url env variables, but instead of having one specific for docker, we could have one specific to the rs setup script

@basiliskus
Copy link
Contributor

I'd propose having this in the env.template file

TI_LCL_API_URL="http://localhost:8080"
TI_LCL_API_URL_RS_CONFIG="http://host.docker.internal:8080"

And directly using TI_LCL_API_URL_RS_CONFIG in scripts/setup/setup-reportstream.sh without the if statement

@saquino0827
Copy link
Contributor Author

I just tried this PR and it's not working for me. The if statement is true, and it adds the docker host name, but that doesn't work in my case. I'm wondering if we should just add a note in the docs for people to update their hostname to whatever works in their environment instead of trying to set it automatically. We could still have two separate api url env variables, but instead of having one specific for docker, we could have one specific to the rs setup script

Yeah, I think I agree with this and I'll update the README.

… can default to leaving it as a config change per user environment

Co-authored-by: Sylvie <[email protected]>
Co-authored-by: GilmoreA6 <[email protected]>
Co-authored-by: pluckyswan <[email protected]>
@saquino0827
Copy link
Contributor Author

I just tried this PR and it's not working for me. The if statement is true, and it adds the docker host name, but that doesn't work in my case. I'm wondering if we should just add a note in the docs for people to update their hostname to whatever works in their environment instead of trying to set it automatically. We could still have two separate api url env variables, but instead of having one specific for docker, we could have one specific to the rs setup script

Yeah, I think I agree with this and I'll update the README.

I gave it a bit more thought with others and I might try one last attempt to getting the scripts working with Docker vs Gradle. We theorized that host.docker.internal settings works when both TI and RS are running in docker. I'll make some changes and do some testing

@basiliskus
Copy link
Contributor

I gave it a bit more thought with others and I might try one last attempt to getting the scripts working with Docker vs Gradle. We theorized that host.docker.internal settings works when both TI and RS are running in docker. I'll make some changes and do some testing

Ok. In case that doesn't work, I propose completely removing the if statement and just adding a note to the readme. Setting values to the person's specific environment in the .env file is the purpose of that file anyway
#1648 (comment)

@saquino0827
Copy link
Contributor Author

@basiliskus can you pull the latest changes and test to see if your environment gets set up correctly?
My machine is having issues running gradle in RS. I'm currently working to figure this out but I figure someone else with a gradle setup could test as well.

Copy link
Contributor

@basiliskus basiliskus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it and it works for me! I just left one comment regarding the variable names

scripts/setup/setup-reportstream.sh Outdated Show resolved Hide resolved
- template update to rename variables
- README update to reference where local set up of RS and TI are
- update local variables to be lower case
@saquino0827
Copy link
Contributor Author

I'd propose having this in the env.template file

TI_LCL_API_URL="http://localhost:8080"
TI_LCL_API_URL_RS_CONFIG="http://host.docker.internal:8080"

And directly using TI_LCL_API_URL_RS_CONFIG in scripts/setup/setup-reportstream.sh without the if statement

I went with your suggestion for naming

@saquino0827 saquino0827 merged commit c6a7096 into main Dec 13, 2024
17 checks passed
@saquino0827 saquino0827 deleted the scripts/README-updates branch December 13, 2024 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants