Skip to content

Conversation

@beninato8
Copy link
Contributor

@beninato8 beninato8 commented Jun 13, 2025

This PR addresses the changes requested in #346 from earlier this year, as I also would like to be able to use this feature.

It adds 2 new outputs: CACHE-HIT and PUB-CACHE-HIT. These just pass along the cache-hit output from actions/cache@v4 for the cache-flutter and cache-pub steps. These can be used for increasing workflow efficiency through steps like conditionally installing dependencies when the cache is invalid. The README is also updated with example usage to skip melos bootstrap if PUB-CACHE-HIT was not true.

I tested the outputs here: https://github.com/beninato8-forks/flutter-action/actions/runs/15627281250/job/44023816175

Cache restored successfully
Cache restored from key: flutter-linux-stable-3.27.4-x64-d8a9f9a52e5af486f80d932e838ee93861ffd863
...
Cache restored successfully
Cache restored from key: flutter-pub-linux-stable-3.27.4-x64-d8a9f9a52e5af486f80d932e838ee93861ffd863-
...
Cache Hit: true
Pub Cache Hit: true

Output from the following steps (after a previous run was cached):

- name: Flutter Action 1
  uses: ./
  id: flutter-action-1
  with:
    flutter-version: '3.27.x'
    channel: 'stable'
    cache: true

- name: Print Action Outputs 1
  run: |
    echo "Cache Hit: ${{ steps.flutter-action-1.outputs.CACHE-HIT }}"
    echo "Pub Cache Hit: ${{ steps.flutter-action-1.outputs.PUB-CACHE-HIT }}"

This PR closes #346

Comment on lines -366 to +404
[Alif Rachmawadi]: https://github.com/subosito
[Bartek Pacia]: https://github.com/bartekpacia
[Alif Rachmawadi](https://github.com/subosito)
[Bartek Pacia](https://github.com/bartekpacia)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these lines did not show up in the README, so i changed to links that do show up

Copy link
Collaborator

Choose a reason for hiding this comment

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

thank you!

Copy link
Collaborator

@bartekpacia bartekpacia Jun 24, 2025

Choose a reason for hiding this comment

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

well, they were actually supposed to not show up. they are link reference definitions.

see https://github.github.com/gfm/#link-reference-definitions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, my bad 😅. thanks for explaining!

@jogboms
Copy link

jogboms commented Jun 20, 2025

@bartekpacia 👀

Copy link
Collaborator

@bartekpacia bartekpacia left a comment

Choose a reason for hiding this comment

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

LGTM, thank you! just some tiny changes and it's ready to be merged

README.md Outdated
Comment on lines 322 to 325
Note: `PUB-CACHE-HIT` and `CACHE-HIT` directly use the `cache-hit` output from `actions/cache@v4`, which is the following:
> - `cache-hit` - A string value to indicate an exact match was found for the key.
> - If there's a cache hit, this will be 'true' or 'false' to indicate if there's an exact match for `key`.
> - If there's a cache miss, this will be an empty string.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use this syntax to make it look nicer :)

README.md Outdated
> - If there's a cache hit, this will be 'true' or 'false' to indicate if there's an exact match for `key`.
> - If there's a cache miss, this will be an empty string.

Example usage (inspired by [actions/cache@v4](https://github.com/actions/cache?tab=readme-ov-file#skipping-steps-based-on-cache-hit) and [#346](https://github.com/subosito/flutter-action/pull/346)) to skip `melos bootstrap` if there was a pub cache hit:
Copy link
Collaborator

Choose a reason for hiding this comment

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

pin the link to a specific commit so the link doesn't become broken in the future

@beninato8 beninato8 requested a review from bartekpacia June 24, 2025 18:41
@bartekpacia bartekpacia merged commit 947e9c9 into subosito:main Jun 24, 2025
@bartekpacia
Copy link
Collaborator

Thank you!

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.

4 participants