github action: run a test file on pull request

Viewed 1212

I want to run a test file when someone sends a pull request. This is my action.yml file.

name: "GitHub Actions Test"
on:
    pull_request:
        branches:
            - master


jobs:
    test:
        runs-on: ubuntu-latest
        steps:
            # - uses: actions/checkout@v1
            - name: 'Install Node'
              uses: actions/setup-node@v1
            - name: Install mocha
              run: npm install -g mocha
            - name: Install dependencies
              run: npm install 
            - name: "Run Test"
              run: mocha test-mocha.test.js


but when running the test from github, I got the following error:

Error: No test files found: "test-mocha.test.js"

I wonder something is wrong on the last line of my yml file. how to fix this?

1 Answers

This is because you've commented out the line that checks out your code:

# - uses: actions/checkout@v1 # Remove the comment from this line

By default, your code is not checked out in the workflow's directory. As such, you have to use the Checkout GitHub Action to check out your code.

From the README:

This action checks-out your repository under $GITHUB_WORKSPACE, so your workflow can access it.

Related