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

Skipped builds fail #3268

Closed
5 tasks done
jdpst opened this issue Jan 26, 2023 · 9 comments
Closed
5 tasks done

Skipped builds fail #3268

jdpst opened this issue Jan 26, 2023 · 9 comments
Labels
archived This issue has been locked. bug Something isn't working compute investigating

Comments

@jdpst
Copy link

jdpst commented Jan 26, 2023

Before opening, please confirm:

  • I have checked to see if my question is addressed in the FAQ.
  • I have searched for duplicate or closed issues.
  • I have read the guide for submitting bug reports.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.

App Id

d1zloo668ozrvr

AWS Region

eu-west-1

Amplify Hosting feature

Frontend builds, Monorepo

Describe the bug

Diff deployment correctly detects when there are no changes and skips running the build, but then fails because it complains that the build artefact doesn't exist. See logs and buildspec below.

Expected behavior

When a build is supposed to be skipped I would expect it to actually be skipped, not to fail.

Reproduction steps

  1. Enable diff deployments
  2. Click re-deploy this version

Build Settings

cdk.aws_codebuild.BuildSpec.fromObjectToYaml({
    version: 1,
    applications: [
      {
        appRoot,
        frontend: {
          phases: {
            preBuild: {
              commands: [
                "npm ci",
                'echo "NEXT_PUBLIC_HOST=$AWS_BRANCH.$AWS_APP_ID.amplifyapp.com" >> .env.production',
                'echo "NEXT_PUBLIC_GIT_SHA=$(git rev-parse HEAD)" >> .env.production',
              ],
            },
            build: {
              commands: ["npm run build"],
            },
            postBuild: {
              commands: [
                "shopt -s dotglob", // include filenames beginning with a ‘.’ in the results of filename expansion, except '.' and '..'
                `mv -f .next/standalone/${appRoot}/* .next/standalone`,
              ],
            },
          },
          artifacts: {
            baseDirectory: ".next",
            files: ["**/*"],
          },
          cache: {
            paths: ["../../node_modules/**/*", ".next/cache/**/*"],
          },
        },
      },
    ],
  });

Log output

2023-01-26T12:23:43.726Z [INFO]: # Determining if there are deployable frontend differences relative to repository root at: apps/admin
2023-01-26T12:23:43.726Z [INFO]: # NOTE: Set the AMPLIFY_DIFF_DEPLOY_ROOT environment variable to a valid relative path to override the default, ie: dist
2023-01-26T12:23:43.770Z [INFO]: # No differences detected.
2023-01-26T12:23:43.771Z [INFO]: # Defaulting to Node version 16
2023-01-26T12:23:52.878Z [INFO]: # Node version 16 is available for installation
2023-01-26T12:23:52.960Z [INFO]: # Installing Node version 16
2023-01-26T12:23:58.864Z [INFO]: # Now using Node version 16
2023-01-26T12:23:58.951Z [INFO]: No live updates for this build run
2023-01-26T12:23:58.953Z [INFO]: Setting NEXT_PRIVATE_STANDALONE=true to produce .next/standalone directory
2023-01-26T12:23:58.954Z [INFO]: # Retrieving cache...
2023-01-26T12:23:59.022Z [INFO]: # Extracting cache...
2023-01-26T12:23:59.024Z [INFO]: # Extraction completed
2023-01-26T12:23:59.025Z [INFO]: # Retrieved cache
2023-01-26T12:24:37.165Z [INFO]: ## Skipping Frontend Build & Deploy, No changes detected...
2023-01-26T12:24:37.268Z [INFO]: ## Build completed successfully
2023-01-26T12:24:37.269Z [INFO]: # Starting caching...
2023-01-26T12:24:37.274Z [INFO]: # Creating cache artifact...
2023-01-26T12:24:37.278Z [INFO]: # Created cache artifact
2023-01-26T12:24:37.278Z [INFO]: # Uploading cache artifact...
2023-01-26T12:24:37.351Z [INFO]: # Uploaded cache artifact
2023-01-26T12:24:37.351Z [INFO]: # Caching completed
2023-01-26T12:24:37.353Z [INFO]: Setting NEXT_PRIVATE_STANDALONE=true to produce .next/standalone directory
2023-01-26T12:24:37.354Z [INFO]: # No custom headers found.
2023-01-26T12:24:37.356Z [ERROR]: !!! CustomerError: The base directory '.next' you have specified in your amplify.yml does not exist. Make sure you run 'next build' or specify the correct name for your NextJS build directory.
2023-01-26T12:24:37.356Z [INFO]: # Starting environment caching...
2023-01-26T12:24:37.356Z [INFO]: # Uploading environment cache artifact...
2023-01-26T12:24:37.430Z [INFO]: # Uploaded environment cache artifact
2023-01-26T12:24:37.430Z [INFO]: # Environment caching completed
Terminating logging...

