Make WordPress Core

Opened 2 years ago

Closed 22 months ago

Last modified 3 months ago

#62416 closed enhancement (fixed)

Switch to using local references for reusable workflows

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

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 (10)

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


2 years ago
#1

  • Keywords has-patch added

​@johnbillion commented on ​PR #7796:


2 years 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:


2 years 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:


2 years 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:


2 years ago
#5

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

​@johnbillion commented on ​PR #7796:


22 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:


22 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:


22 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
22 months ago

  • Owner set to johnbillion
  • Resolution → fixed
  • Status new → 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

#10 @desrosj
3 months ago

In 63230:

Build/Test Tools: Change workflow file references back to local ones.

[63167] made several required post-branching changes to trunk, but also included the results of grunt replace:workflow-references-local-to-remote which is run as part of grunt post-branching.

All reusable workflow files in trunk should be called using local references so that changes to these files are automatically tested within pull requests without having to push the changes to a fork and change the references.

Props joedolson, wildworks.
Fixes #65844. See #62416.

Note: See TracTickets for help on using tickets.