Skip to content

Update docker composer and CI files #22

Update docker composer and CI files

Update docker composer and CI files #22

Workflow file for this run

name: CI
on:
push:
branches:
- automated-testing
pull_request:
jobs:
integration-tests:
runs-on: ubuntu-latest
services:
docker:
image: docker:19.03.12
options: --privileged
# Docker-in-Docker is available on GitHub Actions by default on ubuntu-latest runners.
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install docker-compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
- name: Set up Docker Compose
run: |
docker-compose -f .github/docker/docker-compose.yml up -d
#Debug, remove when working
- name: List Docker Containers
run: docker ps
- name: Print WordPress container logs
run: |
CONTAINER_ID=$(docker-compose -f .github/docker/docker-compose.yml ps -q wordpress)
docker logs "$CONTAINER_ID"
# Wait for WordPress to be fully up before running commands
- name: Wait for WordPress to be available
run: |
# Give the container extra time to initialize
echo "Initial wait for container initialization…"
sleep 5
echo "Executing verbose curl"
RESPONSE=$(curl -v --max-time 30 http://localhost:8000 || true)
echo "Response from curl:"
echo "$RESPONSE"
- name: Install WordPress via WP-CLI
run: |

Check failure on line 52 in .github/workflows/ci.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/ci.yml

Invalid workflow file

You have an error in your yaml syntax on line 52
CONTAINER_ID=$(docker-compose -f .github/docker/docker-compose.yml ps -q wordpress)
# Ensure WP-CLI is available inside the container.
#docker exec $CONTAINER_ID bash -c "if ! command -v wp &> /dev/null; then \
# curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \
# chmod +x wp-cli.phar && mv wp-cli.phar /usr/local/bin/wp; \
#fi"
# Run WordPress install
docker-compose -f .github/docker/docker-compose.yml exec -T wordpress \
wp core install \
--url="http://localhost:8000" \
--title="GitHub Actions Test Site" \
--admin_user="admin" \
--admin_password="admin_password" \
--admin_email="admin@example.com" \
--skip-email \
--allow-root
# Copy plugin into container
- name: Copy Plugin into Container
run: |
CONTAINER_ID=$(docker-compose -f .github/docker/docker-compose.yml ps -q wordpress)
echo "Creating build folder..."
docker exec $CONTAINER_ID mkdir -p /var/www/html/wp-content/plugins/shortpixel-image-optimiser/build/
echo "Copying plugin files..."
docker cp build/shortpixel/ "$CONTAINER_ID":/var/www/html/wp-content/plugins/shortpixel-image-optimiser/build/
docker cp res "$CONTAINER_ID":/var/www/html/wp-content/plugins/shortpixel-image-optimiser/
docker cp class "$CONTAINER_ID":/var/www/html/wp-content/plugins/shortpixel-image-optimiser/
docker cp wp-shortpixel.php "$CONTAINER_ID":/var/www/html/wp-content/plugins/shortpixel-image-optimiser/
docker cp shortpixel-plugin.php "$CONTAINER_ID":/var/www/html/wp-content/plugins/shortpixel-image-optimiser/
docker cp readme.txt "$CONTAINER_ID":/var/www/html/wp-content/plugins/shortpixel-image-optimiser/
echo "Listing main plugin files:"
docker exec $CONTAINER_ID ls -alh /var/www/html/wp-content/plugins/shortpixel-image-optimiser/
# Activate the plugin using WP-CLI
- name: Activate Plugin via WP-CLI
run: |
CONTAINER_ID=$(docker-compose -f .github/docker/docker-compose.yml ps -q wordpress)
# Activate the plugin via WP-CLI (already installed above)
docker exec $CONTAINER_ID wp plugin activate shortpixel-image-optimiser --allow-root
#Configure GH token to access the plugin-modules repo, which is private
- name: Configure GitHub OAuth for Composer
run: composer --version
#composer config --global github-oauth.github.com ${{ secrets.SP_PLUGIN_MODULES_TOKEN }}
# Run your tests (customize this step to your testing framework)
- name: Run Plugin Tests
run: |
# Example: running PHPUnit test suite located in /tests directory.
# Customize the following command based on your actual testing framework.
composer update --no-interaction --prefer-dist
#vendor/bin/phpunit --configuration phpunit.xml.dist
# Tear down Docker Compose
- name: Shut down Docker Compose
if: always()
run: docker-compose -f .github/docker/docker-compose.yml down