aws-amplify / amplify-hosting

AWS Amplify Hosting provides a Git-based workflow for deploying and hosting fullstack serverless web applications.
https://aws.amazon.com/amplify/hosting/
Apache License 2.0
461 stars 116 forks source link

Build artifacts for failed builds #3949

Open clemblanco opened 4 months ago

clemblanco commented 4 months ago

Before opening, please confirm:

Amplify Hosting feature

E2E Cypress tests

Is your feature request related to a problem? Please describe:

It looks like with Amplify 2, build artifacts can only be downloaded for successful builds, not failing builds. However, they are the most useful to us to troubleshoot things when our E2E tests are failing before deploying, therefore we need to be able to access them for failed builds too.

Describe how you'd like this feature to work

Same as for successful builds but for failed builds too.

image image

We can even see in the logs for failed builds that the artifacts are indeed uploaded to your S3 bucket https://aws-amplify-prod-[region]-artifacts.s3.[region].amazonaws.com/[app_id]/[branch]/000000[build_number]/BUILD/artifacts.zip, so it's not like they were not existing at all.

image

github-actions[bot] commented 4 months ago

This has been identified as a feature request. If this feature is important to you, we strongly encourage you to give a 👍 reaction on the request. This helps us prioritize new features most important to you. Thank you!

clemblanco commented 2 months ago

It's been a month and a half. Any update on this one?

mauerbac commented 1 week ago

@clemblanco right now we only upload build artifacts if the build succeeds or if it fails due to a bundle size error .

What use case are you looking for?

clemblanco commented 1 week ago

@mauerbac well if a build fails because of some e2e tests failing we want to be able to download our artifacts generated by Cypress such as screenshots and videos. This used to be possible with the first Amplify console. Not anymore unless if we use the AWS CLI directly, meaning such files are still generated and uploaded to your own private S3. They just aren't offered to download directly from the console anymore which is very annoying.

mauerbac commented 1 week ago

ah, understood -- sorry. You want to download test artifacts easily in the Gen2 UI . Let me share this with our console team

mauerbac commented 1 week ago

hi @clemblanco - i spoke to the team. There should be no difference in functionality between the new and old console UI as it pertains to this feature. If you don't see the download button that means there is some issue preventing us for giving you the logs.

Either 1/ you have your own amplify.yml file or you didn't deploy through the console so app.buildSpec was not setup

The solution would be to take whatever you have in your own custom build spec and paste it into the Build Settings section for the app in the console

clemblanco commented 1 week ago

@mauerbac it's the exact same amplify.yml and when we analyse the logs we can see Amplify uploading the same files to your S3 bucket which is how we figured out we could maybe use the AWS CLI to generate some signed URLs to directly download these files.

I've just tried pasting it into the console with no luck. The artifacts from the failing test phase are no longer accessible whatsoever, only standard logs are.

I have root access on my account so I don't think it's a permission issue.

clemblanco commented 1 week ago

This is what I'm referring to:

artifacts>files The generated artifacts (screenshots and videos) available for download.

Source: https://docs.aws.amazon.com/amplify/latest/userguide/running-tests.html

clemblanco commented 1 week ago

If you don't see the download button that means there is some issue preventing us for giving you the logs.

I do see the button it's just only giving me text logs which I already have in the console UI.

clemblanco commented 1 week ago

We don't have a custom buildspec.yml file. Only an amplify.yml one. Which we tried to copy paste into the console already.

mauerbac commented 1 week ago

ah, ok - i see. The issue is probably in the amplify.yml file. Amplify Console detects whether an app has been configured to run Cypress tests by searching for one the following phases in the app’s build spec: preTest: , test:, postTest:

preTest
Install the dependencies required to run Cypress tests. Amplify Hosting uses mochawesome to generate a report to view your test results and wait-on to set up the localhost server during the build.

test
Run cypress commands to perform tests using mochawesome.

postTest
The mochawesome report is generated from the output JSON. Note that if you are using Yarn, you must run this command in silent mode to generate the mochawesome report. For Yarn, you can use the following command.

You may need to edit your file with one of these commands. If you need further help, could you contact me with your account number + appId + build id and ill take a look. You can DM me on Twitter, Discord or amazon email with my username on github

clemblanco commented 1 week ago

We already have these in our amplify.yml

I will DM you.