Skip to content

Make installer work on any os/arch and add installer tests #3712

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

Merged
merged 5 commits into from
Jul 13, 2021

Conversation

code-asher
Copy link
Member

No description provided.

@code-asher code-asher force-pushed the installer branch 3 times, most recently from 5e49d2d to c23439f Compare July 2, 2021 18:35
@codecov
Copy link

codecov bot commented Jul 2, 2021

Codecov Report

Merging #3712 (4ffecd6) into main (723a274) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3712   +/-   ##
=======================================
  Coverage   62.89%   62.89%           
=======================================
  Files          35       35           
  Lines        1838     1838           
  Branches      371      371           
=======================================
  Hits         1156     1156           
  Misses        577      577           
  Partials      105      105           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 723a274...4ffecd6. Read the comment docs.

@code-asher code-asher force-pushed the installer branch 3 times, most recently from 3bb0c6d to 8133e7e Compare July 2, 2021 21:52
@jsjoeio
Copy link
Contributor

jsjoeio commented Jul 2, 2021

Will this fix #3585?

@code-asher code-asher force-pushed the installer branch 2 times, most recently from d472d4e to 20bc84b Compare July 2, 2021 23:07
@code-asher
Copy link
Member Author

Nope but I'll add a fix.

@code-asher code-asher force-pushed the installer branch 4 times, most recently from b8dce0f to ed3e60d Compare July 3, 2021 00:07
@code-asher code-asher marked this pull request as ready for review July 3, 2021 00:11
@code-asher code-asher requested a review from a team as a code owner July 3, 2021 00:11
@code-asher code-asher requested a review from jsjoeio July 3, 2021 00:12
test:
name: Run script unit tests
runs-on: ubuntu-latest
# This runs on Alpine to make sure we're testing with actual sh.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused, doesn't the script force things to run as bash due to the shebang? Also, Ubuntu should include Bourne shell (e.g. dash) too

Copy link
Member Author

Choose a reason for hiding this comment

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

The installer shebang is #!/bin/sh but since that's often a symlink to bash/dash/etc I've used Alpine to make sure it's really using sh to catch any bashisms that might sneak in there.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah! Good point, I was looking at test-scripts.sh, which uses bash explicitly: #!/usr/bin/env bash

This makes sense then. I think Ubuntu should be using dash for /bin/sh by default, though I'm not sure if GitHub Actions does some customization to the environment:

$ docker run --rm -it ubuntu:latest
root@081f1b5d886d:/# which sh
/usr/bin/sh
root@081f1b5d886d:/# ls -al /usr/bin/sh
lrwxrwxrwx 1 root root 4 Jul 18  2019 /usr/bin/sh -> dash

There's also a handy checkbashisms script in devscripts (install it with apt) that you may find useful. I use it in my dotfiles build: https://github.com/jawnsy/dotfiles/blob/0a27557f15aba599056171abc5ff936e7b530d13/.github/workflows/build.yml#L49

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh that's dope! I'll definitely add that.

Copy link
Contributor

@jsjoeio jsjoeio left a comment

Choose a reason for hiding this comment

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

Nice work! Really happy you laid a foundation for writing script tests. Maybe this'll motivate me to write some for our other scripts.

Previously if the prefix was non-existent we would switch to root even
if the user does have the permissions to create the directory.

Fixes coder#3585
@code-asher code-asher merged commit 862c977 into coder:main Jul 13, 2021
@code-asher code-asher deleted the installer branch July 13, 2021 17:47
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