Reputation: 870
It has a monorepo, where it will contain two subfolders, which are:
Each with their respective projects and packages. I am trying to access a certain subfolder to do its respective action, but it is giving an error when I run a command to test with lint, which is:
error Couldn't find a package.json file in "/github/workspace"
It probably should not be accessing the frontend subfolder. I need it to run all the commands in this subfolder, how do I do it?
MY .YML
:
name: PIPELINE OF TESTS
on:
push:
branches: [frontend-develop, backend-develop]
pull_request_target:
types: [opened, edited, closed]
branches: [main]
jobs:
test-frontend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend
strategy:
matrix:
node-version: [14.x]
architecture: [x64]
steps:
- name: CHECK-OUT GIT REPOSITORY
uses: actions/checkout@v2
- name: USE NODEJS ${{ matrix.node-version }} - ${{ matrix.architecture }}
uses: actions/setup-node@v2
- name: INSTALL PROJECT DEPENDENCIES (YARN)
uses: borales/[email protected]
with:
cmd: install
- name: CODE ANALYSE (LINT) AND STYLE-GUIDE ANALYSE (PRETTIER + AIRBNB)
uses: borales/[email protected]
with:
cmd: lint-check
- name: UNIT TEST (JEST)
uses: borales/[email protected]
with:
cmd: test
Upvotes: 5
Views: 10408
Reputation: 611
Using defaults
with run
will only be applied to the run step (e.g scripts/commands that you execute yourself and not actions). See the docs:
Provide default
shell
andworking-directory
to allrun
steps in the job. Context and expression are not allowed in this section.
When you are using a GitHub action (you have uses:
) it not possible to change the working directory. Keep in mind that some actions support this - you can pass an additional argument to with:
, but in your case borales/actions-yarn
do not support that.
What can you do?
As suggested in the borales/actions-yarn
REAME.md:
Please keep in mind that this Action was originally written for GitHub Actions beta (when Docker was the only way of doing things). Consider using actions/setup-node to work with Yarn. This repository will be mostly supporting the existing flows.
You can remove these actions and call yarn directly in run:
. Your workflow should look like:
name: PIPELINE OF TESTS
on:
push:
branches: [frontend-develop, backend-develop]
pull_request_target:
types: [opened, edited, closed]
branches: [main]
jobs:
test-frontend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend
strategy:
matrix:
node-version: [14.x]
architecture: [x64]
steps:
- name: CHECK-OUT GIT REPOSITORY
uses: actions/checkout@v2
- name: USE NODEJS ${{ matrix.node-version }} - ${{ matrix.architecture }}
uses: actions/setup-node@v2
- name: INSTALL PROJECT DEPENDENCIES (YARN)
run: yarn install
- name: CODE ANALYSE (LINT) AND STYLE-GUIDE ANALYSE (PRETTIER + AIRBNB)
run: yarn lint-check
- name: UNIT TEST (JEST)
run: yarn test
Upvotes: 10