Skip to content

Commit

Permalink
[TASK] Add DDEV HEAD (aka nightly, latest) to build matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
ochorocho committed Dec 16, 2024
1 parent 4d7649c commit 3153469
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: [ v1.24, v1.23, v1.22 ]
version: [ latest, v1.24, v1.23, v1.22 ]
steps:
-
name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: [ v1.24, v1.23, v1.22 ]
version: [ latest, v1.24, v1.23, v1.22 ]
steps:
-
name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ ARG ddev_version
ENV DDEV_VERSION=${ddev_version}

COPY ddev-install.sh ddev-install.sh
RUN ash ddev-install.sh && rm ddev-install.sh
RUN ash ddev-install.sh
USER ddev
RUN mkcert -install
13 changes: 11 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,22 @@ while getopts ":v:hplx" opt; do
PLATFORM="--platform linux/amd64,linux/arm64"
;;
*)
echo "Invalid option: -$OPTARG"
help
echo "Invalid option: -$OPTARG"
exit 1
;;
esac
done

loadVersionAndTags
# Set version and tag for latest (aka nightly)
if [ "$OPTION_VERSION" = "latest" ]; then
DDEV_VERSION="latest"
DOCKER_TAGS=("-t $IMAGE_NAME:latest")
else
loadVersionAndTags
fi

echo $DDEV_VERSION
echo $DOCKER_TAGS

docker buildx build ${PLATFORM} --progress plain --no-cache --pull . -f Dockerfile ${DOCKER_TAGS[@]} --build-arg ddev_version="$DDEV_VERSION" $PUSH $LOAD
20 changes: 15 additions & 5 deletions ddev-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,26 @@ case ${unamearch} in
;;
esac

wget "https://github.com/ddev/ddev/releases/download/${DDEV_VERSION}/ddev_linux-${ARCH}.${DDEV_VERSION}.tar.gz"

# Prepare and install binaries
mkdir ddev
tar xfvz "ddev_linux-${ARCH}.${DDEV_VERSION}.tar.gz" --directory ddev

if [ "$DDEV_VERSION" = "latest" ]; then
# Download ddev head (nightly)
wget "https://nightly.link/ddev/ddev/workflows/master-build/master/all-ddev-executables.zip"

unzip all-ddev-executables.zip
tar xfvz ddev_linux-${ARCH}.* --directory ddev
else
# Download specific ddev version
wget "https://github.com/ddev/ddev/releases/download/${DDEV_VERSION}/ddev_linux-${ARCH}.${DDEV_VERSION}.tar.gz"

tar xfvz "ddev_linux-${ARCH}.${DDEV_VERSION}.tar.gz" --directory ddev
fi

mv ddev/ddev /usr/local/bin/
mv ddev/mkcert /usr/local/bin/
sudo -i ddev /usr/local/bin/mkcert -install
rm -Rf ddev "ddev_linux-${ARCH}.${DDEV_VERSION}.tar.gz"
rm -Rf ddev*

# Ensure required folders exist
mkdir -p /home/ddev/.ddev/commands/host
Expand All @@ -37,7 +48,6 @@ disable_http2: false
fail_on_hook_fail: false
instrumentation_opt_in: false
internet_detection_timeout_ms: 3000
last_started_version: ${DDEV_VERSION}
letsencrypt_email: ""
mkcert_caroot: /home/ddev/.local/share/mkcert
no_bind_mounts: false
Expand Down
43 changes: 24 additions & 19 deletions tests/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@

@test "See ddev version" {
run docker-run "ddev version -j"

version=$(echo "$output" | tail -n 1 | yq '.raw.["DDEV version"]')
regex='^v([0-9]+)\.([0-9]+)\.([0-9]+)$'

if [ "$DDEV_VERSION" = "latest" ]; then
# The HEAD version contains a hash e.g. v1.24.1-4-gbce95e65e
regex='^v([0-9]+)\.([0-9]+)\.([0-9]+)-([0-9]+)-([a-z0-9]+)$'
else
regex='^v([0-9]+)\.([0-9]+)\.([0-9]+)$'
fi

[[ $version =~ $regex ]]
[ "$status" -eq 0 ]
Expand All @@ -27,23 +32,6 @@
[ "$status" -eq 0 ]
}

@test "Create and run a ddev project" {
local TEST_COMMAND="
mkdir ~/ddev-test
cd ~/ddev-test
echo '<?php echo \"Hello World\";' > index.php
ddev config --project-type php --auto
ddev config global --no-bind-mounts=true
ddev start
curl https://ddev-test.ddev.site/index.php
ddev poweroff
"
run docker-run "${TEST_COMMAND}"

[[ "$output" == *"Configuration complete. You may now run 'ddev start'"* ]]
[[ "$output" == *"Hello World"* ]]
[ "$status" -eq 0 ]
}

@test "Run ddev debug dockercheck" {
run docker-run "ddev debug dockercheck"
Expand All @@ -52,6 +40,23 @@
[[ "$output" == *"Able to use internet inside container."* ]]
[ "$status" -eq 0 ]
}
#@test "Create and run a ddev project" {
# local TEST_COMMAND="
# mkdir ~/ddev-test
# cd ~/ddev-test
# echo '<?php echo \"Hello World\";' > index.php
# ddev config --project-type php --auto
# ddev config global --no-bind-mounts=true
# ddev start
# curl https://ddev-test.ddev.site/index.php
# ddev poweroff
# "
# run docker-run "${TEST_COMMAND}"
#
# [[ "$output" == *"Configuration complete. You may now run 'ddev start'"* ]]
# [[ "$output" == *"Hello World"* ]]
# [ "$status" -eq 0 ]
#}

# Use "--no-bind-mounts=true" to make "ddev debug test" pass. This is only required in testing environment
@test "Run ddev debug test" {
Expand Down

0 comments on commit 3153469

Please sign in to comment.