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

Add save and restore actions #41

Merged
merged 5 commits into from
Feb 9, 2024

Conversation

mattlewis92
Copy link
Contributor

Changes

Adds save and restore sub-actions to match the official actions cache behaviour and make this action a true drop in replacement for the official github cache action.

Usage is fairly straight forward, to save to the cache only (note the /save at the end of the uses key):

      - uses: tespkg/actions-cache/save@v1
        with:
          accessKey: "Q3AM3UQ867SPQQA43P2F" # required
          secretKey: "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG" # required
          bucket: actions-cache # required
          # actions/cache compatible properties: https://github.com/actions/cache
          key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
          path: |
            node_modules

To restore only (note the /restore at the end of the uses key)::

      - uses: tespkg/actions-cache/restore@v1
        with:
          accessKey: "Q3AM3UQ867SPQQA43P2F" # required
          secretKey: "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG" # required
          bucket: actions-cache # required
          # actions/cache compatible properties: https://github.com/actions/cache
          key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
          path: |
            node_modules

Fix Issues

Closes #38

@jackieli-tes
Copy link
Contributor

Looks good so far, can you add a test workflow to test just the saveOnly part? You can start by copying this file: https://github.com/tespkg/actions-cache/blob/main/.github/workflows/test.yml to a new file and modify the bits needed.

@mattlewis92
Copy link
Contributor Author

Looks good so far, can you add a test workflow to test just the saveOnly part? You can start by copying this file: main/.github/workflows/test.yml to a new file and modify the bits needed.

Sure thing! Added here a4b7cac + here 18d4ac5

@@ -169,3 +169,32 @@ jobs:
path: |
test-cache
~/test-cache

test-restore-only:
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this tests the new functionality. Can you elaborate how does this test the restore-only?

In my previous comment, I meant that you should make a new file and use your pattern of "save" and "restore" actions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note how it uses the new sub-action that restores only via the uses: ./restore/ here:

https://github.com/mattlewis92/actions-cache/blob/18d4ac58ee9683f4c7ea366fee85bcc0fa578240/.github/workflows/test.yml#L184

They could be put into a different workflow, but it seemed redundant to me as it also functions just fine in this one. I can move it into a separate workflow if you'd prefer though

Copy link
Contributor

Choose a reason for hiding this comment

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

The tests is setup so that it logs the machine ID it runs on and restores on the same machine. I know, it can be so much better, but it works so far. So a separate file will probably put it on a different machine. Hence tests the actual thing. If put in the same file it'll pick up from the previous step.

After written all these, I realised you do distinguish using the key. so all good for me.

@@ -169,3 +169,32 @@ jobs:
path: |
test-cache
~/test-cache

test-restore-only:
Copy link
Contributor

Choose a reason for hiding this comment

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

The tests is setup so that it logs the machine ID it runs on and restores on the same machine. I know, it can be so much better, but it works so far. So a separate file will probably put it on a different machine. Hence tests the actual thing. If put in the same file it'll pick up from the previous step.

After written all these, I realised you do distinguish using the key. so all good for me.

@jackieli-tes jackieli-tes merged commit f914804 into tespkg:main Feb 9, 2024
24 checks passed
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.

💡 - Split save and restore
2 participants