Additional information

We use the GitHub App integration with a monorepo so builds are frequently skipped. However, when they are skipped it causes the checks on a PR to fail, which is annoying. This also means we can't distinguish between actual failures and "skips" without signing in to the AWS console and checking the build logs. Very annoying.

image

@jdpst jdpst added bug Something isn't working pending-triage labels Jan 26, 2023
@ghost ghost self-assigned this Jan 27, 2023
@ghost
Copy link

ghost commented Feb 1, 2023

Hi @jdpst 👋🏽 thanks for raising this issue. We are currently working on reproducing and root causing this issue. Will update once we have next steps.

@jdpst
Copy link
Author

jdpst commented Feb 17, 2023

@hloriana any updates?

@michrome
Copy link

Now available as a beta, Amplify Hosting has improved support for monorepo frameworks including npm/yarn/pnpm workspaces, Turborepo and Nx. If you'd like to try it out, please let me know your AWS Account ID number so we can flag you in. My email is [email protected].

@ghost ghost removed their assignment Jul 7, 2023
@lj-n
Copy link

lj-n commented Aug 9, 2023

Any updates on this? Having the same problem with a turborepo setup.

2023-08-09T10:09:09.030Z [INFO]: ## Skipping Frontend Build & Deploy, No changes detected...
2023-08-09T10:09:09.030Z [INFO]: ## Build completed successfully
2023-08-09T10:09:09.031Z [INFO]: # Starting caching...
2023-08-09T10:09:09.042Z [INFO]: # Creating cache artifact...
2023-08-09T10:09:25.152Z [INFO]: # Created cache artifact
2023-08-09T10:09:25.253Z [INFO]: # Uploading cache artifact...
2023-08-09T10:09:36.259Z [INFO]: # Uploaded cache artifact
2023-08-09T10:09:36.365Z [INFO]: # Caching completed
2023-08-09T10:09:36.372Z [INFO]: # No custom headers found.
2023-08-09T10:09:36.458Z [ERROR]: !!! CustomerError: Build output not found in /codebuild/output/src3965271401/src/<<repo>>/amplify-compute-bundle-output/compute/.next/server, please check your build artifacts path
2023-08-09T10:09:36.458Z [INFO]: # Starting environment caching...
2023-08-09T10:09:36.460Z [INFO]: # Environment caching completed

@jay-kj-woo
Copy link

jay-kj-woo commented Sep 4, 2023

@michrome
Any update on this? Also having the same issue when build is skipped from no diff status:

2023-09-04T20:29:19.240Z [INFO]: # NOTE: Set the AMPLIFY_DIFF_DEPLOY_ROOT environment variable to a valid relative path to override the default, ie: dist
2023-09-04T20:29:19.356Z [INFO]: # No differences detected.
2023-09-04T20:29:19.357Z [INFO]: No live updates for this build run
2023-09-04T20:29:19.360Z [INFO]: # Retrieving cache...
2023-09-04T20:29:38.445Z [INFO]: # Extracting cache...
2023-09-04T20:29:56.018Z [INFO]: # Extraction completed
2023-09-04T20:29:56.324Z [INFO]: # Retrieved cache
2023-09-04T20:30:31.434Z [INFO]: ## Skipping Frontend Build & Deploy, No changes detected...
2023-09-04T20:30:31.504Z [INFO]: ## Build completed successfully
2023-09-04T20:30:31.505Z [INFO]: # Starting caching...
2023-09-04T20:30:31.516Z [INFO]: # Creating cache artifact...
2023-09-04T20:31:06.356Z [INFO]: # Created cache artifact
2023-09-04T20:31:06.446Z [INFO]: # Uploading cache artifact...
2023-09-04T20:31:21.512Z [INFO]: # Uploaded cache artifact
2023-09-04T20:31:21.591Z [INFO]: # Caching completed
2023-09-04T20:31:21.598Z [INFO]: # No custom headers found.
2023-09-04T20:31:21.603Z [ERROR]: !!! CustomerError: Artifacts base directory not found in build output, please check your buildSpec

