Skip to content

feat: impl cache hit outputs #346

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

Conversation

anies1212
Copy link
Contributor

@anies1212 anies1212 commented Jan 24, 2025

What does this PR do?

This PR adds a new output, cache-hit, to the flutter-action. The cache-hit output indicates whether the cache was successfully hit during the setup process. This can help optimize workflows by conditionally executing subsequent steps based on cache status.

Why is this change necessary?

In our project, we manage a monorepo using melos. As part of our CI/CD pipeline, we run melos bs (bootstrap) every time to set up dependencies and link packages. However, this can be redundant when the cache is already valid.

With the cache-hit output, we can:

  • Avoid unnecessary executions of melos bs when the cache is valid.
  • Reduce build times and resource usage.
  • Enhance workflow efficiency.

Example usage

Here’s how we plan to use the cache-hit output:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Set up Flutter
        uses: subosito/flutter-action@v2
        id: flutter-action
        with:
          channel: stable
          cache: true

      - name: Conditionally run melos bootstrap
        if: steps.flutter-action.outputs.CACHE-HIT == 'false'
        run: melos bs

      - name: Continue with build
        run: flutter build apk

@bartekpacia
Copy link
Collaborator

Hi @anies1212! This looks like a great PR, thank you.

I'd like to ask you to:

  • update README to document this new feature
  • support both CACHE-KEY and PUB-CACHE-KEY, i.e. have two separate cache-hit and pub-cache-hit outputs.

@beninato8 beninato8 mentioned this pull request Jun 13, 2025
@beninato8
Copy link
Contributor

beninato8 commented Jun 13, 2025

@bartekpacia as this is also a feature i would be interested in, i cherry picked the commit from @anies1212 and created a new PR with your requested changes in #364.

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