|
| 1 | +name: Magento 2.4 Community Edition Docker container build |
| 2 | +on: |
| 3 | + push: |
| 4 | + pull_request: |
| 5 | + schedule: |
| 6 | + - cron: '0 0 * * 1' |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + strategy: |
| 12 | + fail-fast: false |
| 13 | + matrix: |
| 14 | + cfg: |
| 15 | + - { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.3.1, SAMPLE_DATA: true } |
| 16 | + - { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.3.1, SAMPLE_DATA: false } |
| 17 | + - { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.3.0, SAMPLE_DATA: true } |
| 18 | + - { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.3.0, SAMPLE_DATA: false } |
| 19 | + |
| 20 | +# - { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.2.0, SAMPLE_DATA: false } |
| 21 | +# - { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.1.1, SAMPLE_DATA: false } |
| 22 | +# - { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.1.0, SAMPLE_DATA: false } |
| 23 | +# - { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.0.6, SAMPLE_DATA: false } |
| 24 | +# - { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.0.5, SAMPLE_DATA: false } |
| 25 | +# - { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.0.4, SAMPLE_DATA: false } |
| 26 | +# - { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.0.3, SAMPLE_DATA: false } |
| 27 | +# - { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.0.2, SAMPLE_DATA: false } |
| 28 | +# - { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.0.1, SAMPLE_DATA: false } |
| 29 | +# - { PHP_VERSION: php83-fpm, MAGEOS_VERSION: 1.0.0, SAMPLE_DATA: false } |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v5 |
| 32 | + |
| 33 | + # Step 1: Build the docker image |
| 34 | + - name: Build the Docker image (without sample data) |
| 35 | + if: matrix.cfg.SAMPLE_DATA == false |
| 36 | + run: |
| 37 | + docker build mage-os -f mage-os/Dockerfile |
| 38 | + -t michielgerritsen/mage-os-community-edition:${{ matrix.cfg.PHP_VERSION }}-mage-os{{ matrix.cfg.MAGEOS_VERSION }} |
| 39 | + --build-arg MAGEOS_VERSION=${{ matrix.cfg.MAGEOS_VERSION }} |
| 40 | + --build-arg PHP_VERSION=${{ matrix.cfg.PHP_VERSION }} |
| 41 | + |
| 42 | + - name: Build the Docker image (with sample data) |
| 43 | + if: matrix.cfg.SAMPLE_DATA == true |
| 44 | + run: |
| 45 | + docker build mage-os -f mage-os/Dockerfile |
| 46 | + -t michielgerritsen/mage-os-community-edition:${{ matrix.cfg.PHP_VERSION }}-mage-os{{ matrix.cfg.MAGEOS_VERSION }}-sample-data |
| 47 | + --build-arg MAGEOS_VERSION=${{ matrix.cfg.MAGEOS_VERSION }} |
| 48 | + --build-arg PHP_VERSION=${{ matrix.cfg.PHP_VERSION }} |
| 49 | + --build-arg SAMPLE_DATA=true |
| 50 | + |
| 51 | + # Step 2: Test the docker image |
| 52 | + - name: Start the docker image (without sample date) |
| 53 | + if: matrix.cfg.SAMPLE_DATA == false |
| 54 | + run: |
| 55 | + docker run --memory=4G --detach --name mage-os-community-edition |
| 56 | + michielgerritsen/mage-os-community-edition:${{ matrix.cfg.PHP_VERSION }}-mage-os{{ matrix.cfg.MAGEOS_VERSION }} |
| 57 | + |
| 58 | + - name: Start the docker image (with sample date) |
| 59 | + if: matrix.cfg.SAMPLE_DATA == true |
| 60 | + run: |
| 61 | + docker run --detach --name mage-os-community-edition |
| 62 | + michielgerritsen/mage-os-community-edition:${{ matrix.cfg.PHP_VERSION }}-mage-os{{ matrix.cfg.MAGEOS_VERSION }}-sample-data |
| 63 | + |
| 64 | + - name: Copy the example test module |
| 65 | + run: | |
| 66 | + docker exec mage-os-community-edition mkdir -vp /data/extensions/MichielGerritsen-ExampleTest/Test/Integration/ |
| 67 | + docker exec mage-os-community-edition mkdir -vp /data/extensions/MichielGerritsen-ExampleTest/Test/Unit/ |
| 68 | + echo "Copying Test/composer.json" |
| 69 | + docker cp Test/composer.json mage-os-community-edition:/data/extensions/MichielGerritsen-ExampleTest/ |
| 70 | + echo "Copying Test/ExampleIntegrationTest.php" |
| 71 | + docker cp Test/ExampleIntegrationTest.php mage-os-community-edition:/data/extensions/MichielGerritsen-ExampleTest/Test/Integration/ |
| 72 | + echo "Copying Test/ExampleUnitTest.php" |
| 73 | + docker cp Test/ExampleUnitTest.php mage-os-community-edition:/data/extensions/MichielGerritsen-ExampleTest/Test/Unit/ |
| 74 | +
|
| 75 | + - name: Install the example test module |
| 76 | + run: docker exec mage-os-community-edition composer require michielgerritsen/exampletest:@dev |
| 77 | + |
| 78 | + - name: Enable developer mode |
| 79 | + run: docker exec mage-os-community-edition ./retry "bin/magento deploy:mode:set developer" |
| 80 | + |
| 81 | + - name: Run setup:di:compile |
| 82 | + run: docker exec mage-os-community-edition ./retry "php bin/magento setup:di:compile" |
| 83 | + |
| 84 | + - name: Run the example integration test |
| 85 | + 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" |
| 86 | + |
| 87 | + - name: Run the example unit test |
| 88 | + 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" |
| 89 | + |
| 90 | + # Step 3: Upload the images to Docker Hub. |
| 91 | + - name: Docker hub login |
| 92 | + if: github.ref == 'refs/heads/master' |
| 93 | + run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin |
| 94 | + |
| 95 | + - name: Push the image to Docker hub (without sample data) |
| 96 | + if: github.ref == 'refs/heads/master' && matrix.cfg.SAMPLE_DATA == false |
| 97 | + run: docker push michielgerritsen/mage-os-community-edition:${{ matrix.cfg.PHP_VERSION }}-mage-os{{ matrix.cfg.MAGEOS_VERSION }} |
| 98 | + |
| 99 | + - name: Push the image to Docker hub (with sample data) |
| 100 | + if: github.ref == 'refs/heads/master' && matrix.cfg.SAMPLE_DATA == true |
| 101 | + run: docker push michielgerritsen/mage-os-community-edition:${{ matrix.cfg.PHP_VERSION }}-mage-os{{ matrix.cfg.MAGEOS_VERSION }}-sample-data |
| 102 | + |
| 103 | + - name: Dump Docker logs files (on failure) |
| 104 | + if: failure() |
| 105 | + run: | |
| 106 | + mkdir failure-logs |
| 107 | + docker logs mage-os-community-edition > failure-logs/docker.log |
| 108 | + docker cp mage-os-community-edition:/data/var/log failure-logs/var/log |
| 109 | +
|
| 110 | + - name: Upload failure artifacts |
| 111 | + if: failure() |
| 112 | + uses: actions/upload-artifact@v4 |
| 113 | + with: |
| 114 | + name: failure-artifacts-${{ matrix.cfg.PHP_VERSION }}-mage-os{{ matrix.cfg.MAGEOS_VERSION }} |
| 115 | + path: | |
| 116 | + failure-logs |
0 commit comments