-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add integration test debugging to launch cfg, refactor magefile, and update comments - Introduced a new launch configuration for "mage RunIntegrationTests" in the VSCode settings. - Enhanced the documentation and comments within `magefiles/magefile.go` for clarity. * Expose runIntegrationTests as a Mage Command and Enhance Documentation - Made `runIntegrationTests` an exported function as `RunIntegrationTests` to allow it to be used as a Mage command. - Added comprehensive comments to functions related to TTP example README parsing and command execution. * Enhance compilation and testing functionalities in magefile - Introduce `Compile` function using `goreleaser` for project compilation. - Implement environment variable handling for target OS and architecture in compilation. - Improve the `InstallDeps` function's description and dependencies. - Handle `pre-commit` tool validation and error messaging in `RunPreCommit`. - Add environment variable handling and adjustments in `RunIntegrationTests`. - Implement temporary directory handling for binary during integration tests. * Refactor magefile and introduce magefiles README - Introduce a comprehensive README for the `magefiles` to document its functionality and usage. - Refine the `Compile` function to simplify environment variable handling for OS and architecture. - Remove unnecessary environment variables in `RunIntegrationTests` and ensure a cleaner flow for binary path setting. - Introduce utility functions `changeToRepoRoot` and `getBinaryDirName` for cleaner and modular code. - Add appropriate cleanup for generated directories and files post integration tests. * Optimize magefile structure and introduce testing script - Organize build tags for the `magefile`. - Remove redundant and unused `FindExportedFuncsWithoutTests` function. - Streamline the `RunTests` function by removing unnecessary dependencies. - Introduce `magefile_test.sh` script to automate the testing of magefile commands, ensuring each command works as expected. * Update developer documentation with mage test command; linting - Add a section in `docs/dev/README.md` to guide developers on testing all mage functions using the new script. - Linted docs/dev/update-go.md * Refactor Compile function for better usability and clarity - Removed direct parameter from the Compile function and shifted to an environment variable approach for the 'release' variable. - Updated function comments to be more concise and informative, adhering to the 80-character line limit. - Adjusted the RunIntegrationTests function to set the 'release' environment variable before calling Compile. * Refactor magefiles README doc gen; pin afero dep - Simplify the introduction in the README for magefiles. - Reorganize the magefile function comments to provide clearer examples and more consistent formatting. - Update the docgen README template to support magefiles. - Pin afero to desired version * Update pre-commit hooks * Update magefile_test with final changes to compile command
- Loading branch information
Showing
11 changed files
with
737 additions
and
481 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ coverage-all.out | |
# Compiled binary | ||
ttpforge | ||
ttpforge-windows | ||
dist | ||
|
||
# vscode debugger | ||
__debug_bin | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
# TTPForge/magefiles | ||
|
||
`magefiles` provides utilities that would normally be managed | ||
and executed with a `Makefile`. Instead of being written in the make language, | ||
magefiles are crafted in Go and leverage the [Mage](https://magefile.org/) library. | ||
|
||
--- | ||
|
||
## Table of contents | ||
|
||
- [Functions](#functions) | ||
- [Contributing](#contributing) | ||
- [License](#license) | ||
|
||
--- | ||
|
||
## Functions | ||
|
||
### Compile() | ||
|
||
```go | ||
Compile() error | ||
``` | ||
|
||
Compile compiles the Go project using goreleaser. The behavior is | ||
controlled by the 'release' environment variable. If the GOOS and | ||
GOARCH environment variables are not set, the function defaults | ||
to the current system's OS and architecture. | ||
|
||
**Environment Variables:** | ||
|
||
release: Determines the compilation mode. | ||
|
||
If "true", compiles all supported releases for TTPForge. | ||
If "false", compiles only the binary for the specified OS | ||
and architecture (based on GOOS and GOARCH) or the current | ||
system's default if the vars aren't set. | ||
|
||
GOOS: Target operating system for compilation. Defaults to the | ||
current system's OS if not set. | ||
|
||
GOARCH: Target architecture for compilation. Defaults to the | ||
current system's architecture if not set. | ||
|
||
Example usage: | ||
|
||
```go | ||
release=true mage compile # Compiles all supported releases for TTPForge | ||
GOOS=darwin GOARCH=arm64 mage compile false # Compiles the binary for darwin/arm64 | ||
GOOS=linux GOARCH=amd64 mage compile false # Compiles the binary for linux/amd64 | ||
``` | ||
|
||
**Returns:** | ||
|
||
error: An error if any issue occurs during compilation. | ||
|
||
--- | ||
|
||
### GeneratePackageDocs() | ||
|
||
```go | ||
GeneratePackageDocs() error | ||
``` | ||
|
||
GeneratePackageDocs creates documentation for the various packages | ||
in the project. | ||
|
||
Example usage: | ||
|
||
```go | ||
mage generatepackagedocs | ||
``` | ||
|
||
**Returns:** | ||
|
||
error: An error if any issue occurs during documentation generation. | ||
|
||
--- | ||
|
||
### InstallDeps() | ||
|
||
```go | ||
InstallDeps() error | ||
``` | ||
|
||
InstallDeps installs the Go dependencies necessary for developing | ||
on the project. | ||
|
||
Example usage: | ||
|
||
```go | ||
mage installdeps | ||
``` | ||
|
||
**Returns:** | ||
|
||
error: An error if any issue occurs while trying to | ||
install the dependencies. | ||
|
||
--- | ||
|
||
### RunIntegrationTests() | ||
|
||
```go | ||
RunIntegrationTests() error | ||
``` | ||
|
||
RunIntegrationTests executes all integration tests by extracting the commands | ||
described in README files of TTP examples and then executing them. | ||
|
||
Example usage: | ||
|
||
```go | ||
mage runintegrationtests | ||
``` | ||
|
||
**Returns:** | ||
|
||
error: An error if any issue occurs while running the tests. | ||
|
||
--- | ||
|
||
### RunPreCommit() | ||
|
||
```go | ||
RunPreCommit() error | ||
``` | ||
|
||
RunPreCommit updates, clears, and executes all pre-commit hooks | ||
locally. The function follows a three-step process: | ||
|
||
First, it updates the pre-commit hooks. | ||
Next, it clears the pre-commit cache to ensure a clean environment. | ||
Lastly, it executes all pre-commit hooks locally. | ||
|
||
Example usage: | ||
|
||
```go | ||
mage runprecommit | ||
``` | ||
|
||
**Returns:** | ||
|
||
error: An error if any issue occurs at any of the three stages | ||
of the process. | ||
|
||
--- | ||
|
||
### RunTests() | ||
|
||
```go | ||
RunTests() error | ||
``` | ||
|
||
RunTests executes all unit tests. | ||
|
||
Example usage: | ||
|
||
```go | ||
mage runtests | ||
``` | ||
|
||
**Returns:** | ||
|
||
error: An error if any issue occurs while running the tests. | ||
|
||
--- | ||
|
||
## Contributing | ||
|
||
Pull requests are welcome. For major changes, | ||
please open an issue first to discuss what | ||
you would like to change. | ||
|
||
--- | ||
|
||
## License | ||
|
||
This project is licensed under the MIT | ||
License - see the [LICENSE](https://github.com/facebookincubator/TTPForge/blob/main/LICENSE) | ||
file for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.