Closed aneel11 closed 10 months ago
Hi there,
Two potential causes:
Lets check the these two scenarios ? First ?
Best
Hi
I have tested by adding only phpunit.xml in main.yml and with overriding_setting true and false as well but it is giving only one error "Could not read "phpunit.xml"." each time.
Additional, if I add no_push=0 in install magento then it takes phpunit.xml but it pushes code to my repo which I don't want to push it.
Also it seems, it is not taking my scripts/unit-test.sh. I have only this file and folder nothing else. Do I need to add any other file?
So have you tried the ?
unit_test_config: 'phpunit.xml'
The override_settings should be set to 1 not true, in order to work.
Try these? and report back.
Also, if you're running on a selfhosted runner env, you may be encounter issue related to caching. But it looks like you're using the github actions public runners.
Humm also your use case is not clear. What do you have exactly in your github repo? Where you're phpunit.xml comes from?
You don't need the install step, if you already have a magento project files in your repo...
For example if i have :
├── .github
│ └── workflows # directory where the workflows are found, see below for an example of main.yml
├── README.md
├── scripts/unit-test.sh
└── phpunit.xml
In the main.yml, you can call the magento-install (create-project) step and the path will be unit_test_config: '../phpunit.xml'
.
But if you have
├── .github
│ └── workflows # directory where the workflows are found, see below for an example of main.yml
├── magento # with you magento src
└── magento/phpunit.xml
You don't need the magento-install (create-project) step because you already have the project setup. And the path to unit testing will be unit_test_config: 'phpunit.xml' as it is in the magento dir.
In the later case, your steps should look like this:
steps:
#- uses: actions/checkout@v3
- name: 'launch magento2 unit test'
if: always()
uses: MAD-I-T/magento-actions@v3.24
env:
COMPOSER_AUTH: ${{secrets.COMPOSER_AUTH}}
with:
process: 'unit-test'
override_settings: 1
unit_test_config: 'phpunit.xml'
Hi
I have created the same structure as you defined above:
├── .github │ └── workflows # directory where the workflows are found, see below for an example of main.yml ├── magento # with you magento src └── magento/phpunit.xml
And same main.xml code: ` steps:
- name: 'launch magento2 unit test'
if: always()
uses: MAD-I-T/magento-actions@v3.24
env:
COMPOSER_AUTH: ${{secrets.COMPOSER_AUTH}}
with:
process: 'unit-test'
override_settings: 1
unit_test_config: 'phpunit.xml'
`
But this time its giving following error:
And it is also not taking my custom script file unit-test.sh.
This is my repo : https://github.com/../...
And this is the last failed pipeline: https://github.com/../.../actions/runs/6009275299/job/16298381812
Basically, I want to execute unit tests only on app/code folder that's why I want to set custom path when uni test job execute but it is not taking my phpunit.xml file from magento folder, you can check. I tried almost all ways whatever you defined in your documentation.
I didn't notice yesterday in your main.yml. But of course if you comment the checkout (i.e #- uses: actions/checkout@v3
), your files will not be downloaded from github... Please uncomment, that was the issue all along.
Side note: if you're using magento 2.4.5 its best to use opensearch in place of elasticsearch.
Thank you very much above works and saved my time. I am closing this issue.
Hi
I have set custom unit test config path ( unit_test_config: 'magento/phpunit.xml ). I have added this phpunit.xml file in magento folder where magento root files exist. But it is not taking that phpunit.xml file. Can you suggest how we can do that, following is my main.xml file:
name: m2-actions-test
on: [push]
jobs: magento2-build: runs-on: ubuntu-latest name: 'm2 tests & build' services: mysql: image: docker://mysql:8.0 env: MYSQL_ROOT_PASSWORD: magento MYSQL_DATABASE: magento ports:
9200:9200 options: -e="discovery.type=single-node" --health-cmd="curl http://localhost:9200/_cluster/health" --health-interval=10s --health-timeout=5s --health-retries=10
steps:
- uses: actions/checkout@v3
name: 'install fresh magento repo' if: always()
if: ${{false}}
uses: MAD-I-T/magento-actions@v3.24 env: COMPOSER_AUTH: ${{secrets.COMPOSER_AUTH}} with: process: 'create-project' magento_version: 2.4.5 no_push: 1
name: 'launch magento2 unit test' if: always() uses: MAD-I-T/magento-actions@v3.24 env: COMPOSER_AUTH: ${{secrets.COMPOSER_AUTH}} with: process: 'unit-test' override_settings: true unit_test_config: 'magento/phpunit.xml'