-
Notifications
You must be signed in to change notification settings - Fork 7
feat: upgrade to magefile #136
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
Closed
Closed
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
6b09642
feat: magefile from demo plugin
fmartingr 590eb03
feat: allow bulding other binaries
fmartingr 805217d
refactor: better namespaces, split binaries into own target
fmartingr 55dbf95
feat: add mage webapp:watch
fmartingr c2229e4
chore: make calls mage for migrated commands
fmartingr 7a8f565
feat: make Logger public for custom targets
fmartingr c5556a2
feat: allow disable logging in cmd
fmartingr a1fe6d1
docs: added friendly error code for end users
fmartingr 6a7059d
Added a README file
fmartingr 8716c86
chore: fixes some log namespace names
fmartingr c15b04a
refactor: binaryname -> binarynameformat
fmartingr aa5b731
fix: also bundle on upload
fmartingr 7a6b091
ci: updated to use mage
fmartingr 5a65174
linted
fmartingr 7021a92
fix: enhance plugin bundle deployment error handling
fmartingr ee252e9
fix: bug finder bugs
fmartingr 4c75dca
refactor: use package for magefiles
fmartingr f421d97
docs: updated README
fmartingr 6e02fbc
feat: include other assets in magefile plugin package
fmartingr b1cb565
fix: include .editorconfig in assets
fmartingr 84e5a38
feat: assets
fmartingr 56b9008
chore: removed verbose logger
fmartingr 2eebd67
chore: removed aliases
fmartingr 6514f3f
feat: specify mage version in ci
fmartingr 312b451
fix: restore ci.yml but keep updating it from mage
fmartingr e99027e
fix: magefile in the correct folder
fmartingr 1ccd244
fix: update gitignore to have ci.yml in the repo
fmartingr 1bb4001
rename: plugin_magefile -> pluginmage
fmartingr 5b54b63
Merge branch 'main' into feat/magefile
mattermost-build 3593b70
chore: change default build platforms
fmartingr a398286
chore: remove fancy error urls
fmartingr 7b395b3
fix: make deploy mage command
fmartingr 2641008
Merge remote-tracking branch 'origin/main' into feat/magefile
fmartingr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,14 @@ | ||
| package main | ||
|
|
||
| import "github.com/mattermost/mattermost-plugin-legal-hold/pluginmage" | ||
|
|
||
| func init() { | ||
| // Register the processor binary | ||
| pluginmage.RegisterBinary(pluginmage.BinaryBuildConfig{ | ||
| Name: "processor", | ||
| OutputPath: "./bin", | ||
| BinaryNameFormat: "processor-{{.Manifest.Version}}-{{.GOOS}}-{{.GOARCH}}", | ||
| WorkingDir: "./processor", | ||
| PackagePath: ".", | ||
| }) | ||
| } |
This file contains hidden or 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,12 @@ | ||
| //go:build mage | ||
| // +build mage | ||
|
|
||
| // This file is maintained by the plugin sdk tooling. | ||
| // Please do not make changes to this file. | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
| //mage:import | ||
| _ "github.com/mattermost/mattermost-plugin-legal-hold/pluginmage" | ||
| ) |
This file contains hidden or 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,127 @@ | ||
| # Plugin Magefile Package | ||
|
|
||
| This package provides a comprehensive set of [Mage](https://magefile.org/) targets for building, developing, and deploying Mattermost plugins. It replaces the traditional Makefile-based build system with a more flexible and maintainable Go-based solution. | ||
|
|
||
| ## Features | ||
|
|
||
| - 🔨 **Build System** | ||
| - Server binary compilation with multi-platform support | ||
| - Webapp (React/TypeScript) building and watching | ||
| - Plugin bundle creation | ||
| - Dependency management | ||
|
|
||
| - 🚀 **Development Tools** | ||
| - Hot-reload capability with `Watch` target | ||
| - Debug mode support via `MM_DEBUG` | ||
| - Custom logging with namespace support | ||
| - Local and remote deployment options | ||
|
|
||
| - 🛠️ **Deployment** | ||
| - Plugin upload via Mattermost API | ||
| - Enable/disable plugin management | ||
| - Support for both local socket and HTTP API connections | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Basic Commands | ||
|
|
||
| ```bash | ||
| # Show all available commands | ||
| mage | ||
| # Build everything (server, webapp, bundle) | ||
| mage build:all | ||
| # Watch webapp for changes (hot-reload) | ||
| mage webapp:watch | ||
| # Deploy to local Mattermost server | ||
| mage pluginctl:deploy | ||
| ``` | ||
|
|
||
| ### Environment Variables | ||
|
|
||
| - `MM_DEBUG`: Enable debug mode for both Go and webapp builds | ||
| - `MM_SERVICESETTINGS_SITEURL`: Mattermost server URL for deployment | ||
| - `MM_ADMIN_TOKEN`: Admin access token for deployment | ||
| - `MM_ADMIN_USERNAME`/`MM_ADMIN_PASSWORD`: Alternative authentication for deployment | ||
| - `MM_LOCALSOCKETPATH`: Unix socket path for local mode deployment | ||
| - `GO_BUILD_FLAGS`: Additional Go build flags | ||
| - `ASSETS_DIR`: Custom assets directory path | ||
|
|
||
| ### Development Workflow | ||
|
|
||
| 1. Install dependencies: | ||
| ```bash | ||
| mage webapp:dependencies | ||
| ``` | ||
|
|
||
| 2. Start development mode: | ||
| ```bash | ||
| mage webapp:watch | ||
| ``` | ||
|
|
||
| 3. Deploy changes: | ||
| ```bash | ||
| mage pluginctl:deploy | ||
| ``` | ||
|
|
||
| ## Customizing | ||
|
|
||
| ### Build more golang binaries | ||
|
|
||
| You can register additional binaries to build by calling `RegisterBinary` in a new file in the `magefiles` directory: | ||
|
|
||
| ```go | ||
| // magefiles/binaries.go | ||
| func init() { | ||
| // Register additional binaries to build | ||
| plugin_magefile.RegisterBinary(plugin_magefile.BinaryBuildConfig{ | ||
| BinaryName: "custom-tool", | ||
| PackagePath: "./tools/custom", | ||
| OutputPath: "./dist/tools", | ||
| Platforms: []plugin_magefile.BuildPlatform{ | ||
| {GOOS: "linux", GOARCH: "amd64"}, | ||
| }, | ||
| }) | ||
| } | ||
| ``` | ||
|
|
||
| ## Architecture | ||
|
|
||
| ### Package Structure | ||
|
|
||
| - `build.go`: Build configuration and binary building logic | ||
| - `webapp.go`: Webapp building and development tools | ||
| - `dist.go`: Bundle creation and packaging | ||
| - `pluginctl.go`: Deployment and plugin management | ||
| - `server.go`: Server binary compilation | ||
| - `cmd.go`: Command execution utilities | ||
| - `log.go`: Custom logging implementation | ||
| - `types.go`: Core types and configuration | ||
| - `init.go`: Package initialization and environment setup | ||
| - `assets/`: Embedded assets handling | ||
|
|
||
| ### Logging | ||
|
|
||
| We include a custom logging output implementation that allows to easily spot the namespace and target of the log line by using the `namespace` and `target` as attributes: | ||
|
|
||
| ```go | ||
| Logger.Info("Info", | ||
| "namespace", "my namespace", | ||
| "target", "my target") | ||
| ``` | ||
|
|
||
| ### Running commands | ||
|
|
||
| We include a custom command runner that allows to run commands with the correct namespace and target: | ||
|
|
||
| ```go | ||
| cmd := NewCmd("my namespace", "my target", map[string]string{ | ||
| "ENV_VAR": "value", | ||
| }) | ||
| if err := cmd.Run("npm", "run", "build"); err != nil { | ||
| return fmt.Errorf("failed to build webapp: %w", err) | ||
| } | ||
| ``` | ||
|
|
||
| # More information | ||
|
|
||
| - [Error codes](ERROR_CODES.md) |
File renamed without changes.
This file contains hidden or 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,23 @@ | ||
| name: ci | ||
| on: | ||
| schedule: | ||
| - cron: "0 0 * * *" | ||
| push: | ||
| branches: | ||
| - main | ||
| tags: | ||
| - "v*" | ||
| pull_request: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| env: | ||
| IS_CI: true | ||
|
|
||
| jobs: | ||
| plugin-ci: | ||
| uses: mattermost/actions-workflows/.github/workflows/plugin-ci.yml@mage | ||
| secrets: inherit | ||
| with: | ||
| mage-version: v1.15.0 |
File renamed without changes.
This file contains hidden or 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,6 @@ | ||
| package assets | ||
|
|
||
| import "embed" | ||
|
|
||
| //go:embed *.yml **/*/*.yml .editorconfig | ||
| var Assets embed.FS |
This file contains hidden or 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,12 @@ | ||
| //go:build mage | ||
| // +build mage | ||
|
|
||
| // This file is maintained by the plugin sdk tooling. | ||
| // Please do not make changes to this file. | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
| //mage:import | ||
| _ "github.com/mattermost/mattermost-plugin-legal-hold/pluginmage" | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not just delete this line?