Skip to content

Commit

Permalink
💚 bash5 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jcaillon committed Feb 1, 2025
1 parent 2218647 commit f6ca97a
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 84 deletions.
34 changes: 0 additions & 34 deletions .github/workflows/self-test-bash5.yaml

This file was deleted.

30 changes: 8 additions & 22 deletions .github/workflows/self-test-installation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,7 @@ jobs:
self-test-install:
# We run this job in a container to avoid polluting the host
runs-on: ubuntu-latest
container: ubuntu:latest
steps:
# Install dependencies
- name: Run valet self install && self update && self extend
env:
VALET_CONFIG_ENABLE_COLORS: true
VALET_CONFIG_DISABLE_PROGRESS: true
RUNNING_IN_DOCKER: true
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: |
# Install dependencies
apt-get update -qq
apt-get install -qq -y curl sudo makepasswd uidmap git 1>/dev/null
# Create the 'me' user with sudo privileges
echo 'me' > /tmp/pw
useradd -m -u 1987 -U -p "$(makepasswd --crypt-md5 --clearfrom=/tmp/pw)" me
echo "me ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers.d/me-sudo
chsh -s /bin/bash me;
# checkout the repository
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -57,11 +39,15 @@ jobs:
# Runs our tests
- name: Run valet self install && self update && self extend
env:
VALET_CONFIG_ENABLE_COLORS: true
VALET_CONFIG_DISABLE_PROGRESS: true
RUNNING_IN_DOCKER: true
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: |
chmod +x ./tests.d/self-install/test
./tests.d/self-install/test
docker run --rm \
-v $PWD:/app \
-w /app \
-e VALET_CONFIG_ENABLE_COLORS=true \
-e RUNNING_IN_DOCKER=true \
-e BRANCH_NAME=${BRANCH_NAME} \
noyacode/minideb-bash5.0 \
./tests.d/self-install/test self test -C
11 changes: 11 additions & 0 deletions .github/workflows/self-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,14 @@ jobs:
bash --version
chmod +x valet
./valet self test -C
# Runs tests with bash 5
- name: Run valet self test on bash5
run: |
chmod +x valet
docker run --rm \
-v $PWD:/app \
-w /app \
-e VALET_CONFIG_ENABLE_COLORS=true \
noyacode/minideb-bash5.0 \
./valet self test -C
2 changes: 1 addition & 1 deletion libraries.d/core
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ function fs::cleanTempFiles() {
log::debug "Deleting temporary windows directory."
rm -Rf "${GLOBAL_WINDOWS_TEMPORARY_DIRECTORY}" 1>/dev/null || :
fi
rm -f "${GLOBAL_TEMPORARY_FILE_PREFIX}"* 1>/dev/null || :
rm -f "${GLOBAL_TEMPORARY_FILE_PREFIX}"* &>/dev/null || :
unset TEMPORARY_FILE_NUMBER TEMPORARY_DIRECTORY_NUMBER
}

Expand Down
3 changes: 3 additions & 0 deletions libraries.d/lib-bash
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ function bash::runInParallel() {
fi

for pid in "${_BASH_RUNNING_JOB_PIDS[@]}"; do
if [[ -z ${pid} ]]; then
continue
fi
jobIndex="${jobIndexFromPid[${pid}]}"
jobName="${jobNames[jobIndex]}"

Expand Down
2 changes: 1 addition & 1 deletion libraries.d/lib-tui
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ function tui::restoreBindings() {

# restore the default bindings
bind -f "${_INTERACTIVE_SAVED_BINDINGS_FILE}" &>/dev/null
rm -f "${_INTERACTIVE_SAVED_BINDINGS_FILE}"
rm -f "${_INTERACTIVE_SAVED_BINDINGS_FILE}" &>/dev/null || :
unset -v _INTERACTIVE_SAVED_BINDINGS_FILE
}

Expand Down
2 changes: 1 addition & 1 deletion tests.d/self-config/01.self-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function main() {
# shellcheck disable=SC2034
VALET_CONFIG_FILE="${GLOBAL_TEST_TEMP_FILE}"

rm -f "${GLOBAL_TEST_TEMP_FILE}"
rm -f "${GLOBAL_TEST_TEMP_FILE}" &>/dev/null || :

test::exec selfConfig
test::exec fs::head "${GLOBAL_TEST_TEMP_FILE}" 3
Expand Down
50 changes: 25 additions & 25 deletions tests.d/self-install/docker-valet-test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM bitnami/minideb:bookworm

SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c", "-x"]

ARG STANDARD_PACKAGES="locales ca-certificates curl sudo makepasswd uidmap git xonsh fish zsh csh tcsh ksh build-essential wget"
ARG STANDARD_PACKAGES="locales ca-certificates curl sudo makepasswd uidmap git xonsh fish zsh csh tcsh ksh wget"

# ✅ install packages
# ✅ set up locale
Expand All @@ -11,22 +11,19 @@ ENV LANG=${LOCALE}.UTF-8
ENV LC_ALL=${LOCALE}.UTF-8
ENV LANGUAGE=${LOCALE}.UTF-8
RUN \
install_packages ${STANDARD_PACKAGES} ; \
localedef -i ${LOCALE} -c -f UTF-8 -A /usr/share/locale/locale.alias ${LOCALE}.UTF-8; \
echo "${LOCALE}.UTF-8 UTF-8" >> /etc/locale.gen; \
echo "LANG=${LOCALE}.UTF-8" >> /etc/locale.conf; \
locale-gen ${LOCALE}.UTF-8; \
echo 'me' > /tmp/pw; \
useradd -m -u 1000 -U -p "$(makepasswd --crypt-md5 --clearfrom=/tmp/pw)" me; \
echo "me ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers.d/me-sudo; \
chsh -s /bin/bash me; \
curl -fsSL https://github.com/nushell/nushell/releases/download/0.100.0/nu-0.100.0-x86_64-unknown-linux-gnu.tar.gz -o nu.tar.gz; \
tar -xvf nu.tar.gz; \
mv nu-0.100.0-x86_64-unknown-linux-gnu/nu /usr/local/bin/nu;

# ✅ instal delta
RUN \
install_packages ${STANDARD_PACKAGES} ; \
localedef -i ${LOCALE} -c -f UTF-8 -A /usr/share/locale/locale.alias ${LOCALE}.UTF-8; \
echo "${LOCALE}.UTF-8 UTF-8" >> /etc/locale.gen; \
echo "LANG=${LOCALE}.UTF-8" >> /etc/locale.conf; \
locale-gen ${LOCALE}.UTF-8; \
echo 'me' > /tmp/pw; \
useradd -m -u 1000 -U -p "$(makepasswd --crypt-md5 --clearfrom=/tmp/pw)" me; \
echo "me ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers.d/me-sudo; \
chsh -s /bin/bash me; \
pushd /tmp; \
curl -fsSL https://github.com/nushell/nushell/releases/download/0.100.0/nu-0.100.0-x86_64-unknown-linux-gnu.tar.gz -o nu.tar.gz; \
tar -xvf nu.tar.gz; \
mv nu-0.100.0-x86_64-unknown-linux-gnu/nu /usr/local/bin/nu; \
curl -fsSL https://github.com/dandavison/delta/releases/download/0.18.2/delta-0.18.2-x86_64-unknown-linux-gnu.tar.gz -O; \
tar -xvf delta-0.18.2-x86_64-unknown-linux-gnu.tar.gz; \
mv delta-0.18.2-x86_64-unknown-linux-gnu/delta /usr/local/bin/delta; \
Expand All @@ -37,12 +34,15 @@ RUN \
SHELL ["/bin/sh", "-o", "errexit", "-o", "nounset", "-x", "-c"]

RUN \
cd /tmp; \
wget http://ftp.gnu.org/gnu/bash/bash-5.0.tar.gz; \
tar xf bash-5.0.tar.gz; \
cd bash-5.0; \
./configure; \
make; \
sudo make install; \
rm /bin/bash; \
sudo ln -s /usr/local/bin/bash /bin/bash;
install_packages build-essential ; \
cd /tmp; \
wget http://ftp.gnu.org/gnu/bash/bash-5.0.tar.gz; \
tar xf bash-5.0.tar.gz; \
cd bash-5.0; \
./configure; \
make; \
sudo make install; \
rm /bin/bash; \
rm -Rf /tmp/bash-5.0; \
apt purge -y build-essential; \
sudo ln -s /usr/local/bin/bash /bin/bash;

0 comments on commit f6ca97a

Please sign in to comment.