Azure / Azure/azure-sdk-tools

Add a Condition parameter to save-package-properties.yml

Open Beginner friendly
#16,640 1 comment 0 reactions 0 assignees View on GitHub
EngSys
Dominant language
C#
Stars
135
Forks
258
Avg merge
1d 22h
Merged PRs (30d)
115

Description

`eng/common/pipelines/templates/steps/save-package-properties.yml` has no `Condition` parameter, so callers that only need it conditionally have no way to skip it.

## Why this matters

The established pattern in language repos is to call it twice in a build job: once before the daily-dev version is applied, and again afterwards to capture the updated version. The steps in between are gated on `SetDevVersion`, which `daily-dev-build-variable.yml` only sets to `true` when `Build.Reason == 'Schedule'` **and** `System.TeamProject == 'internal'`.

The second call has no such gate, so on every PR build it re-runs after nothing has changed.

This affects at least two repos:

**azure-sdk-for-js** — `eng/pipelines/templates/steps/build.yml` lines 23 and 55. Across 59 succeeded `js - pullrequest` builds (definition 7140), `Save package properties filtered for PR` appears exactly 118 times in the Build job — 2 per build — at a median of 29.6s. Roughly **30s per PR build**.

**azure-sdk-for-python** — `eng/pipelines/templates/steps/build-package-artifacts.yml` lines 91 and 102. In build 6647478 (`python - pullrequest`, definition 7050) it runs twice in each of three jobs:

| Job | durations | redundant |
|---|---|---|
| Build_Linux | 21.6s, 15.3s | 15.3s |
| Build_MacOS | 17.9s, 13.4s | 13.4s |
| Build_Windows | 58.0s, 21.2s | 21.2s |

Roughly **50s of agent time per PR build**.

I haven't checked .NET or Java, but both reference the template from `eng/pipelines`, so they may share the pattern.

## Proposed change

Add a `Condition` parameter and apply it to the tasks in both branches of the template:

```yaml
parameters:
- name: Condition
type: string
default: succeeded()
```

There is precedent for exactly this in sibling templates — `verify-readme.yml`, `verify-readmes.yml`, `verify-changelog.yml`, and `verify-changelogs.yml` all already take a `Condition` parameter.

Callers could then gate the second invocation on `eq(variables['SetDevVersion'], 'true')`.

A compile-time `${{ if }}` in the calling repo is not an option, because `SetDevVersion` is set at runtime by `daily-dev-build-variable.yml`.

## Follow-ups

Consuming repos need a small change once this lands; I'll link those issues here.

Filed by GitHub Copilot on behalf of @xirzec, from CI measurement work in azure-sdk-for-js#39482.

Contributor guide

Open the contributing guide

Research direction

Start with eng/common/pipelines/templates/steps/save-package-properties.yml and compare its parameter syntax with verify-readme.yml, verify-readmes.yml, verify-changelog.yml, and verify-changelogs.yml. Add the Condition parameter consistently to both template branches; done means callers can conditionally skip the second invocation while the default preserves current behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
yaml
Domain
ci-cd
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.