ci(git): Copy generic CI/CD files #78
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: Magento 2 Unit Tests | |
| on: ['push', 'pull_request'] | |
| jobs: | |
| unit-tests: | |
| name: Magento 2 Unit Tests | |
| runs-on: ubuntu-latest | |
| container: | |
| image: yireo/magento2installed:2.4.8-p3 | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@v4 | |
| - name: Detecting unit tests | |
| run: | | |
| test -d $GITHUB_WORKSPACE/Test/Unit || echo "SKIP_JOB=true" >> $GITHUB_ENV | |
| - name: Setting up module variables | |
| if: env.SKIP_JOB != 'true' | |
| run: | | |
| echo COMPOSER_NAME=`jq '.name' $GITHUB_WORKSPACE/composer.json -r` >> $GITHUB_ENV | |
| echo MAGENTO_MODULE=`jq '.module_name' $GITHUB_WORKSPACE/MODULE.json -r` >> $GITHUB_ENV | |
| - name: Configure GitLab | |
| if: env.SKIP_JOB != 'true' | |
| run: | | |
| test -n "${{ secrets.GITLAB_TOKEN }}" || exit 0 | |
| cd /tmp/magento | |
| test -f $GITHUB_WORKSPACE/.github/workflows/composer-additional.sh && source $GITHUB_WORKSPACE/.github/workflows/composer-additional.sh | |
| test -f $GITHUB_WORKSPACE/.github/workflows/composer-${MAGENTO_VERSION}.sh && source $GITHUB_WORKSPACE/.github/workflows/composer-${MAGENTO_VERSION}.sh | |
| composer config --auth gitlab-token.gitlab.yireo.com ${{ secrets.GITLAB_TOKEN }} | |
| composer config repositories.loki-checkout composer https://gitlab.yireo.com/api/v4/group/loki-checkout/-/packages/composer/packages.json | |
| - name: Add module source | |
| if: env.SKIP_JOB != 'true' | |
| run: | | |
| cp -R $GITHUB_WORKSPACE /tmp/magento/package-source | |
| cd /tmp/magento | |
| composer config repositories.local-source path package-source/ | |
| composer require --prefer-source -W -- $COMPOSER_NAME:@dev | |
| - name: Run Magento 2 Unit Tests | |
| if: env.SKIP_JOB != 'true' | |
| run: | | |
| cd /tmp/magento/dev/tests/unit/ | |
| php -d memory_limit=4G ../../../vendor/bin/phpunit -c phpunit.xml.dist ../../../vendor/$COMPOSER_NAME/Test/Unit | |