[release-10.11] Automate setup-go-work as a dependency for Make targets (#35780)

* Automate setup-go-work as a dependency for Make targets (#35476)

* automate setup-go-work

It's all to easy to forget to `make setup-go-work`, only to run into mysterious build failures. Let's default to doing this automatically, unless `SKIP_SETUP_GO_WORK` is true (or the legacy `IGNORE_GO_WORK_IF_EXISTS`, which was oddly named, since we can't actually ignore it.)

* Make setup-go-work recipe fail-fast with set -e

* ci: post success to required e2e status contexts when no relevant changes (#35880)

* ci: post correct skip status from within cypress/playwright reusable workflows

The 'Required Status Checks' ruleset requires e2e-test/cypress-full/enterprise
and e2e-test/playwright-full/enterprise on master and release-*.* branches.
When a PR has no E2E-relevant changes, the jobs were silently skipped, leaving
required statuses unset and the PR permanently blocked.

Architecture fix: instead of a separate skip-e2e job in the caller that
hardcodes status context names, the skip logic now lives inside the reusable
workflows that already own and compute those context names.

Changes:
- e2e-tests-cypress.yml: add should_run input (default 'true') + skip job
  that uses the dynamically-computed context_name when should_run == 'false'
- e2e-tests-playwright.yml: same pattern
- e2e-tests-ci.yml: change e2e-cypress/e2e-playwright job conditions from
  should_run == 'true' to PR_NUMBER != '' (always run when there's a PR),
  pass should_run as input to both reusable workflows

* Add E2E template workflows for Cypress and Playwright

* Add check-e2e-test-only action for E2E workflow

* Fix: Remove circular E2E workflow file check - skip tests when only CI files change

* Add pull_request trigger to E2E workflow - run automatically on PR events

* Fix resolve-pr to use github.event context for automatic pull_request trigger

* Fix checkout condition to work with pull_request events

* Fix: Remove orphaned fi statement in check-changes script

---------

Co-authored-by: yasser khan <attitude3cena.yf@gmail.com>
Этот коммит содержится в:
Jesse Hallam
2026-04-02 10:45:24 -03:00
коммит произвёл GitHub
родитель 075d975ca7
Коммит 70d1794916
9 изменённых файлов: 1999 добавлений и 59 удалений

Просмотреть файл

@@ -218,7 +218,7 @@ ifneq ($(DOCKER_SERVICES_OVERRIDE),true)
ENABLED_DOCKER_SERVICES:=$(ENABLED_DOCKER_SERVICES) $(TEMP_DOCKER_SERVICES)
endif
start-docker: ## Starts the docker containers for local development.
start-docker: setup-go-work ## Starts the docker containers for local development.
ifneq ($(IS_CI),false)
@echo CI Build: skipping docker start
else ifeq ($(MM_NO_DOCKER),true)
@@ -238,7 +238,7 @@ else
endif
endif
update-docker: stop-docker ## Updates the docker containers for local development.
update-docker: setup-go-work stop-docker ## Updates the docker containers for local development.
@echo Updating docker containers
$(GO) run ./build/docker-compose-generator/main.go $(ENABLED_DOCKER_SERVICES) | docker compose -f docker-compose.makefile.yml -f /dev/stdin $(DOCKER_COMPOSE_OVERRIDE) up --no-start
@@ -273,7 +273,7 @@ else
docker compose rm -v
endif
plugin-checker:
plugin-checker: setup-go-work
$(GO) run $(GOFLAGS) ./public/plugin/checker
prepackaged-plugins: ## Populate the prepackaged-plugins directory.
@@ -298,7 +298,7 @@ golang-versions: ## Install Golang versions used for compatibility testing (e.g.
done
export GO_COMPATIBILITY_TEST_VERSIONS="${GO_COMPATIBILITY_TEST_VERSIONS}"
golangci-lint: ## Run golangci-lint on codebase
golangci-lint: setup-go-work ## Run golangci-lint on codebase
$(GO) install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6
ifeq ($(BUILD_ENTERPRISE_READY),true)
$(GOBIN)/golangci-lint run ./... ./public/... $(BUILD_ENTERPRISE_DIR)/...
@@ -315,11 +315,11 @@ i18n-check: ## Exit on empty translation strings and translation source strings
$(GOBIN)/mmgotool i18n clean-empty --portal-dir="" --check
$(GOBIN)/mmgotool i18n check-empty-src --portal-dir=""
store-mocks: ## Creates mock files.
store-mocks: setup-go-work ## Creates mock files.
$(GO) install github.com/vektra/mockery/v2/...@v2.53.4
$(GOBIN)/mockery --config channels/store/.mockery.yaml
cache-mocks:
cache-mocks: setup-go-work
$(GO) install github.com/vektra/mockery/v2/...@v2.53.4
$(GOBIN)/mockery --config platform/services/cache/.mockery.yaml
@@ -327,7 +327,7 @@ telemetry-mocks: ## Creates mock files.
$(GO) install github.com/vektra/mockery/v2/...@v2.53.4
$(GOBIN)/mockery --config platform/services/telemetry/.mockery.yaml
store-layers: ## Generate layers for the store
store-layers: setup-go-work ## Generate layers for the store
$(GO) generate $(GOFLAGS) ./channels/store
new-migration: ## Creates a new migration. Run with make new-migration name=<>
@@ -338,47 +338,47 @@ new-migration: ## Creates a new migration. Run with make new-migration name=<>
@echo "Generating new migration for postgres"
$(GOBIN)/morph new script $(name) --driver postgres --dir channels/db/migrations --sequence
filestore-mocks: ## Creates mock files.
filestore-mocks: setup-go-work ## Creates mock files.
$(GO) install github.com/vektra/mockery/v2/...@v2.53.4
$(GOBIN)/mockery --config platform/shared/filestore/.mockery.yaml
ldap-mocks: ## Creates mock files for ldap.
ldap-mocks: setup-go-work ## Creates mock files for ldap.
$(GO) install github.com/vektra/mockery/v2/...@v2.53.4
$(GOBIN)/mockery --dir $(BUILD_ENTERPRISE_DIR)/ldap --all --inpackage --note 'Regenerate this file using `make ldap-mocks`.'
plugin-mocks: ## Creates mock files for plugins.
plugin-mocks: setup-go-work ## Creates mock files for plugins.
$(GO) install github.com/vektra/mockery/v2/...@v2.53.4
$(GOBIN)/mockery --config public/plugin/.mockery.yaml
einterfaces-mocks: ## Creates mock files for einterfaces.
einterfaces-mocks: setup-go-work ## Creates mock files for einterfaces.
$(GO) install github.com/vektra/mockery/v2/...@v2.53.4
$(GOBIN)/mockery --config einterfaces/.mockery.yaml
searchengine-mocks: ## Creates mock files for searchengines.
searchengine-mocks: setup-go-work ## Creates mock files for searchengines.
$(GO) install github.com/vektra/mockery/v2/...@v2.53.4
$(GOBIN)/mockery --config platform/services/searchengine/.mockery.yaml
sharedchannel-mocks: ## Creates mock files for shared channels.
sharedchannel-mocks: setup-go-work ## Creates mock files for shared channels.
$(GO) install github.com/vektra/mockery/v2/...@v2.53.4
$(GOBIN)/mockery --config platform/services/sharedchannel/.mockery.yaml
misc-mocks: ## Creates mocks for misc interfaces.
misc-mocks: setup-go-work ## Creates mocks for misc interfaces.
$(GO) install github.com/vektra/mockery/v2/...@v2.53.4
$(GOBIN)/mockery --config channels/utils/.mockery.yaml
email-mocks: ## Creates mocks for misc interfaces.
email-mocks: setup-go-work ## Creates mocks for misc interfaces.
$(GO) install github.com/vektra/mockery/v2/...@v2.53.4
$(GOBIN)/mockery --config channels/app/email/.mockery.yaml
platform-mocks: ## Creates mocks for platform interfaces.
platform-mocks: setup-go-work ## Creates mocks for platform interfaces.
$(GO) install github.com/vektra/mockery/v2/...@v2.53.4
$(GOBIN)/mockery --config channels/app/platform/.mockery.yaml
mmctl-mocks: ## Creates mocks for mmctl
mmctl-mocks: setup-go-work ## Creates mocks for mmctl
$(GO) install github.com/golang/mock/mockgen@v1.6.0
$(GOBIN)/mockgen -destination=cmd/mmctl/mocks/client_mock.go -copyright_file=cmd/mmctl/mocks/copyright.txt -package=mocks github.com/mattermost/mattermost/server/v8/cmd/mmctl/client Client
pluginapi: ## Generates api and hooks glue code for plugins
pluginapi: setup-go-work ## Generates api and hooks glue code for plugins
cd ./public && $(GO) generate $(GOFLAGS) ./plugin
mocks: store-mocks telemetry-mocks filestore-mocks ldap-mocks plugin-mocks einterfaces-mocks searchengine-mocks sharedchannel-mocks misc-mocks email-mocks platform-mocks mmctl-mocks mocks-public cache-mocks
@@ -394,15 +394,22 @@ endif
setup-go-work: export BUILD_ENTERPRISE_READY := $(BUILD_ENTERPRISE_READY)
setup-go-work: ## Sets up your go.work file
ifneq ($(IGNORE_GO_WORK_IF_EXISTS),true)
@echo "Creating a go.work file"
rm -f go.work
$(GO) work init
$(GO) work use .
$(GO) work use ./public
ifeq ($(BUILD_ENTERPRISE_READY),true)
$(GO) work use $(BUILD_ENTERPRISE_DIR)
endif
ifneq ($(SKIP_SETUP_GO_WORK),true)
@set -e; \
if [ -f go.work ]; then cp -p go.work go.work.bak; fi; \
rm -f go.work; \
$(GO) work init; \
$(GO) work use .; \
$(GO) work use ./public; \
if [ "$(BUILD_ENTERPRISE_READY)" = "true" ]; then \
$(GO) work use $(BUILD_ENTERPRISE_DIR); \
fi; \
if [ -f go.work.bak ] && cmp -s go.work go.work.bak; then \
mv go.work.bak go.work; \
else \
rm -f go.work.bak; \
echo "Created go.work file"; \
fi
endif
check-style: plugin-checker vet golangci-lint ## Runs style/lint checks
@@ -410,7 +417,7 @@ check-style: plugin-checker vet golangci-lint ## Runs style/lint checks
gotestsum:
$(GO) install gotest.tools/gotestsum@v1.11.0
test-compile: gotestsum ## Compile tests.
test-compile: setup-go-work gotestsum ## Compile tests.
@echo COMPILE TESTS
for package in $(TE_PACKAGES) $(EE_PACKAGES); do \
@@ -481,10 +488,10 @@ else
$(GOBIN)/gotestsum --packages="$(TE_PACKAGES)" -- $(GOFLAGS) -short
endif
internal-test-web-client: ## Runs web client tests.
internal-test-web-client: setup-go-work ## Runs web client tests.
$(GO) run $(GOFLAGS) $(PLATFORM_FILES) test web_client_tests
run-server-for-web-client-tests: ## Tests the server for web client.
run-server-for-web-client-tests: setup-go-work ## Tests the server for web client.
$(GO) run $(GOFLAGS) $(PLATFORM_FILES) test web_client_tests_server
test-client: ## Test client app.
@@ -566,7 +573,7 @@ run-server: setup-go-work prepackaged-binaries validate-go-version start-docker
mkdir -p $(BUILD_WEBAPP_DIR)/channels/dist/files
$(GO) run $(GOFLAGS) -ldflags '$(LDFLAGS)' -tags '$(BUILD_TAGS)' $(PLATFORM_FILES) $(RUN_IN_BACKGROUND)
debug-server: start-docker ## Compile and start server using delve.
debug-server: setup-go-work start-docker ## Compile and start server using delve.
mkdir -p $(BUILD_WEBAPP_DIR)/channels/dist/files
$(DELVE) debug $(PLATFORM_FILES) --build-flags="-ldflags '\
-X github.com/mattermost/mattermost/server/public/model.BuildNumber=$(BUILD_NUMBER)\
@@ -576,7 +583,7 @@ debug-server: start-docker ## Compile and start server using delve.
-X github.com/mattermost/mattermost/server/public/model.BuildEnterpriseReady=$(BUILD_ENTERPRISE_READY)'\
-tags '$(BUILD_TAGS)'"
debug-server-headless: start-docker ## Debug server from within an IDE like VSCode or IntelliJ.
debug-server-headless: setup-go-work start-docker ## Debug server from within an IDE like VSCode or IntelliJ.
mkdir -p $(BUILD_WEBAPP_DIR)/channels/dist/files
$(DELVE) debug --headless --listen=:2345 --api-version=2 --accept-multiclient $(PLATFORM_FILES) --build-flags="-ldflags '\
-X github.com/mattermost/mattermost/server/public/model.BuildNumber=$(BUILD_NUMBER)\
@@ -593,12 +600,12 @@ run-node: export MM_SERVICESETTINGS_LOCALMODESOCKETLOCATION=/var/tmp/mattermost_
run-node: export MM_SQLSETTINGS_DRIVERNAME=postgres
run-node: export MM_SQLSETTINGS_DATASOURCE=postgres://mmuser:mostest@localhost/mattermost_node_test?sslmode=disable&sslmode=disable&connect_timeout=10&binary_parameters=yes
run-node: start-docker ## Runs a shared channel node.
run-node: setup-go-work start-docker ## Runs a shared channel node.
@echo Running mattermost node
$(GO) run $(GOFLAGS) -ldflags '$(LDFLAGS)' -tags '$(BUILD_TAGS)' $(PLATFORM_FILES) $(RUN_IN_BACKGROUND)
run-cli: start-docker ## Runs CLI.
run-cli: setup-go-work start-docker ## Runs CLI.
@echo Running mattermost for development
@echo Example should be like 'make ARGS="-version" run-cli'
@@ -660,7 +667,7 @@ restart-haserver:
restart-client: | stop-client run-client ## Restarts the webapp.
run-job-server: ## Runs the background job server.
run-job-server: setup-go-work ## Runs the background job server.
@echo Running job server for development
$(GO) run $(GOFLAGS) -ldflags '$(LDFLAGS)' -tags '$(BUILD_TAGS)' $(PLATFORM_FILES) jobserver &
@@ -701,7 +708,7 @@ config-openid: ## Configures OpenID.
@echo Finished setting up configuration for local OpenID with keycloak
config-reset: ## Resets the config/config.json file to the default production values.
config-reset: setup-go-work ## Resets the config/config.json file to the default production values.
@echo Resetting configuration to production default
rm -f config/config.json
OUTPUT_CONFIG=$(PWD)/config/config.json $(GO) $(GOFLAGS) run -tags production ./scripts/config_generator
@@ -709,7 +716,7 @@ config-reset: ## Resets the config/config.json file to the default production va
diff-config: ## Compares default configuration between two mattermost versions
@./scripts/diff-config.sh
clean: stop-docker ## Clean up everything except persistent server data.
clean: setup-go-work stop-docker ## Clean up everything except persistent server data.
@echo Cleaning
rm -Rf $(DIST_ROOT)
@@ -758,7 +765,7 @@ ifeq ($(BUILD_ENTERPRISE_READY),true)
mv enterprise/external_imports.go.orig enterprise/external_imports.go
endif
vet: ## Run mattermost go vet specific checks
vet: setup-go-work ## Run mattermost go vet specific checks
## Note that it is pinned to a specific commit, rather than a branch. This is to prevent
## having to backport the fix to multiple release branches for any new change.
$(GO) install github.com/mattermost/mattermost-govet/v2@8e4d46e3fad88497dbfe073788a87e75bbae717c
@@ -778,7 +785,7 @@ vet-api: ## Run mattermost go vet to verify api4 documentation, currently not pa
./scripts/vet-api-check.sh
gen-serialized: export LICENSE_HEADER:=$(LICENSE_HEADER)
gen-serialized: ## Generates serialization methods for hot structs
gen-serialized: setup-go-work ## Generates serialization methods for hot structs
# This tool only works at a file level, not at a package level.
# There will be some warnings about "unresolved identifiers",
# but that is because of the above problem. Since we are generating
@@ -810,10 +817,10 @@ ifeq ($(BUILD_ENTERPRISE_READY),true)
@! ag --ignore Makefile --ignore-dir runtime '(TODO|XXX|FIXME|"FIX ME")[: ]+' $(BUILD_ENTERPRISE_DIR)/
endif
mmctl-build: ## Compiles and generates the mmctl binary
mmctl-build: setup-go-work ## Compiles and generates the mmctl binary
go build -trimpath -ldflags '$(MMCTL_LDFLAGS)' -o bin/mmctl ./cmd/mmctl
mmctl-docs: ## Generate the mmctl docs
mmctl-docs: setup-go-work ## Generate the mmctl docs
rm -rf ./cmd/mmctl/docs
cd ./cmd/mmctl && go run mmctl.go docs
@@ -858,5 +865,5 @@ test-migration:
# we also exlude systems table temporarily due to adding some keys while running the initial migration
bin/dbcmp --source "${MYSQL_DSN}" --target "${POSTGRES_DSN}" --exclude="db_migrations","ir_","focalboard","systems","attributeview"
test-local-filestore: # Run tests for local filestore
test-local-filestore: setup-go-work # Run tests for local filestore
$(GO) test ./platform/shared/filestore -run '^TestLocalFileBackend' -v

Просмотреть файл

@@ -2,7 +2,7 @@ dist: | check-style test package
build-linux: build-linux-amd64 build-linux-arm64
build-linux-amd64:
build-linux-amd64: setup-go-work
@echo Build Linux amd64
ifeq ($(BUILDER_GOOS_GOARCH),"linux_amd64")
env GOOS=linux GOARCH=amd64 $(GO) build -o $(GOBIN) $(GOFLAGS) -trimpath -tags '$(BUILD_TAGS) production' -ldflags '$(LDFLAGS)' ./...
@@ -11,7 +11,7 @@ else
env GOOS=linux GOARCH=amd64 $(GO) build -o $(GOBIN)/linux_amd64 $(GOFLAGS) -trimpath -tags '$(BUILD_TAGS) production' -ldflags '$(LDFLAGS)' ./...
endif
build-linux-arm64:
build-linux-arm64: setup-go-work
@echo Build Linux arm64
ifeq ($(BUILDER_GOOS_GOARCH),"linux_arm64")
env GOOS=linux GOARCH=arm64 $(GO) build -o $(GOBIN) $(GOFLAGS) -trimpath -tags '$(BUILD_TAGS) production' -ldflags '$(LDFLAGS)' ./...
@@ -20,7 +20,7 @@ else
env GOOS=linux GOARCH=arm64 $(GO) build -o $(GOBIN)/linux_arm64 $(GOFLAGS) -trimpath -tags '$(BUILD_TAGS) production' -ldflags '$(LDFLAGS)' ./...
endif
build-osx:
build-osx: setup-go-work
@echo Build OSX amd64
ifeq ($(BUILDER_GOOS_GOARCH),"darwin_amd64")
env GOOS=darwin GOARCH=amd64 $(GO) build -o $(GOBIN) $(GOFLAGS) -trimpath -tags '$(BUILD_TAGS) production' -ldflags '$(LDFLAGS)' ./...
@@ -36,7 +36,7 @@ else
env GOOS=darwin GOARCH=arm64 $(GO) build -o $(GOBIN)/darwin_arm64 $(GOFLAGS) -trimpath -tags '$(BUILD_TAGS) production' -ldflags '$(LDFLAGS)' ./...
endif
build-windows:
build-windows: setup-go-work
@echo Build Windows amd64
ifeq ($(BUILDER_GOOS_GOARCH),"windows_amd64")
env GOOS=windows GOARCH=amd64 $(GO) build -o $(GOBIN) $(GOFLAGS) -trimpath -tags '$(BUILD_TAGS) production' -ldflags '$(LDFLAGS)' ./...
@@ -45,7 +45,7 @@ else
env GOOS=windows GOARCH=amd64 $(GO) build -o $(GOBIN)/windows_amd64 $(GOFLAGS) -trimpath -tags '$(BUILD_TAGS) production' -ldflags '$(LDFLAGS)' ./...
endif
build-cmd-linux:
build-cmd-linux: setup-go-work
@echo Build CMD Linux amd64
ifeq ($(BUILDER_GOOS_GOARCH),"linux_amd64")
env GOOS=linux GOARCH=amd64 $(GO) build -o $(GOBIN) $(GOFLAGS) -trimpath -tags '$(BUILD_TAGS) production' -ldflags '$(LDFLAGS)' ./cmd/...
@@ -61,7 +61,7 @@ else
env GOOS=linux GOARCH=arm64 $(GO) build -o $(GOBIN)/linux_arm64 $(GOFLAGS) -trimpath -tags '$(BUILD_TAGS) production' -ldflags '$(LDFLAGS)' ./cmd/...
endif
build-cmd-osx:
build-cmd-osx: setup-go-work
@echo Build CMD OSX amd64
ifeq ($(BUILDER_GOOS_GOARCH),"darwin_amd64")
env GOOS=darwin GOARCH=amd64 $(GO) build -o $(GOBIN) $(GOFLAGS) -trimpath -tags '$(BUILD_TAGS) production' -ldflags '$(LDFLAGS)' ./cmd/...
@@ -77,7 +77,7 @@ else
env GOOS=darwin GOARCH=arm64 $(GO) build -o $(GOBIN)/darwin_arm64 $(GOFLAGS) -trimpath -tags '$(BUILD_TAGS) production' -ldflags '$(LDFLAGS)' ./cmd/...
endif
build-cmd-windows:
build-cmd-windows: setup-go-work
@echo Build CMD Windows amd64
ifeq ($(BUILDER_GOOS_GOARCH),"windows_amd64")
env GOOS=windows GOARCH=amd64 $(GO) build -o $(GOBIN) $(GOFLAGS) -trimpath -tags '$(BUILD_TAGS) production' -ldflags '$(LDFLAGS)' ./cmd/...
@@ -97,7 +97,7 @@ build-client:
cd $(BUILD_WEBAPP_DIR) && $(MAKE) dist
package-prep:
package-prep: setup-go-work
@ echo Packaging mattermost
@# Remove any old files
rm -Rf $(DIST_ROOT)

Просмотреть файл

@@ -26,3 +26,10 @@ LDAP_DATA ?= test
# Mock the CWS.
MM_ENABLE_CWS_MOCK ?= false
# Skip running setup-go-work automatically.
# IGNORE_GO_WORK_IF_EXISTS is supported for backwards compatibility.
ifdef IGNORE_GO_WORK_IF_EXISTS
SKIP_SETUP_GO_WORK ?= $(IGNORE_GO_WORK_IF_EXISTS)
endif
SKIP_SETUP_GO_WORK ?= false