Skip to content

Convert Makefile to magefile.go#4912

Merged
michel-laterman merged 45 commits intoelastic:mainfrom
michel-laterman:magefile
May 28, 2025
Merged

Convert Makefile to magefile.go#4912
michel-laterman merged 45 commits intoelastic:mainfrom
michel-laterman:magefile

Conversation

@michel-laterman
Copy link
Copy Markdown
Contributor

@michel-laterman michel-laterman commented May 13, 2025

What is the problem this PR solves?

The Makefile has reached a point where it is becoming difficult to understand and add new features/targets.

How does this PR solve the problem?

Reimplement Makefile targets in mage.
Change buildkite pipeline to use mage.
Change Dockerfile* to use mage.

Added bonuses:

  • Support for producing NOTICE-FIPS.txt
    • NOTICE files only contain modules used in shipped binaries.
  • cloudE2E testing is functional
  • Minor increase in parallel execution for targets.
  • env only settings controls
    • target doc strings contain env var usage info
  • conditional linter installation
  • integration/e2e test token reuse
  • improved release testing (archive structure, non-zero len binaries, fips capable indicators if FIPS=true)
  • reimplemented bash scripts in dev-tools for mage, removed unused scripts.

How to test this PR locally

mage -l

See doc strings for targets with mage -h TARGET i.e.:

mage -h build:binary
Binary builds release binaries for the specified platforms. PLATFORMS may be used to set os/arch for compiled binaries. DEV creates a development build. SNAPSHOT creates a snapshot build. FIPS creates a FIPS capable binary. VERSION_QUALIFIER may be used to manually specify a version qualifer for the produced binary.

Usage:

	mage build:binary

@michel-laterman michel-laterman added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label May 13, 2025
@michel-laterman michel-laterman requested a review from a team as a code owner May 13, 2025 01:58
@michel-laterman michel-laterman marked this pull request as draft May 13, 2025 01:58
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented May 13, 2025

This pull request does not have a backport label. Could you fix it @michel-laterman? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-./d./d is the label to automatically backport to the 8./d branch. /d is the digit
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.

@michel-laterman michel-laterman force-pushed the magefile branch 5 times, most recently from 10f999f to f4667d8 Compare May 14, 2025 17:40
@prodsecmachine
Copy link
Copy Markdown

prodsecmachine commented May 14, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@michel-laterman michel-laterman force-pushed the magefile branch 2 times, most recently from f1bf64d to e841377 Compare May 14, 2025 18:00
@michel-laterman michel-laterman added the backport-8.19 Automated backport to the 8.19 branch label May 14, 2025
@michel-laterman michel-laterman force-pushed the magefile branch 2 times, most recently from 1e8020d to 7196699 Compare May 14, 2025 20:00
@michel-laterman
Copy link
Copy Markdown
Contributor Author

michel-laterman commented May 14, 2025

I wasn't able to get some targets that use docker working locally, specifically:

  • docker:binary
  • docker:cover
  • docker:release

I also did not have the time to verify test:e2e or ~test:cloudE2E~.

EDIT: docker:* targets worked, the issue was that the docker container would oom when building all artifacts in parallel; to fix this i made them build serially.
test:e2e also works.
test:cloudE2E works in buildkite now!

@michel-laterman michel-laterman force-pushed the magefile branch 2 times, most recently from 490eac3 to 81c0480 Compare May 14, 2025 20:55
Re-implement all used targets in Makefile in mage. Move most utility
scripts into magefile. Change buildkite to use mage.
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented May 19, 2025

This pull request is now in conflicts. Could you fix it @michel-laterman? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b magefile upstream/magefile
git merge upstream/main
git push upstream magefile

@michel-laterman michel-laterman enabled auto-merge (squash) May 28, 2025 00:10
michalpristas
michalpristas previously approved these changes May 28, 2025
@michalpristas
Copy link
Copy Markdown
Contributor

looks like some notice conflicts that needs to be solved. other than that looks good

@elastic-sonarqube
Copy link
Copy Markdown

@michel-laterman michel-laterman merged commit db5f46b into elastic:main May 28, 2025
9 checks passed
mergify bot pushed a commit that referenced this pull request May 28, 2025
Reimplement Makefile targets in mage.
Change buildkite pipeline to use mage.
Change Dockerfile* to use mage.

(cherry picked from commit db5f46b)

# Conflicts:
#	Dockerfile.build
#	Dockerfile.fips
#	Makefile
#	NOTICE.txt
#	README.md
#	dev-tools/go.mod
#	dev-tools/go.sum
#	docs/developers-guide.md
#	docs/docker-images.md
@michel-laterman michel-laterman deleted the magefile branch May 28, 2025 15:56
michel-laterman added a commit that referenced this pull request May 28, 2025
* Convert Makefile to magefile.go (#4912)

Reimplement Makefile targets in mage.
Change buildkite pipeline to use mage.
Change Dockerfile* to use mage.

(cherry picked from commit db5f46b)

# Conflicts:
#	Dockerfile.build
#	Dockerfile.fips
#	Makefile
#	NOTICE.txt
#	README.md
#	dev-tools/go.mod
#	dev-tools/go.sum
#	docs/developers-guide.md
#	docs/docker-images.md

* Clean up backport

* Delete .terraform.lock.hcl

* Fix check:ci

* Fix imports

---------

Co-authored-by: Michel Laterman <82832767+michel-laterman@users.noreply.github.com>
Co-authored-by: michel-laterman <michel.laterman@elastic.co>
@michel-laterman michel-laterman added backport-8.18 Automated backport to the 8.18 branch backport-9.0 Automated backport to the 9.0 branch labels Sep 3, 2025
mergify bot pushed a commit that referenced this pull request Sep 3, 2025
Reimplement Makefile targets in mage.
Change buildkite pipeline to use mage.
Change Dockerfile* to use mage.

(cherry picked from commit db5f46b)

# Conflicts:
#	.buildkite/pipeline.yml
#	.buildkite/scripts/common.sh
#	.buildkite/scripts/local_build.sh
#	.buildkite/scripts/test-release.sh
#	Dockerfile.build
#	Dockerfile.fips
#	Makefile
#	NOTICE.txt
#	README.md
#	dev-tools/cloud/Makefile
#	dev-tools/cloud/terraform/main.tf
#	dev-tools/e2e/Dockerfile
#	dev-tools/e2e/build.sh
#	dev-tools/e2e/validatecerts.go
#	dev-tools/go.mod
#	dev-tools/go.sum
#	docs/developers-guide.md
#	docs/docker-images.md
#	docs/fips.md
#	testing/e2e/fips_test.go
mergify bot pushed a commit that referenced this pull request Sep 3, 2025
Reimplement Makefile targets in mage.
Change buildkite pipeline to use mage.
Change Dockerfile* to use mage.

(cherry picked from commit db5f46b)

# Conflicts:
#	.buildkite/pipeline.yml
#	.buildkite/scripts/common.sh
#	.buildkite/scripts/local_build.sh
#	.buildkite/scripts/test-release.sh
#	.buildkite/scripts/unit_test.sh
#	Dockerfile.fips
#	Makefile
#	NOTICE.txt
#	dev-tools/cloud/Makefile
#	dev-tools/cloud/terraform/main.tf
#	dev-tools/e2e/Dockerfile
#	dev-tools/e2e/build.sh
#	dev-tools/e2e/validatecerts.go
#	dev-tools/go.mod
#	dev-tools/go.sum
#	docs/fips.md
#	testing/e2e/fips_test.go
michel-laterman added a commit to michel-laterman/fleet-server that referenced this pull request Sep 3, 2025
Reimplement Makefile targets in mage.
Change buildkite pipeline to use mage.
Change Dockerfile* to use mage.

(cherry picked from commit db5f46b)

# Conflicts:
#	.buildkite/pipeline.yml
#	.buildkite/scripts/common.sh
#	.buildkite/scripts/local_build.sh
#	.buildkite/scripts/test-release.sh
#	Dockerfile.build
#	Dockerfile.fips
#	Makefile
#	NOTICE.txt
#	README.md
#	dev-tools/cloud/Makefile
#	dev-tools/cloud/terraform/main.tf
#	dev-tools/e2e/Dockerfile
#	dev-tools/e2e/build.sh
#	dev-tools/e2e/validatecerts.go
#	dev-tools/go.mod
#	dev-tools/go.sum
#	docs/developers-guide.md
#	docs/docker-images.md
#	docs/fips.md
#	testing/e2e/fips_test.go
michel-laterman added a commit to michel-laterman/fleet-server that referenced this pull request Sep 4, 2025
Reimplement Makefile targets in mage.
Change buildkite pipeline to use mage.
Change Dockerfile* to use mage.
michel-laterman added a commit to michel-laterman/fleet-server that referenced this pull request Sep 4, 2025
Reimplement Makefile targets in mage.
Change buildkite pipeline to use mage.
Change Dockerfile* to use mage.
michel-laterman added a commit that referenced this pull request Sep 24, 2025
Backport PRs #4912 #4985 #5000 #5075 to 9.0 so that mage is used instead of Make.
Do additional cleanup so FIPS references have been removed.
Chane Buildkite to use plugins.
michel-laterman added a commit that referenced this pull request Sep 24, 2025
* Convert Makefile to magefile.go (#4912)

Reimplement Makefile targets in mage.
Change buildkite pipeline to use mage.
Change Dockerfile* to use mage.

(cherry picked from commit db5f46b)

# Conflicts:
#	.buildkite/pipeline.yml
#	.buildkite/scripts/common.sh
#	.buildkite/scripts/local_build.sh
#	.buildkite/scripts/test-release.sh
#	Dockerfile.build
#	Dockerfile.fips
#	Makefile
#	NOTICE.txt
#	README.md
#	dev-tools/cloud/Makefile
#	dev-tools/cloud/terraform/main.tf
#	dev-tools/e2e/Dockerfile
#	dev-tools/e2e/build.sh
#	dev-tools/e2e/validatecerts.go
#	dev-tools/go.mod
#	dev-tools/go.sum
#	docs/developers-guide.md
#	docs/docker-images.md
#	docs/fips.md
#	testing/e2e/fips_test.go

* Ensure directory is made within zip artifacts (#4985)

* Ensure directory is made within zip artifacts

* Make test:release extraction stricter

* Fail cloude2e step if tests can't run, fix image publication (#5000)

Fail the pipeline if cloude2e tests can't run.
mage docker:image now uses the DOCKER_IMAGE env var.

* Add multiplatform images (#5075)

Fixes issue where change from make to mage, result in the loss of creating multiple platform images.

* Fix cherry-picks

* change to serialdeps

* Use magefile from main

* Remove FIPS references, use docker plugin

* Use bk plugins

* cleanup go.mod in dev-tools and pkg/api

* Add missing EC secret to cloud e2e step

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

Labels

backport-8.18 Automated backport to the 8.18 branch backport-8.19 Automated backport to the 8.19 branch backport-9.0 Automated backport to the 9.0 branch Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team tech debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants