Add quotas to the CONTAINER_ID in copy commands #16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 10 | |
| 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: | | |
| 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) | |
| docker cp build "$CONTAINER_ID":/var/www/html/wp-content/plugins/shortpixel-image-optimiser/ | |
| 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/ | |
| docker exec $CONTAINER_ID ls -alh /var/www/html/wp-content/plugins/ | |
| docker exec $CONTAINER_ID ls -alh /var/www/html/wp-content/plugins/shortpixel-image-optimiser/ | |
| docker exec $CONTAINER_ID ls -alh /var/www/html/wp-content/plugins/shortpixel-image-optimiser/build/shortpixel/ | |
| # 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 | |
| # 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 install --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 |