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

fix: Site build polling and latest build branch #4663

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

apburnes
Copy link
Contributor

Closes #4650 and #4648

Changes proposed in this pull request:

  • Adds react-query to manage api calls and polling for site builds
  • Simplifies the tagging of the latest, completed build branches
  • Removes fetch builds from redux state

security considerations

Adds new dependency react-query to manage http calls

@cloud-gov-pages-operations
Copy link
Contributor

cloud-gov-pages-operations commented Nov 14, 2024

🤖 This is an automated code coverage report

Total coverage (lines): 14.04%
Coverage diff: 8.56% 📈

Copy link
Contributor

@drewbo drewbo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a big improvement and I'm excited about the new patterns. Added a few small questions/comments

import { useQuery } from '@tanstack/react-query';
import api from '@util/federalistApi';

// Assumes the order of builds is based on createdAt desc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a slight potential for race conditions because of createdAt sorting vs completedAt checking but I'm fine ignoring for now

@@ -0,0 +1,1349 @@
export const builds = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually we should create some standardized way of creating our fixtures but this is perfect for now

import AlertBanner from '@shared/alertBanner';
import LoadingIndicator from '@shared/LoadingIndicator';

export default function QueryPage({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this

/>
</div>
)}
{data?.length > 0 && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to avoid these checks in the QueryPage children? It shouldn't try to render the child without data but not sure if component still gets fully run

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be cut because the QueryPage does not render the child without data.

return request(`site/${site.id}/build`);
return request(
`site/${site.id}/build`,
{},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are theses changes need to the API request?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The request method kicks off a notification redux action by default and these args skips the notification action. The QueryPage wrapper we now handle the error from a react-query request with an alert.

@apburnes apburnes force-pushed the fix-build-polling-and-latest-build-branch branch 2 times, most recently from d923955 to 88e23a9 Compare November 14, 2024 21:51
Signed-off-by: Andrew Burnes <andrew.burnes@gsa.gov>
@apburnes apburnes force-pushed the fix-build-polling-and-latest-build-branch branch from 88e23a9 to 5f03ab4 Compare November 14, 2024 22:53
});
}

export function useBuilds(id) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rename this variable siteId for clarity (and it will bind the second variable of the mutation function which I think right now might not be needed)


it('should mutate the builds on rebuild', async () => {
const siteId = 1;
await getSiteBuilds(siteId, 'Something happened');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No second argument

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: build status polling broken
3 participants