@Namstel
Copy link

Namstel commented Mar 14, 2024

We are also running into the very same issue.

We have Nuxt 3 apps in Turborepo.

Our amplify.yml looks like this:

version: 1
applications:
  - appRoot: apps/appOne
    frontend:
      buildPath: /
      phases:
        preBuild:
          commands:
            - npm install -g pnpm
            - nvm use 18 && node --version
            - corepack enable && npx --yes nypm install
        build:
          commands:
            - pnpm build:appOne
      artifacts:
        baseDirectory: .amplify-hosting
        files:
          - "**/*"
  - appRoot: apps/appTwo
    frontend:
      buildPath: /
      phases:
        preBuild:
          commands:
            - npm install -g pnpm
            - nvm use 18 && node --version
            - corepack enable && npx --yes nypm install
        build:
          commands:
            - pnpm build:appTwo
      artifacts:
        baseDirectory: .amplify-hosting
        files:
          - "**/*"

And then for each app in the Amplify dashboard, we set the environment variables to:
AMPLIFY_DIFF_DEPLOY: true
AMPLIFY_MONOREPO_APP_ROOT: (the path to the app)

Deployment works fine without AMPLIFY_DIFF_DEPLOY (or setting it to false), but not with it set to true.

Here are the logs

2024-03-14T10:20:49.854Z [INFO]: # Determining if there are deployable frontend differences relative to repository root at: apps/appOne
2024-03-14T10:20:49.854Z [INFO]: # NOTE: Set the AMPLIFY_DIFF_DEPLOY_ROOT environment variable to a valid relative path to override the default, ie: dist
2024-03-14T10:20:49.911Z [INFO]: # No differences detected.
2024-03-14T10:20:50.828Z [INFO]: No live updates for this build run
2024-03-14T10:20:50.833Z [INFO]: # Retrieving cache...
2024-03-14T10:20:50.833Z [INFO]: # Retrieved cache
2024-03-14T10:21:10.943Z [INFO]: ## Starting Backend Build
                                 ## Checking for associated backend environment...
                                 ## No backend environment association found, continuing...
                                 ## Completed Backend Build
2024-03-14T10:21:10.951Z [INFO]: {"backendDuration": 0}
                                 ## Skipping Frontend Build & Deploy, No changes detected...
2024-03-14T10:21:11.030Z [INFO]: ## Build completed successfully
2024-03-14T10:21:11.039Z [ERROR]: !!! CustomerError: Failed to find the deploy-manifest.json file in the build output. Please verify that it exists within the "baseDirectory" specified in your buildSpec. If it's not there, we will also check the .amplify-hosting directory as a fallback. When using a framework adapter for hosting on Amplify, double-check that the adapter settings are correct.
2024-03-14T10:21:11.040Z [INFO]: # Starting environment caching...
2024-03-14T10:21:11.040Z [INFO]: # Environment caching completed
2024-03-14T10:21:11.040Z [INFO]: # A new default build image based on Amazon Linux 2023 is now generally available. The image includes newer versions of Node.js, Python, and Ruby that you can use to build your app. To use the new image, select "Amazon Linux:2023" in the "Build settings" section for your app in the Amplify console.
Terminating logging...

Technically it's working, as it's not building, but having the Amplify dashboard report failed deployments seems wrong.

@Narrator
Copy link
Contributor

@Namstel We pushed an update last week to fix this issue. AMPLIFY_DIFF_DEPLOY should now work as expected - Please let us know if you continue to face issues.

Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Copy link

This issue has been automatically locked.

@github-actions github-actions bot added the archived This issue has been locked. label Mar 28, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived This issue has been locked. bug Something isn't working compute investigating
Projects
None yet
Development

No branches or pull requests

6 participants