Test starting the containers in GitHub Actions

This commit is contained in:
Matthew Lopez
2024-01-13 17:04:08 -05:00
parent dcb5976a8a
commit df649c27da
2 changed files with 39 additions and 34 deletions

View File

@@ -18,17 +18,24 @@ jobs:
submodules: true
- name: Set TERM environment variable
run: echo "TERM=xterm" >> $GITHUB_ENV
run: echo "TERM=xterm" >> "$GITHUB_ENV"
# Trying to expose ports in GitHub Actions causes a "bind: address already
# in use" error. Also, restarting containers should be disabled for
# testing whether any exit.
- name: Remove exposed ports configuration and disable container restart
run: |
yq eval 'del(.services.*.ports)' -i compose.yml
yq eval '.services.*.restart = "no"' -i compose.yml
- name: Run the setup script
run: ./setup.sh
- name: Build Docker images
uses: docker/bake-action@v4
with:
pull: true
load: true
push: false
set: |
*.cache-from=type=gha
*.cache-to=type=gha,mode=max
- name: Test starting the servers
run: |
docker compose up -d
sleep 35
docker compose ps -a
docker compose logs
# Fail if any containers exited
! docker compose ps -a | grep Exited

View File

@@ -46,10 +46,14 @@ check_prerequisites() {
exit 1
elif [ "$prerequisites_warning" = true ]; then
warning "Prerequisites check completed with warnings."
printf "Do you want to continue anyway (y/N)? "
read -r continue_anyway
if [ "$continue_anyway" != "Y" ] && [ "$continue_anyway" != "y" ]; then
exit 1
if [ -z "${CI+x}" ]; then
# Optional prerequisites can be ignored in CI
printf "Do you want to continue anyway (y/N)? "
read -r continue_anyway
if [ "$continue_anyway" != "Y" ] && [ "$continue_anyway" != "y" ]; then
exit 1
fi
fi
else
success "All prerequisites are installed."
@@ -57,22 +61,21 @@ check_prerequisites() {
}
ci_setup() {
warning "It looks like the script is running in CI. Only setup tasks required for building the Docker images will be performed."
stage "Setting up submodules and applying patches."
./scripts/setup-submodule-patches.sh
stage "Setting up environment variables."
./scripts/setup-environment.sh "1.1.1.1" "2.2.2.2" "3.3.3.3"
success "CI setup completed."
}
setup_environment_variables() {
echo "Enter the IP address of your Pretendo Network server. It must be accessible to your console."
read -r server_ip
echo "Enter the IP address of your Wii U (optional). It is only used for automatic FTP uploads of modified Inkay patches."
read -r wiiu_ip
echo "Enter the IP address of your 3DS (optional). It is only used for automatic FTP uploads."
read -r ds_ip
if [ -n "${CI+x}" ]; then
warning "It looks like the script is running in CI. Using test IP addresses."
server_ip="0.0.0.0"
wiiu_ip=""
ds_ip=""
else
echo "Enter the IP address of your Pretendo Network server. It must be accessible to your console."
read -r server_ip
echo "Enter the IP address of your Wii U (optional). It is only used for automatic FTP uploads of modified Inkay patches."
read -r wiiu_ip
echo "Enter the IP address of your 3DS (optional). It is only used for automatic FTP uploads."
read -r ds_ip
fi
./scripts/setup-environment.sh "$server_ip" "$wiiu_ip" "$ds_ip"
}
@@ -102,11 +105,6 @@ cd "$git_base"
title "Unofficial Pretendo Network setup script"
header "Pretendo setup script started at $(date)."
if [ -n "${CI+x}" ]; then
ci_setup
exit 0
fi
stage "Checking prerequisites."
check_prerequisites