Closed gabiwassan closed 2 years ago
Hello @gabiwassan! 👋
Sorry for the late reply. As far as I can see, in your configuration the working-directory
has correct value, but it is not being passed to the action. I'm not sure, but it seems to me that the issue is with the name of the variable: try to rename it so that no hyphen is used (for example PATH_WAZUH_APP
). If that doesn't work, try running an action with a configuration like this:
- name: Step 08 - Run Tests & Collect Coverage
run: |
echo “PATH_WAZUH-APP=$GITHUB_WORKSPACE/kibana/plugins/wazuh-kibana-app/” >> $GITHUB_ENV
cd ./kibana/plugins/wazuh-kibana-app
ls -la
echo $GITHUB_WORKSPACE/kibana/plugins/wazuh-kibana-app/
yarn run test:jest --silent --ci --testLocationInResults --colors --coverage --json --outputFile=report.json
- name: Step 09 - Comment coverage
uses: artiomtr/jest-coverage-report-action@v2.0-rc.1
with:
# here is the change ↓
working-directory: kibana/plugins/wazuh-kibana-app/
github-token: ${{ secrets.GITHUB_TOKEN }}
skip-step: all
Hope my answer will help you!
I have the same problem. working-directory is given as literal
working-directory: frontend
But getting error
Could not read report file located at frontend/report.json [Error: ENOENT: no such file or directory, open 'frontend/report.json'] { errno: -2, code: 'ENOENT', syscall: 'open', path: 'frontend/report.json' }
Also tried working-directory: ./frontend
and working-directory: frontend/
which should be the same.
Reporters are 'text', 'text-summary', 'json'
.
Hello @ig-onoffice-de,
Could you send me the full action.yml
file as well as a screenshot of the console output of the action? Thank you in advance.
Hello @gabiwassan!
Sorry for the late reply. As far as I can see, in your configuration the
working-directory
has correct value, but it is not being passed to the action. I'm not sure, but it seems to me that the issue is with the name of the variable: try to rename it so that no hyphen is used (for examplePATH_WAZUH_APP
). If that doesn't work, try running an action with a configuration like this:- name: Step 08 - Run Tests & Collect Coverage run: | echo “PATH_WAZUH-APP=$GITHUB_WORKSPACE/kibana/plugins/wazuh-kibana-app/” >> $GITHUB_ENV cd ./kibana/plugins/wazuh-kibana-app ls -la echo $GITHUB_WORKSPACE/kibana/plugins/wazuh-kibana-app/ yarn run test:jest --silent --ci --testLocationInResults --colors --coverage --json --outputFile=report.json - name: Step 09 - Comment coverage uses: artiomtr/jest-coverage-report-action@v2.0-rc.1 with: # here is the change ↓ working-directory: kibana/plugins/wazuh-kibana-app/ github-token: ${{ secrets.GITHUB_TOKEN }} skip-step: all
Hope my answer will help you!
Hi @ArtiomTr, don't apologize, it's okay 😃 I tried with this configuration, but if it keeps generating the same error:
/usr/bin/git fetch --all --depth=1 fatal: not a git repository (or any of the parent directories): .git Error fetching git repository Error: The process '/usr/bin/git' failed with exit code 128 at f._setResult (/home/runner/work/_actions/artiomtr/jest-coverage-report-action/v2.0-rc.1/dist/index.js:2:11470) at f.CheckComplete (/home/runner/work/_actions/artiomtr/jest-coverage-report-action/v2.0-rc.1/dist/index.js:2:10900) at ChildProcess.<anonymous> (/home/runner/work/_actions/artiomtr/jest-coverage-report-action/v2.0-rc.1/dist/index.js:2:9944) at ChildProcess.emit (events.js:210:5) at maybeClose (internal/child_process.js:1021:16) at Socket.<anonymous> (internal/child_process.js:430:11) at Socket.emit (events.js:210:5) at Pipe.<anonymous> (net.js:659:12) /usr/bin/git checkout -f 4.3-7.10 fatal: not a git repository (or any of the parent directories): .git Error: The process '/usr/bin/git' failed with exit code 128
@gabiwassan, could you please send the action arguments as you did in your first comment? Like this:
Error result:
Run artiomtr/jest-coverage-report-action@v2.0-rc.1 with: github-token: *** skip-step: all test-script: npx jest --silent --ci --coverage --testLocationInResults --json --outputFile="report.json" icons: emoji annotations: all package-manager: npm env: “PATH_WAZUH-APP: /home/runner/work/wazuh-kibana-app/wazuh-kibana-app/kibana/plugins/wazuh-kibana-app/” Could not read report file located at report.json [Error: ENOENT: no such file or directory, open 'report.json'] {
Also, could you try please to set up working-directory variable as shown below:
working-directory: /home/runner/work/wazuh-kibana-app/wazuh-kibana-app/kibana/plugins/wazuh-kibana-app/
@ArtiomTr here the action.yml
Y try with this: working-directory: /home/runner/work/wazuh-kibana-app/wazuh-kibana-app/kibana/plugins/wazuh-kibana-app/
but i had the same error.
> Run artiomtr/jest-coverage-report-action@v2.0-rc.1
> with:
> working-directory: /home/runner/work/wazuh-kibana-app/wazuh-kibana-app/kibana/plugins/wazuh-kibana-app/
> github-token: ***
> skip-step: all
> test-script: npx jest --silent --ci --coverage --testLocationInResults --json --outputFile="report.json"
> icons: emoji
> annotations: all
> package-manager: npm
> env:
> NODE_10-23-1: 10.23.1
> NODE_12-22-3: 12.22.3
> YARN_1-21-1: 1.21.1
> KIBANA_TAG: v7.10.2
> “PATH_WAZUH-APP: /home/runner/work/wazuh-kibana-app/wazuh-kibana-app/kibana/plugins/wazuh-kibana-app/”
> /usr/bin/git fetch --all --depth=1
> fatal: not a git repository (or any of the parent directories): .git
> Error fetching git repository Error: The process '/usr/bin/git' failed with exit code 128
> at f._setResult (/home/runner/work/_actions/artiomtr/jest-coverage-report-action/v2.0-rc.1/dist/index.js:2:11470)
> at f.CheckComplete (/home/runner/work/_actions/artiomtr/jest-coverage-report-action/v2.0-rc.1/dist/index.js:2:10900)
> at ChildProcess.<anonymous> (/home/runner/work/_actions/artiomtr/jest-coverage-report-action/v2.0-rc.1/dist/index.js:2:9944)
> at ChildProcess.emit (events.js:210:5)
> at maybeClose (internal/child_process.js:1021:16)
> at Socket.<anonymous> (internal/child_process.js:430:11)
> at Socket.emit (events.js:210:5)
> at Pipe.<anonymous> (net.js:659:12)
> /usr/bin/git checkout -f 4.3-7.10
> fatal: not a git repository (or any of the parent directories): .git
> Error: The process '/usr/bin/git' failed with exit code 128
@gabiwassan,
I think that the problem is that you're changing directory in previous step, to collect coverage. You can try to simply remove working-directory
option from your action.yml
file, or just to exit working directory in previous step. So possible configurations could be:
Remove working directory:
- name: Step 08 - Run Tests & Collect Coverage
run: |
echo “PATH_WAZUH-APP=$GITHUB_WORKSPACE/kibana/plugins/wazuh-kibana-app/” >> $GITHUB_ENV
cd ./kibana/plugins/wazuh-kibana-app
ls -la
echo $GITHUB_WORKSPACE/kibana/plugins/wazuh-kibana-app/
yarn run test:jest --silent --ci --testLocationInResults --colors --coverage --json --outputFile=report.json
- name: Step 09 - Comment coverage
uses: artiomtr/jest-coverage-report-action@v2.0-rc.1
with:
# working-directory: ./kibana/plugins/wazuh-kibana-app/
github-token: ${{ secrets.GITHUB_TOKEN }}
skip-step: all
Exit in previous step:
- name: Step 08 - Run Tests & Collect Coverage
run: |
echo “PATH_WAZUH-APP=$GITHUB_WORKSPACE/kibana/plugins/wazuh-kibana-app/” >> $GITHUB_ENV
cd ./kibana/plugins/wazuh-kibana-app
ls -la
echo $GITHUB_WORKSPACE/kibana/plugins/wazuh-kibana-app/
yarn run test:jest --silent --ci --testLocationInResults --colors --coverage --json --outputFile=report.json
# ↓
cd ../../..
- name: Step 09 - Comment coverage
uses: artiomtr/jest-coverage-report-action@v2.0-rc.1
with:
# and specify working directory ↓
working-directory: ./kibana/plugins/wazuh-kibana-app/
github-token: ${{ secrets.GITHUB_TOKEN }}
skip-step: all
Also, if these configurations not solved your issue, try to remove step 8 and let this action collect coverage for you:
- name: Step 08 - Collect & comment coverage
uses: artiomtr/jest-coverage-report-action@v2.0-rc.3
with:
working-directory: ./kibana/plugins/wazuh-kibana-app/
github-token: ${{ secrets.GITHUB_TOKEN }}
test-script: yarn run test:jest --silent --ci --testLocationInResults --colors --coverage --json --outputFile=report.json
package-manager: yarn
If these solutions do not help you, then wait until #118 is merged into the master.
@gabiwassan,
I think that the problem is that you're changing directory in previous step, to collect coverage. You can try to simply remove
working-directory
option from youraction.yml
file, or just to exit working directory in previous step. So possible configurations could be:
- Remove working directory:
- name: Step 08 - Run Tests & Collect Coverage run: | echo “PATH_WAZUH-APP=$GITHUB_WORKSPACE/kibana/plugins/wazuh-kibana-app/” >> $GITHUB_ENV cd ./kibana/plugins/wazuh-kibana-app ls -la echo $GITHUB_WORKSPACE/kibana/plugins/wazuh-kibana-app/ yarn run test:jest --silent --ci --testLocationInResults --colors --coverage --json --outputFile=report.json - name: Step 09 - Comment coverage uses: artiomtr/jest-coverage-report-action@v2.0-rc.1 with: # working-directory: ./kibana/plugins/wazuh-kibana-app/ github-token: ${{ secrets.GITHUB_TOKEN }} skip-step: all
- Exit in previous step:
- name: Step 08 - Run Tests & Collect Coverage run: | echo “PATH_WAZUH-APP=$GITHUB_WORKSPACE/kibana/plugins/wazuh-kibana-app/” >> $GITHUB_ENV cd ./kibana/plugins/wazuh-kibana-app ls -la echo $GITHUB_WORKSPACE/kibana/plugins/wazuh-kibana-app/ yarn run test:jest --silent --ci --testLocationInResults --colors --coverage --json --outputFile=report.json # ↓ cd ../../.. - name: Step 09 - Comment coverage uses: artiomtr/jest-coverage-report-action@v2.0-rc.1 with: # and specify working directory ↓ working-directory: ./kibana/plugins/wazuh-kibana-app/ github-token: ${{ secrets.GITHUB_TOKEN }} skip-step: all
Also, if these configurations not solved your issue, try to remove step 8 and let this action collect coverage for you:
- name: Step 08 - Collect & comment coverage uses: artiomtr/jest-coverage-report-action@v2.0-rc.3 with: working-directory: ./kibana/plugins/wazuh-kibana-app/ github-token: ${{ secrets.GITHUB_TOKEN }} test-script: yarn run test:jest --silent --ci --testLocationInResults --colors --coverage --json --outputFile=report.json package-manager: yarn
If these solutions do not help you, then wait until #118 is merged into the master.
I have tried the 3 options, the first two I get the same error, with the third option shows me the following error:
Run artiomtr/jest-coverage-report-action@v2.0-rc.3 with: working-directory: ./kibana/plugins/wazuh-kibana-app/ github-token: *** test-script: yarn run test:jest --silent --ci --testLocationInResults --colors --coverage --json --outputFile=report.json package-manager: yarn icons: emoji annotations: all skip-step: none env: NODE_10-23-1: 10.23.1 NODE_12-22-3: 12.22.3 YARN_1-21-1: 1.21.1 KIBANA_TAG: v7.10.2 Running using node v10.23.1 Error: Callback must be a function Error: Process completed with exit code 1.
I wait for that merge 👍🏼 thanks!
@ArtiomTr
I think I have similar problem. The workflow looks like this:
...
- name: Check current directory
run: |
pwd
ls app/
ls app/code-coverage-report-from-develop/
- uses: artiomtr/jest-coverage-report-action@v2.0-rc.5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
working-directory: ./app/
threshold: 1
skip-step: all
coverage-file: ./report.json
base-coverage-file: ./code-coverage-report-from-develop/report.json
In "Check current directory" "pwd" command outputs /home/runner/work/my-app/my-app
, which is expected. With "ls" commands I make sure that the report.json
files are there.
By setting working-directory
to ./app/
I assume that the absolute path for the working directory will be /home/runner/work/my-app/my-app/app/
and absolute paths for report.json
files will be:
/home/runner/work/my-app/my-app/app/report.json
/home/runner/work/my-app/my-app/app/code-coverage-report-from-develop/report.json
.
The action fails with:
And there is also this error: :
It would be much easier to debug if the action would print out the full path of working-directory
and the report files.
Hey @laurislokalise,
Could you please try to replicate this bug in the latest v2.0-rc.6
? This version contains more detailed debugging information so that it would be easier to spot the error. :smile:
Thanks @ArtiomTr! This is much nicer - there are much more information now :smiley: Now it outputs the actual errors directly in the console which is helpful.
Have this error: Error: Failed reading coverage file. (Error: Error: ENOENT: no such file or directory, open './report.json')
. However it is still a mistery why that happens. Knowing the absolute path of the working directory would help a lot. Is it something that can be added? Perhaps I could create a PR - but I need somebody with more experience to ensure me that it is possible :smile:
@laurislokalise, this repository is open to all types of contributions, so if you think displaying the absolute path in the error will help you understand the problem more clearly, feel free to open the PR.
However, the problem may go deeper than it might seem at first glance. The problem might be that the action is not generating a report file, which is a much deeper problem. In version v2.0-rc.6
, the action prints the entire progress, which stages were completed
/ skipped
/ failed
and why.
So could you please send me the full screenshot of the console? This would help me a lot.
@ArtiomTr here is the screenshot of the console:
@laurislokalise, thank you! Now, I see that there is two big issues with your case:
The first problem requires a deeper understanding, more time, so I've created a separate issue for it. (#190)
The second issue is caused because of not intuitive behavior of this action. This is the fragment of code which causes problem: https://github.com/ArtiomTr/jest-coverage-report-action/blob/8a4ee4425baec6bdc5ccc1f507c5c1726cc4c9e4/src/stages/collectCoverage.ts#L21-L33
You're expecting, that by specifying workingDirectory
and coverage-file
, the action will concatenate those properties, and will try to read file at path workingDirectory/coverage-file
. However, it just ignores workingDirectory
when coverage-file
is specified.
So the solution would be to simply concatenate those two properties here: https://github.com/ArtiomTr/jest-coverage-report-action/blob/8a4ee4425baec6bdc5ccc1f507c5c1726cc4c9e4/src/stages/collectCoverage.ts#L26
That's all. So now that the problem has been found, you can start working on it if you would like to.
I also have the same problem @ArtiomTr
Hi, I'm trying to use our action just to collect my report and comment on github that information, but I can't run successfully.
My action:
Error result:
Here my action.yml