Skip to content
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

CI: Trigger workflows based on changed files #2952

Merged
merged 8 commits into from
Jan 6, 2024
Merged

CI: Trigger workflows based on changed files #2952

merged 8 commits into from
Jan 6, 2024

Conversation

seisman
Copy link
Member

@seisman seisman commented Jan 4, 2024

Some workflow runs are unnecessary and waste CI resources. For example, PR #2950 contains no codes or docs changes, but when it was merged into the main branch, workflows "Tests" and "Docs" were still triggered (see https://github.com/GenericMappingTools/pygmt/actions?query=branch%3Amain).

This PR updates the workflow trigger conditions based on changes files, to save CI resources.

  • benchmarks.yml
  • cache_data.yaml
  • check-links.yml
  • ci_docs.yml
  • ci_doctests.yaml
  • ci_tests_dev.yaml
  • ci_tests_legacy.yaml
  • ci_tests.yaml
  • dvc-diff.yml
  • format-command.yml
  • publish-to-pypi.yml
  • release-baseline-images.yml
  • release-drafter.yml
  • slash-command-dispatch.yml
  • style_checks.yaml
  • type_checks.yml

@@ -11,12 +11,10 @@ on:
branches: [ main ]
paths:
Copy link
Member Author

Choose a reason for hiding this comment

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

We need to run benchmarks for changes of test files. The main reasons are: (1) when making changes to a test in a PR, we need to know that the new test is not too slow. (2) when merging the changes into the main branch, benchmarks need to be triggered to update the performance baseline. Otherwise, when benchmarks are triggered in a new PR, we will be surprised to see that the test has a performance change even though the changes in the PR is irrelevant to the test.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, #2945 was a good example of this where we only modified the test files, and that caused a change in performance. But this is a bit of a rare case though. Maybe we only need to run the benchmark on merge into main, but not in the Pull Request itself? I.e. delete L14 but keep L19?

Copy link
Member Author

@seisman seisman Jan 6, 2024

Choose a reason for hiding this comment

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

Maybe we only need to run the benchmark on merge into main, but not in the Pull Request itself?

Or just disable the workflow in PR (i.e. remove lines 16-20) and run it via slash command when necessary?

Copy link
Member

@weiji14 weiji14 Jan 6, 2024

Choose a reason for hiding this comment

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

Or just disable the workflow in PR (i.e. remove lines 16-20) and run it via slash command when necessary?

Yeah, let's go with that. Just keep a commented line like # pull_request:, so we can manually trigger the benchmark workflow if needed. The slash command can be done in a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in b1e5fa8.

@@ -17,8 +17,14 @@ name: Publish to PyPI
# Only run for pushes to the main branch and releases.
on:
push:
branches:
- main
branches: [ main ]
Copy link
Member Author

Choose a reason for hiding this comment

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

Only publish a test release to TestPyPI if there are code changes.

@seisman seisman marked this pull request as ready for review January 5, 2024 14:00
@@ -11,12 +11,10 @@ on:
branches: [ main ]
paths:
Copy link
Member

Choose a reason for hiding this comment

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

Yes, #2945 was a good example of this where we only modified the test files, and that caused a change in performance. But this is a bit of a rare case though. Maybe we only need to run the benchmark on merge into main, but not in the Pull Request itself? I.e. delete L14 but keep L19?

.github/workflows/ci_docs.yml Show resolved Hide resolved
.github/workflows/ci_docs.yml Show resolved Hide resolved
@weiji14 weiji14 added maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog labels Jan 6, 2024
@weiji14 weiji14 added this to the 0.11.0 milestone Jan 6, 2024
- 'Makefile'
- 'MANIFEST.in'
- 'pyproject.toml'
- 'README.rst'
Copy link
Member

Choose a reason for hiding this comment

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

Reminder to change this to 'README.md' once #2928 is done.

Copy link
Member

@weiji14 weiji14 left a comment

Choose a reason for hiding this comment

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

Just a couple more suggestions, and should be ok to merge after handling https://github.com/GenericMappingTools/pygmt/pull/2952/files#r1443654304.

.github/workflows/benchmarks.yml Show resolved Hide resolved
.github/workflows/ci_tests_legacy.yaml Show resolved Hide resolved
seisman and others added 2 commits January 6, 2024 16:35
Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
@seisman seisman enabled auto-merge (squash) January 6, 2024 08:37
@seisman seisman disabled auto-merge January 6, 2024 08:55
@seisman seisman merged commit 98e0074 into main Jan 6, 2024
17 of 18 checks passed
@seisman seisman deleted the workflows/paths branch January 6, 2024 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants