Skip to content

Commit b242279

Browse files
committed
Run shellcheck
1 parent 72823ee commit b242279

File tree

17 files changed

+51
-18
lines changed

17 files changed

+51
-18
lines changed

.devcontainer/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM mcr.microsoft.com/devcontainers/base:1-bookworm
2+
3+
RUN apt-get update && apt-get install -y shellcheck

.devcontainer/devcontainer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-in-docker
33
{
44
"name": "Docker in Docker",
5-
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6-
"image": "mcr.microsoft.com/devcontainers/javascript-node:1-20-bookworm",
5+
"build": {
6+
"dockerfile": "Dockerfile"
7+
},
78

89
"features": {
910
"ghcr.io/devcontainers/features/docker-in-docker:2": {

.github/workflows/test-features.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,15 @@ jobs:
5151
- name: "Generating tests for '${{ matrix.features }}' scenarios"
5252
working-directory: features
5353
run: devcontainer features test -f ${{ matrix.features }} --skip-autogenerated --skip-duplicated .
54+
55+
shellcheck:
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v4
59+
60+
- name: "Install shellcheck"
61+
run: sudo apt-get update && sudo apt-get install -y shellcheck
62+
63+
- name: "Run shellcheck"
64+
working-directory: features
65+
run: find . -name "*.sh" -type f -exec shellcheck {} +

features/src/bun/install.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ set -e
33

44
USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}"
55

6-
if ! command -v curl &> /dev/null; then
6+
if ! command -v curl > /dev/null 2>&1; then
77
apt update && apt install -y curl unzip
88
fi
99

10-
su ${USERNAME} -c "curl -fsSL https://bun.sh/install | bash"
10+
su "${USERNAME}" -c "curl -fsSL https://bun.sh/install | bash"
1111

1212
rm -rf /var/lib/apt/lists/*
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
#!/bin/sh
2+
13
# This is a no op

features/src/postgres-client/install.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ apt-get update -qq
77

88
apt-get install -y gnupg ca-certificates
99

10-
VERSION_EXISTS=$(apt-cache search --names-only postgresql-client-$POSTGRES_CLIENT_VERSION | wc -l)
10+
client_package="postgresql-client-$POSTGRES_CLIENT_VERSION"
11+
12+
VERSION_EXISTS=$(apt-cache search --names-only "$client_package" | wc -l)
1113

1214
if [ "$VERSION_EXISTS" -ge 1 ]; then
13-
apt-get install --no-install-recommends -y libpq-dev postgresql-client-$POSTGRES_CLIENT_VERSION
15+
apt-get install --no-install-recommends -y libpq-dev "$client_package"
1416
else
1517
apt-get install --no-install-recommends -y postgresql-common libpq-dev
16-
/usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y && apt-get install --no-install-recommends -y postgresql-client-$POSTGRES_CLIENT_VERSION
18+
/usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y && apt-get install --no-install-recommends -y "$client_package"
1719
fi
1820

1921
rm -rf /var/lib/apt/lists/*

features/src/ruby/install.sh

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}"
55

66
apt-get update -y
77
apt-get -y install --no-install-recommends git curl ca-certificates libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential \
8-
libyaml-dev libncurses5-dev libffi-dev libgdbm-dev libxml2-dev rustc
8+
libyaml-dev libncurses5-dev libffi-dev libgdbm-dev libxml2-dev rustc
99

1010
git clone https://github.com/rbenv/rbenv.git /usr/local/share/rbenv
1111
git clone https://github.com/rbenv/ruby-build.git /usr/local/share/ruby-build
@@ -14,20 +14,23 @@ mkdir -p /root/.rbenv/plugins
1414
ln -s /usr/local/share/ruby-build /root/.rbenv/plugins/ruby-build
1515

1616
if [ "${USERNAME}" != "root" ]; then
17-
mkdir -p /home/${USERNAME}/.rbenv/plugins
18-
ln -s /usr/local/share/ruby-build /home/${USERNAME}/.rbenv/plugins/ruby-build
17+
user_home="/home/${USERNAME}"
18+
mkdir -p "${user_home}/.rbenv/plugins"
19+
ln -s /usr/local/share/ruby-build "${user_home}/.rbenv/plugins/ruby-build"
1920

20-
chown -R "${USERNAME}" "/home/${USERNAME}/.rbenv/"
21-
chmod -R g+r+w "/home/${USERNAME}/.rbenv"
21+
chown -R "${USERNAME}" "${user_home}/.rbenv/"
22+
chmod -R g+r+w "${user_home}/.rbenv"
2223

23-
echo 'eval "$(rbenv init -)"' >> /home/${USERNAME}/.bashrc
24+
# shellcheck disable=SC2016
25+
echo 'eval "$(rbenv init -)"' >> "${user_home}/.bashrc"
2426

25-
if [ -f /home/${USERNAME}/.zshrc ]; then
26-
echo 'eval "$(rbenv init -)"' >> /home/${USERNAME}/.zshrc
27+
if [ -f "${user_home}/.zshrc" ]; then
28+
# shellcheck disable=SC2016
29+
echo 'eval "$(rbenv init -)"' >> "${user_home}/.zshrc"
2730
fi
2831
fi
2932

30-
su ${USERNAME} -c "/usr/local/share/rbenv/bin/rbenv install $VERSION"
31-
su ${USERNAME} -c "/usr/local/share/rbenv/bin/rbenv global $VERSION"
33+
su "${USERNAME}" -c "/usr/local/share/rbenv/bin/rbenv install $VERSION"
34+
su "${USERNAME}" -c "/usr/local/share/rbenv/bin/rbenv global $VERSION"
3235

3336
rm -rf /var/lib/apt/lists/*

features/test/activestorage/image_processor_imagemagick.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
set -e
33

4+
# shellcheck source=/dev/null
45
source dev-container-features-test-lib
56

67
check "imagemagick is installed" bash -c "convert --version"

features/test/activestorage/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
set -e
33

4+
# shellcheck source=/dev/null
45
source dev-container-features-test-lib
56

67
check "libvips is installed" bash -c "dpkg -l | grep libvips"

features/test/bun/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
set -e
33

4+
# shellcheck source=/dev/null
45
source dev-container-features-test-lib
56

67
check "Bun is in the PATH" bash -c "which bun"

0 commit comments

Comments
 (0)