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

Actions: Add more tests for the cache service #301

Open
ChristopherHX opened this issue Jan 18, 2024 · 0 comments
Open

Actions: Add more tests for the cache service #301

ChristopherHX opened this issue Jan 18, 2024 · 0 comments

Comments

@ChristopherHX
Copy link
Owner

The following is already working, but could be broken without having ci raising an error

on: push
defaults:
  run:
    shell: bash

jobs:
    createcache:
        runs-on: ubuntu-latest
        steps:
        -   uses: actions/cache@v3
            id: cache
            with:
                path: |
                    ./.cache
                key: prefix0-keya
        -   run: |
                mkdir ./.cache
                echo createcache > ./.cache/Test
            if: steps.cache.outputs.cache-hit != 'true'
        -   run: exit 1
            if: steps.cache.outputs.cache-hit == 'true'
    createcache2:
        runs-on: ubuntu-latest
        needs: createcache
        steps:
        -   uses: actions/cache@v3
            id: cache
            with:
                path: |
                    ./.cache
                key: prefix0-keyb
        -   run: |
                mkdir ./.cache
                echo createcache2 > ./.cache/Test
            if: steps.cache.outputs.cache-hit != 'true'
        -   run: exit 1
            if: steps.cache.outputs.cache-hit == 'true'
    createcache3:
        runs-on: ubuntu-latest
        needs: createcache2
        steps:
        -   uses: actions/cache@v3
            id: cache
            with:
                path: |
                    ./.cache
                key: prefix1-keya
        -   run: |
                mkdir ./.cache
                echo createcache3 > ./.cache/Test
            if: steps.cache.outputs.cache-hit != 'true'
        -   run: exit 1
            if: steps.cache.outputs.cache-hit == 'true'
    hitcache:
        needs: createcache3
        runs-on: ubuntu-latest
        steps:
        -   uses: actions/cache@v3
            id: cache
            with:
                path: |
                    ./.cache
                key: dummy-key
                restore-keys: |
                  prefix0-
        -   run: 'ls -l ./.cache'
        -   run: exit 1
            if: steps.cache.outputs.cache-hit == 'true'
        -   run: echo We got the expected non exact hit the cache!
            if: steps.cache.outputs.cache-hit != 'true'
        -   run: |
              cat ./.cache/Test
        -   name: Verify that the right entry has been restored
            run: |
              [[ "createcache2" != "$(cat ./.cache/Test )" ]] && exit 1 || exit 0
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

No branches or pull requests

1 participant