Skip to content

Conversation

@beagins
Copy link
Contributor

@beagins beagins commented Jul 23, 2025

Description

What does this PR do?
Hackweek: add copilot instructions to ui repo

  • Work with Vault UI team to come up with ember js/ts/hbs/scss/test instructions for automated copilot PR reviews.
  • GoLang instructions shamelessly copied from Niko's shared HashiCorp copilot-resources repo
  • GitHub Copilot Reviewer Demo using this set of instructions

@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Jul 23, 2025
@github-actions
Copy link

github-actions bot commented Jul 23, 2025

CI Results:
All Go tests succeeded! ✅

@beagins beagins force-pushed the ui/hackweek/copilot branch from 2345256 to 0f57c38 Compare July 23, 2025 23:48
@vercel
Copy link

vercel bot commented Jul 23, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
vault-ui Ready Ready Preview Comment Aug 18, 2025 4:59pm

@@ -0,0 +1,265 @@
# GitHub Copilot Instructions for Vault
Copy link

@nikolasrieble nikolasrieble Jul 25, 2025

Choose a reason for hiding this comment

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

👋 Great to see the adoption of instructions. I spent the full HackWeek on investigating instructions and best practice. You might like to read https://go.hashi.co/rfc/eng-051.

One way to improve this setup is to:

  • split this top level instructions up into smaller, targeted instruction files each of the files has a glob pattern defined. In VS Code the files would then automatically be included in every prompt in the chat mode. In this case it seems one could split us as follows:
    • js.instructions.md (general js best practice)
    • ember.instructions.md (ember specific rules)
    • api.instructions.md (Restful)
  • Follow general prompt best practice:
    • short, concise bullet points
    • Prefer positive over negative instructions

You can find more examples and inspiration in the doc above.

Choose a reason for hiding this comment

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

Finally, we have created a shared repo for instructions within HashiCorp https://github.com/hashicorp/copilot-resources

@github-actions
Copy link

github-actions bot commented Aug 8, 2025

Build Results:
All builds succeeded! ✅

hellobontempo
hellobontempo previously approved these changes Aug 13, 2025
Copy link
Contributor

@hellobontempo hellobontempo left a comment

Choose a reason for hiding this comment

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

Left some comments, nice work!

});
```

> **Note**: Avoid manual server setup and shutdown. Use `setupMirage(hooks)` instead to prevent memory leaks and reduce boilerplate code.
Copy link
Contributor

Choose a reason for hiding this comment

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

👏 😍 😍 😍

});
```

**Avoid** - unnecessary nesting for organization only:
Copy link
Contributor

Choose a reason for hiding this comment

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

Love! great work updating these

Copy link
Contributor

@hellobontempo hellobontempo left a comment

Choose a reason for hiding this comment

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

🚀

@beagins beagins enabled auto-merge (squash) August 13, 2025 22:30
@beagins beagins disabled auto-merge August 13, 2025 23:40
Copy link
Collaborator

@ryancragun ryancragun left a comment

Choose a reason for hiding this comment

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

Two caveats here:

  • I don't use VSCode and as such have no idea what the actual outcomes of my suggestions will be for those who do. This PR has motivated me to set aside some time to test copilot in nvim and see what happens.
  • I did not really review the ember sections as I'm by no means any sort of authority in that area of the code base.

That said, I'm 👍 on merging this with a few small tweaks to the golang and testing sections.

We might want to hold off on merging this until next week as it'll be easier to deal with the backports that touch .github, but that's entirely up to you. If you do merge it I suspect you'll have to manually backport the changes to vault-enterprise release branches for 1.16.x+ent, 1.18.x+ent, and 1.19.x+ent.

# Go Programming Instructions

## Code Style and Formatting
- Use `gofmt` and `goimports` to format all Go code automatically
Copy link
Collaborator

Choose a reason for hiding this comment

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

We use gofumpt, gosimports, and golines formatting

## Control Structures
- Use initialization statement in if/switch when appropriate:
```go
if err := file.Chmod(0664); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if err := file.Chmod(0664); err != nil {
if err := file.Chmod(0o664); err != nil {

## Interfaces and Composition
- Design small, focused interfaces (often single-method)
- Accept interfaces, return concrete types
- Use empty interface `interface{}` or any sparingly
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- Use empty interface `interface{}` or any sparingly
- Use empty interface `interface{}` or `any` sparingly

## General Guidelines
- Write unit tests for all public functions
- Use table-driven tests when appropriate
- Follow naming convention: `TestFunctionName`
Copy link
Collaborator

Choose a reason for hiding this comment

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

We often actually underscore in Vault. e.g. Test_FunctionName


## Test Structure
- Use t.Helper() to mark helper functions
- Use subtests for organizing related test cases with t.Run()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would also suggest using t.Parallel(). Not only does this yield faster test run, it also encourages writing tests that do not share state or require specific ordering.

- Use testcontainers to spin up dependencies like postgres or redis

## Black box testing
- The test should be in feature_test package to be the first client of the feature package
Copy link
Collaborator

Choose a reason for hiding this comment

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

Eventually we'll want to add a section here on end-to-end testing with enos and cloud first testing in Vault Cloud. That does not need to happen in this PR but I wanted to comment on it for posterity.

- A unit test should only fail for one reason
- Do not share state between tests
- Cleanup resources after the test
- If files are needed, use a temp directory
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps mention using t.TempDir() as it can create one for you that is automatically cleaned up.

@beagins
Copy link
Contributor Author

beagins commented Aug 18, 2025

Addressed PR comments & cherrypicked changes to vault-enterprise repo: https://github.com/hashicorp/vault-enterprise/pull/8680

@beagins beagins closed this Aug 18, 2025
@beagins beagins deleted the ui/hackweek/copilot branch August 25, 2025 22:53
pull bot pushed a commit to Zezo-Ai/vault that referenced this pull request Sep 2, 2025
…ashicorp#8728)

* add copilot instructions to repository

use copilot resources example repo (https://github.com/hashicorp/copilot-resources/tree/main)

* address PR comments (hashicorp#31361)

Co-authored-by: Shannon Roberts (Beagin) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed pr/no-changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants