Skip to content

Apply concurrency control to swift-package-test, cancelling previously running workflows of the same kind #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

TTOzzi
Copy link
Member

@TTOzzi TTOzzi commented Apr 4, 2025

Hello! 👋
This change is derived from swiftlang/swift-format#976.
It adds concurrency control to ensure that only one active workflow is running per pull request, preventing duplicate workflow executions for open PRs.

@TTOzzi TTOzzi requested a review from a team as a code owner April 4, 2025 11:16
@TTOzzi
Copy link
Member Author

TTOzzi commented Apr 4, 2025

It seems that in workflows like this one, where multiple swift_package_test jobs are executed, they share the same concurrency group ID, which causes them to cancel each other 🤔

@TTOzzi TTOzzi force-pushed the concurrency-control branch from 56197f1 to 8151a1e Compare April 4, 2025 12:12
@TTOzzi TTOzzi marked this pull request as draft April 4, 2025 12:16
@TTOzzi
Copy link
Member Author

TTOzzi commented Apr 4, 2025

Currently, when the swift_package_test workflow is used by multiple jobs within a parent workflow, it cannot access information about the specific job that called it. As a result, the concurrency group ID becomes the same across jobs, causing them to be treated as duplicates and canceled.

I’ve tried several approaches based on GitHub’s documentation, but so far, it seems the only way to avoid this is to explicitly pass a unique identifier from each job in the parent workflow to the swift_package_test.

However, requiring such an ID as an input parameter would affect all existing workflows that use swift_package_test, essentially defeating the purpose by shifting the concurrency logic back to each individual job.

@TTOzzi
Copy link
Member Author

TTOzzi commented Apr 4, 2025

As long as there are cases where swift_package_test is called from multiple jobs within the same workflow, it seems difficult to handle concurrency in a centralized way 😞
I'll go back to the original PR.

@TTOzzi TTOzzi closed this Apr 4, 2025
@@ -65,6 +65,11 @@ on:
description: "Boolean to enable providing the GITHUB_TOKEN to downstream job."
default: false

## We are cancelling previously triggered workflow runs
concurrency:
group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }}-package-test
Copy link
Member Author

Choose a reason for hiding this comment

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

While I could tell which PR it was and whether it was the linux-build or windows-build job inside swift_package_test, there was no way — using only the information available within swift_package_test — to determine whether it was triggered from tests_with_docker or tests_without_docker in the parent workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant