Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment fails when test section included in amplify.yml #1923

Closed
wyatt-troia opened this issue Jun 4, 2021 · 8 comments
Closed

Deployment fails when test section included in amplify.yml #1923

wyatt-troia opened this issue Jun 4, 2021 · 8 comments
Labels
archived This issue has been locked. pending-investigation

Comments

@wyatt-troia
Copy link

wyatt-troia commented Jun 4, 2021

Region: us-east-1
App ID: diz6udlgf5b4p

The below build config results in a build that fails during the "deploy" stage with the following logs:

2021-06-04T04:19:06 [INFO]: Starting Deployment
2021-06-04T04:19:06 [ERROR]: Failed to deploy

When I remove the testing section entirely, deployment succeeds. Deployment also fails when I include the test section but omit the "files" part.

Is there anything I can do? I'd like to be able to integrate testing into my deployment process. The repo is structured as a monorepo

amplify.yml:

version: 1
applications:
  - appRoot: packages/my-app
    frontend:
      phases:
        preBuild:
          commands:
            - echo "REACT_APP_API_GATEWAY_URL=$REACT_APP_API_GATEWAY_URL" > .env
            - yarn install --frozen-lockfile
        build:
          commands:
            - npm run build
      artifacts:
        files:
            - "**/*"
        baseDirectory: build
      cache:
        paths:
          - node_modules/**/*
    test:
      phases:
        test:
          commands:
            - cd ../.. # go up to monorepo root
            - npm run test:run-all
      **artifacts:
        baseDirectory: ./ # arbitrary existing path bc amplify test phase will fail without one
        files:
          - "**/*.mp4"**

@github-actions
Copy link

github-actions bot commented Jun 4, 2021

Hi 👋, thanks for opening! While we look into this...

If this issue is related to custom domains, be sure to check the custom domains troubleshooting guide to see if that helps. Also, there is a more general troubleshooting FAQ that may be helpful for other questions.

Lastly, please make sure you've specified the App ID and Region in the issue!

@kahdojay
Copy link
Contributor

kahdojay commented Jun 4, 2021

@wyatt-troia can you confirm for me the branch and job number for the deploy failure? The only deploy for diz6udlgf5b4p that I see around that time doesn't show any error on our end.

@kahdojay
Copy link
Contributor

kahdojay commented Jun 4, 2021

@wyatt-troia can you also double check your yaml syntax (in particular **artifacts looks off) and see if this also helps: #1167 (comment)

@sameer-kumar-jain
Copy link

sameer-kumar-jain commented Jun 13, 2021

I am having a similar issue with this. My Amplify.yml looks like following and my app id is dnpfuqj1l8nkg. I also tried to modify yml as per suggestions/examples I found on the internet but nothing works. It always stuck at the build phase or sometimes at the test phase but it never starts my tests.

amplify.yml:

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - yarn install
    build:
      commands:
        - yarn run build
  artifacts:
    baseDirectory: build
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*
test:
  phases:
    test:
      commands:
        - yarn test
  artifacts:
    baseDirectory: ./
    files:
      - '**/*.mp4'    

EDIT: Here are couple of last lines from buid.log

2021-06-13T12:02:05.950Z [INFO]: # Completed phase: build
                                 ## Completed Frontend Build
2021-06-13T12:02:05.950Z [INFO]: ## Build completed successfully
2021-06-13T12:02:05.951Z [INFO]: # Starting caching...
2021-06-13T12:02:06.027Z [INFO]: Creating cache artifact...
2021-06-13T12:02:29.979Z [INFO]: # Cache artifact is: 1516MB
2021-06-13T12:02:30.054Z [INFO]: # Uploading cache artifact...
2021-06-13T12:02:40.343Z [INFO]: # Caching completed

@sameer-kumar-jain
Copy link

sameer-kumar-jain commented Jun 14, 2021

Updates:

So I changed test script to this in package.json

CI=true react-scripts test

and modified my yml to this

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - yarn install
    build:
      commands:
        - yarn run build
  artifacts:
    baseDirectory: build
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*
test:
  phases:
    test:
      commands:
        - 'yarn test'
  artifacts:
    baseDirectory: ./
    files:
      - '**/*'

Now all my tests passed and worked correctly but fails on deploy with the following logs

2021-06-14T06:43:35 [INFO]: Starting Deployment
2021-06-14T06:43:35 [ERROR]: Failed to deploy

@sameer-kumar-jain
Copy link

It worked now. I tested with a fresh new app and all good, so I think CI=true in package.json and configFilePath: '/mochawesome.json'** did the trick. Not sure why configFilePath is required, but this helped me

package.json

...
"test": "CI=true react-scripts test",
...

amplify.yml

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - yarn install
    build:
      commands:
        - yarn run build
  artifacts:
    baseDirectory: build
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*
test:
  phases:
    test:
      commands:
        - 'yarn test'
  artifacts:
    baseDirectory: ./
    **configFilePath: '**/mochawesome.json'**
    files:
      - '**/*.mp4'

@wyatt-troia
Copy link
Author

@saachitech @kahdojay Thank you! I also just had to provide an arbitrary value for configFilePath. Definitely tough to figure this one out with the error message given

Here was my final test section of my config:

    test:
      phases:
        test:
          commands:
            - cd ../.. # go up to monorepo root
            - npm run test:run-all
      artifacts: # arbitrary values (other than baseDirectory) bc amplify test phase will fail without them
        baseDirectory: ./ 
        configFilePath: '**/mochawesome.json'
        files:
          - '**/*.png'
          - '**/*.mp4'

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot added the archived This issue has been locked. label Oct 28, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Oct 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived This issue has been locked. pending-investigation
Projects
None yet
Development

No branches or pull requests

3 participants