Skip to content

WIP

WIP #12

Workflow file for this run

name: Mage-OS Build
on:
push:
pull_request:
schedule:
- cron: '0 0 * * 1'
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
cfg:
- { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.3.1, SAMPLE_DATA: true }
- { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.3.1, SAMPLE_DATA: false }
- { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.3.0, SAMPLE_DATA: true }
- { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.3.0, SAMPLE_DATA: false }
# - { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.2.0, SAMPLE_DATA: false }
# - { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.1.1, SAMPLE_DATA: false }
# - { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.1.0, SAMPLE_DATA: false }
# - { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.0.6, SAMPLE_DATA: false }
# - { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.0.5, SAMPLE_DATA: false }
# - { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.0.4, SAMPLE_DATA: false }
# - { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.0.3, SAMPLE_DATA: false }
# - { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.0.2, SAMPLE_DATA: false }
# - { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.0.1, SAMPLE_DATA: false }
# - { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.0.0, SAMPLE_DATA: false }
steps:
- uses: actions/checkout@v5
# Step 1: Build the docker image
- name: Build the Docker image (without sample data)
if: matrix.cfg.SAMPLE_DATA == false
run:
docker build mage-os -f mage-os/Dockerfile
-t michielgerritsen/mage-os-community-edition:${{ matrix.cfg.PHP_VERSION }}-mage-os${{ matrix.cfg.MAGEOS_VERSION }}
--build-arg MAGEOS_VERSION=${{ matrix.cfg.MAGEOS_VERSION }}
--build-arg PHP_VERSION=${{ matrix.cfg.PHP_VERSION }}
- name: Build the Docker image (with sample data)
if: matrix.cfg.SAMPLE_DATA == true
run:
docker build mage-os -f mage-os/Dockerfile
-t michielgerritsen/mage-os-community-edition:${{ matrix.cfg.PHP_VERSION }}-mage-os${{ matrix.cfg.MAGEOS_VERSION }}-sample-data
--build-arg MAGEOS_VERSION=${{ matrix.cfg.MAGEOS_VERSION }}
--build-arg PHP_VERSION=${{ matrix.cfg.PHP_VERSION }}
--build-arg SAMPLE_DATA=true
# Step 2: Test the docker image
- name: Start the docker image (without sample date)
if: matrix.cfg.SAMPLE_DATA == false
run:
docker run --memory=4G --detach --name mage-os-community-edition
michielgerritsen/mage-os-community-edition:${{ matrix.cfg.PHP_VERSION }}-mage-os{{ matrix.cfg.MAGEOS_VERSION }}
- name: Start the docker image (with sample date)
if: matrix.cfg.SAMPLE_DATA == true
run:
docker run --detach --name mage-os-community-edition
michielgerritsen/mage-os-community-edition:${{ matrix.cfg.PHP_VERSION }}-mage-os{{ matrix.cfg.MAGEOS_VERSION }}-sample-data
- name: Copy the example test module
run: |
docker exec mage-os-community-edition mkdir -vp /data/extensions/MichielGerritsen-ExampleTest/Test/Integration/
docker exec mage-os-community-edition mkdir -vp /data/extensions/MichielGerritsen-ExampleTest/Test/Unit/
echo "Copying Test/composer.json"
docker cp Test/composer.json mage-os-community-edition:/data/extensions/MichielGerritsen-ExampleTest/
echo "Copying Test/ExampleIntegrationTest.php"
docker cp Test/ExampleIntegrationTest.php mage-os-community-edition:/data/extensions/MichielGerritsen-ExampleTest/Test/Integration/
echo "Copying Test/ExampleUnitTest.php"
docker cp Test/ExampleUnitTest.php mage-os-community-edition:/data/extensions/MichielGerritsen-ExampleTest/Test/Unit/
- name: Install the example test module
run: docker exec mage-os-community-edition composer require michielgerritsen/exampletest:@dev
- name: Enable developer mode
run: docker exec mage-os-community-edition ./retry "bin/magento deploy:mode:set developer"
- name: Run setup:di:compile
run: docker exec mage-os-community-edition ./retry "php bin/magento setup:di:compile"
- name: Run the example integration test
run: docker exec mage-os-community-edition bash -c "cd /data/dev/tests/integration/ && ../../../vendor/bin/phpunit /data/vendor/michielgerritsen/exampletest/Test/Integration/ExampleIntegrationTest.php"
- name: Run the example unit test
run: docker exec mage-os-community-edition bash -c "cd /data/dev/tests/unit/ && ../../../vendor/bin/phpunit /data/vendor/michielgerritsen/exampletest/Test/Unit/ExampleUnitTest.php"
# Step 3: Upload the images to Docker Hub.
- name: Docker hub login
if: github.ref == 'refs/heads/master'
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
- name: Push the image to Docker hub (without sample data)
if: github.ref == 'refs/heads/master' && matrix.cfg.SAMPLE_DATA == false
run: docker push michielgerritsen/mage-os-community-edition:${{ matrix.cfg.PHP_VERSION }}-mage-os{{ matrix.cfg.MAGEOS_VERSION }}
- name: Push the image to Docker hub (with sample data)
if: github.ref == 'refs/heads/master' && matrix.cfg.SAMPLE_DATA == true
run: docker push michielgerritsen/mage-os-community-edition:${{ matrix.cfg.PHP_VERSION }}-mage-os{{ matrix.cfg.MAGEOS_VERSION }}-sample-data
- name: Dump Docker logs files (on failure)
if: failure()
run: |
mkdir failure-logs
docker logs mage-os-community-edition > failure-logs/docker.log
docker cp mage-os-community-edition:/data/var/log failure-logs/var/log
- name: Upload failure artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: failure-artifacts-${{ matrix.cfg.PHP_VERSION }}-mage-os{{ matrix.cfg.MAGEOS_VERSION }}
path: |
failure-logs