Skip to content

Commit

Permalink
Use $HOME instead of ~ in PATH env variable
Browse files Browse the repository at this point in the history
Signed-off-by: Jose Blanquicet <josebl@microsoft.com>
  • Loading branch information
blanquicet committed Dec 8, 2023
1 parent 624adef commit 2918057
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

# Run the test cases
- name: Run the test cases
run: docker run --volume $(pwd)/tests:/tests tools_cloudshell /bin/bash /tests/test.sh
run: docker run -i --volume $(pwd)/tests:/tests tools_cloudshell /bin/bash /tests/test.sh

# Show Docker image size
- name: find the pull request id
Expand Down
11 changes: 11 additions & 0 deletions linux/bash/bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Start: Define custom environment variables

# Add dotnet tools to PATH so users can install a tool using dotnet tools and
# can execute that command from any directory
export PATH=$HOME/.dotnet/tools:$PATH

# Add user's home directories to PATH at the front so they can install tools
# which override defaults
export PATH=$HOME/.local/bin:$HOME/bin:$PATH

# End: Define custom environment variables
8 changes: 4 additions & 4 deletions linux/tools.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ RUN rm -f ./linux/Dockerfile && rm -f /bin/su
RUN ln -s /usr/bin/python3 /usr/bin/python
RUN ln -s /usr/bin/node /usr/bin/nodejs

# Add user's home directories to PATH at the front so they can install tools which
# override defaults
# Add dotnet tools to PATH so users can install a tool using dotnet tools and can execute that command from any directory
ENV PATH ~/.local/bin:~/bin:~/.dotnet/tools:$PATH
# Add custom environment variables to /etc/skel/.bashrc so they will be
# available to users any time they open a new shell.
COPY ./linux/bash/bashrc linux/bashrc
RUN cat linux/bashrc >> /etc/skel/.bashrc && rm linux/bashrc

# Set AZUREPS_HOST_ENVIRONMENT
ENV AZUREPS_HOST_ENVIRONMENT cloud-shell/1.0
4 changes: 2 additions & 2 deletions tests/PSinLinuxCloudShellImage.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ Describe "Various programs installed with expected versions" {

It "has local paths in `$PATH" {
$paths = ($env:PATH).split(":")
$paths | Should -Contain "~/bin"
$paths | Should -Contain "~/.local/bin"
$paths | Should -Contain "$HOME/bin"
$paths | Should -Contain "$HOME/.local/bin"
}

It "Ansible pwsh has modules" {
Expand Down
6 changes: 5 additions & 1 deletion tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,9 @@ pwsh /tests/root-tests.ps1

pwsh -c "Install-Module Pester -Force -Scope AllUsers"

# Run tests as csuser with an interactive shell to verify the configuration in
# the same environment this imange will be used in. Otherwise, the .bashrc won't
# be sourced and the bash configuration (e.g., environment variables) won't be
# set during the tests.
echo "running tests as csuser"
runuser -u csuser pwsh /tests/test.ps1
runuser -u csuser -- /bin/bash -i -c 'pwsh /tests/test.ps1'

0 comments on commit 2918057

Please sign in to comment.