Skip to content

1 setup golang project with fx framework#6

Merged
michiosw merged 11 commits intomainfrom
1-setup-golang-project-with-fx-framework
Apr 7, 2025
Merged

1 setup golang project with fx framework#6
michiosw merged 11 commits intomainfrom
1-setup-golang-project-with-fx-framework

Conversation

@hashkode
Copy link
Copy Markdown
Contributor

@hashkode hashkode commented Apr 7, 2025

This pull request introduces a comprehensive setup for continuous integration, release automation and project structure for the agent-browser project. The most important changes include the addition of GitHub Actions workflows for CI and release processes, the setup of MegaLinter for code quality checks and the organization of the project structure with a detailed Makefile and README.md updates.

Continuous Integration and Release Automation:

  • .github/workflows/go.yaml: Added a workflow for Go CI that runs on pushes and pull requests to the main branch, performing tasks like code checkout, Go setup, formatting checks, linting, testing and building the application.
  • .github/workflows/mega-linter.yaml: Added a MegaLinter workflow to run on pushes and pull requests to the main branch, ensuring code quality across various languages and formats.
  • .github/workflows/release.yaml: Added a workflow for automating releases using semantic-release, which runs on pushes to the main branch.

Project Structure and Configuration:

  • Makefile: Introduced a Makefile with targets for common tasks such as setup, build, run, test, format, tidy and lint. This facilitates easier project management and development workflows.
  • README.md: Updated the README to provide a detailed project structure, setup instructions and CI information, making it easier for new developers to get started and understand the project layout.

Codebase Organization:

  • cmd/agent-browser/main.go: Created the main entry point for the application, setting up the Fx application with core modules and custom logging.
  • internal/app/app.go: Defined core application modules using Fx, including common dependencies, configuration, backend services, MCP server, updater and web server.
  • internal/log/fx_adapter.go and internal/log/log.go: Implemented a custom logging adapter for Fx using zerolog, providing structured logging capabilities.

These changes collectively establish a robust foundation for continuous integration, release management and code organization, enhancing the overall development workflow and maintainability of the project.

hashkode added 4 commits April 5, 2025 20:30
…file, and application modules.

Add main application entry point and logging setup using zerolog.

Implement basic web server and UI handler with templating support.
- Added a new log adapter for integrating zerolog with Fx event logging.

- Modified main application entry point to utilize the new logger.

- Refactored UI handler to inject the logger for error handling.

- Updated Makefile to build the application binary into a specified output directory.

- Updated .gitignore to include build artifacts.
Establishes the initial Go project structure using Fx for dependency injection and lifecycle management. Includes foundational tooling and CI/CD setup.

- Initializes core directory structure (cmd, internal, scripts, .github).
- Integrates Uber Fx framework in main.go and internal/app.
- Sets up zerolog logging with an Fx adapter (internal/log).
- Creates a Makefile with targets for common tasks (build, run, test, fmt, lint, setup, tidy).
- Adds a setup script (scripts/setup.sh) to install tools (templ, golangci-lint) and check PATH.
- Configures GitHub Actions workflows for:
    - Go build/test/lint/format (go.yaml)
    - MegaLinter checks (mega-linter.yaml)
    - Semantic Release (release.yaml)
- Adds comprehensive README with setup, usage and CI details.
- Includes .gitignore file to avoid bloat.
- Adds a dummy test (internal/app/app_test.go) to validate test execution.
@hashkode hashkode added documentation Improvements or additions to documentation enhancement New feature or request labels Apr 7, 2025
@hashkode hashkode requested a review from Copilot April 7, 2025 20:39
@hashkode hashkode self-assigned this Apr 7, 2025
@hashkode hashkode linked an issue Apr 7, 2025 that may be closed by this pull request
9 tasks
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 28 out of 30 changed files in this pull request and generated no comments.

Files not reviewed (2)
  • Makefile: Language not supported
  • go.mod: Language not supported
Comments suppressed due to low confidence (1)

internal/app/app_test.go:10

  • [nitpick] TestAppDummy is a placeholder and does not verify any functionality; consider adding tests to cover critical application workflows.
func TestAppDummy(t *testing.T) {

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2025

🦙 MegaLinter status: ⚠️ WARNING

Descriptor Linter Files Fixed Errors Elapsed time
✅ ACTION actionlint 3 0 0.1s
✅ BASH bash-exec 1 0 0.01s
✅ BASH shellcheck 1 0 0.04s
✅ BASH shfmt 1 0 0 0.03s
✅ COPYPASTE jscpd yes no 5.26s
✅ GO revive 17 0 39.89s
⚠️ MARKDOWN markdownlint 1 1 1 1.67s
✅ MARKDOWN markdown-link-check 1 0 5.25s
✅ MARKDOWN markdown-table-formatter 1 1 0 1.53s
✅ REPOSITORY checkov yes no 12.31s
⚠️ REPOSITORY devskim yes 4 1.11s
✅ REPOSITORY dustilock yes no 0.02s
✅ REPOSITORY gitleaks yes no 0.07s
✅ REPOSITORY git_diff yes no 0.01s
✅ REPOSITORY grype yes no 20.11s
✅ REPOSITORY kics yes no 2.35s
✅ REPOSITORY secretlint yes no 0.59s
✅ REPOSITORY syft yes no 1.25s
✅ REPOSITORY trivy yes no 5.9s
✅ REPOSITORY trivy-sbom yes no 0.07s
✅ REPOSITORY trufflehog yes no 1.96s
✅ YAML prettier 4 3 0 2.94s
✅ YAML v8r 4 0 9.57s
✅ YAML yamllint 4 0 1.61s

See detailed report in MegaLinter reports
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

hashkode added 5 commits April 7, 2025 22:57
Corrects Go version mismatch, GitHub Actions permissions, and Go linting errors reported by MegaLinter.

- Bumps Go version in `go.yaml` workflow to 1.24, aligning with `go.mod`.
- Sets default `permissions: read-all` in `go.yaml` and `release.yaml` workflows to resolve Checkov warnings.
- Adds missing package comments to satisfy `revive` linter across multiple internal packages.
@hashkode hashkode requested a review from Copilot April 7, 2025 21:17
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 28 out of 30 changed files in this pull request and generated no comments.

Files not reviewed (2)
  • Makefile: Language not supported
  • go.mod: Language not supported
Comments suppressed due to low confidence (1)

internal/app/app_test.go:9

  • [nitpick] Consider replacing the placeholder test with comprehensive tests to verify application startup and core functionality.
    // TODO: Replace with actual application tests.

@hashkode hashkode requested review from 0xmad and michiosw April 7, 2025 21:22
@hashkode hashkode force-pushed the 1-setup-golang-project-with-fx-framework branch from eceee4b to a4425ce Compare April 7, 2025 21:25
@hashkode hashkode force-pushed the 1-setup-golang-project-with-fx-framework branch from a4425ce to d80c905 Compare April 7, 2025 21:25
@michiosw michiosw merged commit 4c7b2ff into main Apr 7, 2025
2 checks passed
@michiosw
Copy link
Copy Markdown
Contributor

michiosw commented Apr 8, 2025

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@michiosw
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setup Golang Project with Fx Framework

3 participants