Skip to content

feat: mage package for plugins#31424

Closed
fmartingr wants to merge 2 commits intomasterfrom
feat/pluginmage
Closed

feat: mage package for plugins#31424
fmartingr wants to merge 2 commits intomasterfrom
feat/pluginmage

Conversation

@fmartingr
Copy link
Copy Markdown
Contributor

Summary

  • Adds a pluginmage package that can be used from plugins to maintain the toolkit up to date.
  • Make targets migrated: server, proceesor, webapp, webapp/node_modules, deploy, dist, bundle, watch
  • Makefile now calls mage on the migrated targets.
  • PluginCTL logic has been migrated to mage directly by calling mage pluginctl:(command) and it's available to other targets as well.

Improvements

  • Can run dependendant targets in parallel (server and webapp for a build).
  • Friendly error codes for checks (do you have Go? Do you have NPM? Do you have GNU's Tar?) with links to documentation
  • Allow the plugin developers to specify other binaries to be built in their magefiles, there's an example in this plugin with the processor.
  • Common asset management for plugins is centralized. No more copying and pasting configuration for the editor, golangci lint, github workflows, ...

pluginmage

All logic is bundled to this package which is the one we can move to the public package in the mattermost server for distribution.

$ mage
Targets:
  build:additionalBinaries    builds all additional binaries if set up by the plugin developers
  build:all                   builds both server, additional binaries, and webapp
  build:bundle                creates a distributable bundle of the plugin
  build:server                Build builds the server if it exists
  build:webapp                Build builds the webapp if it exists
  deploy:upload               builds and installs the plugin to a server
  dummy                       prints a hello message and plugin info
  pluginctl:deploy            uploads and enables a plugin via the Client4 API
  pluginctl:disable           disables a plugin via the Client4 API
  pluginctl:enable            enables a plugin via the Client4 API
  pluginctl:reset             disables and re-enables a plugin via the Client4 API
  webapp:dependencies         installs webapp dependencies using npm
  webapp:watch                builds and watches the webapp for changes, rebuilding automatically

Check the included README.md in the package.

Requires mattermost/actions-workflows#53

Ticket Link

Screenshots

--

Release Note

Adds new package with plugin tooling

@fmartingr fmartingr self-assigned this Jun 13, 2025
@mm-cloud-bot mm-cloud-bot added kind/feature Categorizes issue or PR as related to a new feature. release-note-none Denotes a PR that doesn't merit a release note. labels Jun 13, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jun 13, 2025

⚠️ One or more flaky tests detected ⚠️

TestRetries
Postgres with binary parameters (Results)
com/mattermost/mattermost/server/v8/enterprise/message_export.TestRunExportJobE2EByType/using_dedicated_export_filestore/actiance_e2e_3_-_test_create,_update,_delete_xml_fields1
com/mattermost/mattermost/server/v8/enterprise/message_export.TestRunExportJobE2EByType/using_dedicated_export_filestore1
com/mattermost/mattermost/server/v8/enterprise/message_export.TestRunExportJobE2EByType1

OutputPath: "./server/dist",
Environment: map[string]string{
"CGO_ENABLED": "0",
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

question: If I don't like the defaults here for my use case (maybe I need to target a different platform or I need to enable CGO), how can I make changes? Previously, this configuration lived in each separate repository and the configuration could be modified directly. Now it lives in a unified repository that I may not have access to.

Would I need to fork the entire monorepo, make changes, and point to that? Or is there a simpler way to handle that scenario?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The idea of this is implement the basic functionality and then keep migrating plugins adopting and improving the toolkit. For example, we already support building additional binaries (coming from the legal-hold plugin which requires the processor to be built alongside the plugin) so things could be added as we work with it.

Checking the code I see that I'm handling the CGO in two different places. If I just remove the line you mention the defaults of the build configuration will allow GCO to be enabled if the env var CGO_ENABLED is set.

Do you have an example plugin where this is happening or more environment variables are required?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The idea of this is implement the basic functionality [...]

That makes sense. Though when real users start pulling this in to build plugins, I'm worried that it won't be configurable enough to meet their needs. Should we have some consistent way to "configure" common aspects of the build that could be different?

Another example: targeting a different platform or architecture. From what I understand, we only build Linux binaries with this implementation (unless in developer mode).

@fmartingr
Copy link
Copy Markdown
Contributor Author

@fmartingr fmartingr closed this Sep 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature. release-note-none Denotes a PR that doesn't merit a release note.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants