-
-
Notifications
You must be signed in to change notification settings - Fork 628
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
include in
generate_github_workflows.py
- Loading branch information
Showing
2 changed files
with
73 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
name: PR Validation | ||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- reopened | ||
- labeled | ||
- unlabeled | ||
# GENERATED, DO NOT EDIT! | ||
# To change, edit `src/python/pants_release/generate_github_workflows.py` and run: | ||
# ./pants run src/python/pants_release/generate_github_workflows.py | ||
|
||
|
||
jobs: | ||
check_labels: | ||
if: github.repository_owner == 'pantsbuild' | ||
name: Ensure PR has a category label | ||
runs-on: | ||
- ubuntu-20.04 | ||
runs_on: | ||
- ubuntu-latest | ||
steps: | ||
- env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
name: Ensure category label | ||
uses: mheap/[email protected] | ||
with: | ||
count: 1 | ||
labels: category:new feature, category:user api change, category:plugin api change, category:performance, category:bugfix, | ||
category:documentation, category:internal | ||
labels: category:new feature, category:user api change, category:plugin api | ||
change, category:performance, category:bugfix, category:documentation, category:internal | ||
mode: exactly | ||
name: PR Validation | ||
'on': | ||
pull_request: | ||
types: | ||
- opened | ||
- reopened | ||
- labeled | ||
- unlabeled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ | |
import yaml | ||
from pants_release.common import die | ||
|
||
from pants.util.strutil import softwrap | ||
|
||
HEADER = dedent( | ||
"""\ | ||
# GENERATED, DO NOT EDIT! | ||
|
@@ -1524,6 +1526,41 @@ def gen_goals(use_default_version: bool) -> Sequence[object]: | |
return PublicReposOutput(jobs=jobs, inputs=inputs, run_name=run_name) | ||
|
||
|
||
@dataclass | ||
class CheckLabelsOutput: | ||
jobs: Jobs | ||
|
||
|
||
def check_labels() -> CheckLabelsOutput: | ||
steps = [ | ||
{ | ||
"name": "Ensure category label", | ||
"env": {"GITHUB_TOKEN": gha_expr("secrets.GITHUB_TOKEN")}, | ||
"uses": "mheap/[email protected]", | ||
"with": { | ||
"count": 1, | ||
"labels": softwrap( | ||
""" | ||
category:new feature, category:user api change, | ||
category:plugin api change, category:performance, category:bugfix, | ||
category:documentation, category:internal | ||
""" | ||
), | ||
"mode": "exactly", | ||
}, | ||
} | ||
] | ||
|
||
job = { | ||
"name": "Ensure PR has a category label", | ||
"if": IS_PANTS_OWNER, | ||
"runs_on": ["ubuntu-latest"], | ||
"steps": steps, | ||
} | ||
|
||
return CheckLabelsOutput({"check_labels": job}) | ||
|
||
|
||
# ---------------------------------------------------------------------- | ||
# Main file | ||
# ---------------------------------------------------------------------- | ||
|
@@ -1694,12 +1731,32 @@ def generate() -> dict[Path, str]: | |
Dumper=NoAliasDumper, | ||
) | ||
|
||
check_labels_output = check_labels() | ||
check_labels_yaml = yaml.dump( | ||
{ | ||
"name": "PR Validation", | ||
"on": { | ||
"pull_request": { | ||
"types": [ | ||
"opened", | ||
"reopened", | ||
"labeled", | ||
"unlabeled", | ||
] | ||
} | ||
}, | ||
"jobs": check_labels_output.jobs, | ||
}, | ||
Dumper=NoAliasDumper, | ||
) | ||
|
||
return { | ||
Path(".github/workflows/audit.yaml"): f"{HEADER}\n\n{audit_yaml}", | ||
Path(".github/workflows/cache_comparison.yaml"): f"{HEADER}\n\n{cache_comparison_yaml}", | ||
Path(".github/workflows/test.yaml"): f"{HEADER}\n\n{test_yaml}", | ||
Path(".github/workflows/release.yaml"): f"{HEADER}\n\n{release_yaml}", | ||
Path(".github/workflows/public_repos.yaml"): f"{HEADER}\n\n{public_repos_yaml}", | ||
Path(".github/workflows/check_labels.yaml"): f"{HEADER}\n\n{check_labels_yaml}", | ||
} | ||
|
||
|
||
|