Make WordPress Core

Opened 7 months ago

Closed 5 months ago

#62416 closed enhancement (fixed)

Switch to using local references for reusable workflows

Reported by: johnbillion's profile johnbillion Owned by: johnbillion's profile johnbillion
Milestone: 6.8 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch
Focuses: Cc:

Description

Reusable workflows used within GitHub Actions are currently referenced using their remote syntax, eg:

uses: WordPress/wordpress-develop/{workflow}.yml@trunk

As these workflows are actually local files, their references can be updated to local ones:

uses: ./{workflow}.yml

The benefit of this is that when PRs are made to make changes to a reusable workflow, the references doesn't need to be updated to point to the fork in order for the changed workflow to run.

@desrosj flagged there might be a security concern with such a change. I don't believe there is, but it's worth double checking.

Change History (9)

This ticket was mentioned in PR #7796 on WordPress/wordpress-develop by @johnbillion.


7 months ago
#1

  • Keywords has-patch added

@johnbillion commented on PR #7796:


7 months ago
#2

@desrosj Another consideration. The current syntax means that workflows in older branches will always use the latest reusable workflow from the trunk branch. For example, the 6.4 branch uses the current workflow from trunk, not the workflow as it was at 6.4.

Is this a feature or a bug?

@desrosj commented on PR #7796:


7 months ago
#3

Ah, yes. This is absolutely a feature. We only need to update the workflow file once this way. See https://core.trac.wordpress.org/ticket/61213. Otherwise, we need to periodically backport fixes to all supported branches, and this is a large undertaking.

@desrosj commented on PR #7796:


7 months ago
#4

One way around this could be that after branching a release, we update all workflows to use the @trunk syntax instead. That allows trunk to use the local references for easier testing, but ensures the same benefits for older branches.

@johnbillion commented on PR #7796:


7 months ago
#5

That sounds reasonable. Would need to be added to the post release checklist.

@johnbillion commented on PR #7796:


5 months ago
#6

@desrosj I've added a command which converts all the local workflow references to remote ones. It can be run after trunk branches to the release branch to update all the references. What do you think?

npm run grunt replace:workflow-references-local-to-remote

@desrosj commented on PR #7796:


5 months ago
#7

@desrosj I've added a command which converts all the local workflow references to remote ones. It can be run after trunk branches to the release branch to update all the references. What do you think?

npm run grunt replace:workflow-references-local-to-remote

Good idea! Hadn't thought of that. I like it.

Would it be worth adding a step to each workflow that confirms the correct reference format based on the branch initiating the workflow run?

@johnbillion commented on PR #7796:


5 months ago
#8

Would it be worth adding a step to each workflow that confirms the correct reference format based on the branch initiating the workflow run?

Maybe! I think there's a few options for enforcing the remote reference in the release branches. Let's get this in and then it can be discussed in another ticket or PR.

#9 @johnbillion
5 months ago

  • Owner set to johnbillion
  • Resolution set to fixed
  • Status changed from new to closed

In 59673:

Build/Test Tools: Switch to using local references for reusable workflows.

The benefit of this is that when PRs are made to make changes to a reusable workflow, the references doesn't need to be updated to point to the fork in order for the changed workflow to run.

A npm run grunt replace:workflow-references-local-to-remote command has also been introduced in order to convert these local references back to remote ones. This command can be used to switch release branches over to using remote workflows, as they are currently, so they continue to benefit from workflow changes in trunk without the need for continual backporting to all the branches.

Props desrosj, johnbillion

Fixes #62416

Note: See TracTickets for help on using tickets.