Skip to content

Commit

Permalink
Merge pull request #17 from im-open/update-to-node20
Browse files Browse the repository at this point in the history
Update to node20 +semver:minor
  • Loading branch information
DougDyreng authored Aug 6, 2024
2 parents 198f82a + 3fac522 commit 37ba585
Show file tree
Hide file tree
Showing 6 changed files with 62,305 additions and 48,745 deletions.
60 changes: 30 additions & 30 deletions .github/workflows/build-and-review-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,28 @@ jobs:
# The npm script to run to build the action. This is typically 'npm run build' if the
# action needs to be compiled. For composite-run-steps actions this is typically empty.
build-command: 'npm run build'

create-cache:
runs-on: ubuntu-latest

env:
NUGET_CACHE_KEY: ''

outputs:
NUGET_CACHE_KEY: ${{ env.NUGET_CACHE_KEY }}

steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Set Cache Keys
run: echo "NUGET_CACHE_KEY=nuget-${{ hashFiles('**/*.csproj') }}" >> $GITHUB_ENV

- name: Check for a nuget cache
id: has-cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: '~/.nuget/packages'
key: ${{ env.NUGET_CACHE_KEY }}
Expand All @@ -93,7 +93,7 @@ jobs:
# This action creates a post-job step that will upload the ./.nuget/packages dir to the cache if the job completes successfully
- name: Setup caching for nuget packages if cache does not exist
if: steps.has-cache.outputs.cache-hit != 'true'
uses: actions/cache@v3
uses: actions/cache@v4
with:
key: ${{ env.NUGET_CACHE_KEY }}
path: ~/.nuget/packages
Expand All @@ -111,7 +111,7 @@ jobs:
if: steps.has-cache.outputs.cache-hit != 'true'
working-directory: ./test/minimal-dotnet-proj
run: dotnet restore

test:
runs-on: ubuntu-latest
needs: [create-cache]
Expand All @@ -121,7 +121,7 @@ jobs:
BAD_CACHE_KEY: 'abc123'

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

Expand All @@ -130,7 +130,7 @@ jobs:
#--------------------------------------
- name: '-------------------------------------------------------------------------------------------------------'
run: echo ""

- name: When restoring a cache with a bad key and required=true
uses: ./
if: always()
Expand All @@ -140,25 +140,25 @@ jobs:
key: '${{ env.BAD_CACHE_KEY }}'
required: true
path: ~/.nuget/packages

- name: Then the outcome should be failure
if: always()
run: ./test/assert-values-match.sh --name "step outcome" --expected "failure" --actual "${{ steps.required.outcome }}"

- name: And the cache-hit output should be empty
if: always()
run: ./test/assert-values-match.sh --name "cache-hit" --expected "" --actual "${{ steps.required.outputs.cache-hit }}"

- name: And the primary key output should match the key input
if: always()
run: ./test/assert-values-match.sh --name "cache-hit" --expected "${{ env.BAD_CACHE_KEY }}" --actual "${{ steps.required.outputs.primary-key }}"

#--------------------------------------
# NO CACHE HIT - NO FAILURE
#--------------------------------------
- name: '-------------------------------------------------------------------------------------------------------'
run: echo ""

- name: When restoring a cache with a bad key and required=false
uses: ./
if: always()
Expand All @@ -167,25 +167,25 @@ jobs:
key: '${{ env.BAD_CACHE_KEY }}'
required: false
path: ~/.nuget/packages

- name: Then the outcome should be success
if: always()
run: ./test/assert-values-match.sh --name "step outcome" --expected "success" --actual "${{ steps.not-required.outcome }}"

- name: And the cache-hit output should be false
if: always()
run: ./test/assert-values-match.sh --name "cache-hit" --expected "false" --actual "${{ steps.not-required.outputs.cache-hit }}"
run: ./test/assert-values-match.sh --name "cache-hit" --expected "false" --actual "${{ steps.not-required.outputs.cache-hit }}"

- name: And the primary key output should match the key input
if: always()
run: ./test/assert-values-match.sh --name "cache-hit" --expected "${{ env.BAD_CACHE_KEY }}" --actual "${{ steps.not-required.outputs.primary-key }}"

#--------------------------------------
# USING RESTORE KEYS
#--------------------------------------
- name: '-------------------------------------------------------------------------------------------------------'
run: echo ""

- name: When restoring a cache with a bad key and a list of restore keys
uses: ./
if: always()
Expand All @@ -198,25 +198,25 @@ jobs:
'bad-key-a'
'bad-key-b'
'bad-key-c'
- name: Then the outcome should be success
if: always()
run: ./test/assert-values-match.sh --name "step outcome" --expected "success" --actual "${{ steps.restore-keys.outcome }}"

- name: And the cache-hit output should be false
if: always()
run: ./test/assert-values-match.sh --name "cache-hit" --expected "false" --actual "${{ steps.restore-keys.outputs.cache-hit }}"

- name: And the primary key output should match the key input
if: always()
run: ./test/assert-values-match.sh --name "cache-hit" --expected "${{ env.BAD_CACHE_KEY }}" --actual "${{ steps.restore-keys.outputs.primary-key }}"

#--------------------------------------
# EXACT MATCH
#--------------------------------------
- name: '-------------------------------------------------------------------------------------------------------'
run: echo ""

- name: When restoring a cache with the cache key
uses: ./
if: always()
Expand All @@ -225,18 +225,18 @@ jobs:
key: '${{ env.NUGET_CACHE_KEY }}'
required: true
path: ~/.nuget/packages

- name: Then the outcome should be success
if: always()
run: ./test/assert-values-match.sh --name "step outcome" --expected "success" --actual "${{ steps.success.outcome }}"

- name: And the cache-hit output should be true
if: always()
run: ./test/assert-values-match.sh --name "cache-hit" --expected "true" --actual "${{ steps.success.outputs.cache-hit }}"

- name: And the primary key output should match the key input
if: always()
run: ./test/assert-values-match.sh --name "cache-hit" --expected "${{ env.NUGET_CACHE_KEY }}" --actual "${{ steps.success.outputs.primary-key }}"

- name: '-------------------------------------------------------------------------------------------------------'
run: echo ""
run: echo ""
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# restore-cache

This is a fork of [martijnhols/actions-cache] at version 3.0.4 but only contains a slimmed down version of the [restore] action.
This is a fork of [martijnhols/actions-cache] at version 3.0.4 but only contains a slimmed down version of the [restore] action.

This action will restore a cache but will not save the cache in a post-job step.

Expand Down Expand Up @@ -46,13 +46,13 @@ jobs:
runs-on: ubuntu-20.04
outputs:
NPM_CACHE_KEY: ${{ env.NPM_CACHE_KEY }}

steps:
- uses: actions/checkout@v3

- name: Set Cache Keys
run: echo "NPM_CACHE_KEY=node_modules-${{ hashFiles('**/package-lock.json') }}" >> $GITHUB_ENV

- name: Check for an npm cache
id: has-cache
uses: actions/cache@v3
Expand All @@ -61,7 +61,7 @@ jobs:
key: ${{ env.NPM_CACHE_KEY }}
lookup-only: true
enableCrossOsArchive: true

# This action will upload the node_modules dir to the cache if the job completes successfully.
# Subsequent jobs/workflow runs can use this cached copy if the package-lock.json hasn't changed
# and they are also using a ubuntu-20.04 runner to restore the cache from.
Expand All @@ -76,15 +76,15 @@ jobs:
- name: npm ci if cache does not exist
if: steps.has-cache.outputs.cache-hit != 'true'
run: npm ci

jest:
runs-on: ubuntu-20.04
needs: [ npm-cache ]
steps:
- uses: actions/checkout@v3

- name: Download npm cache
uses: im-open/restore-cache@v1.2.0
uses: im-open/restore-cache@v1.3.0
with:
key: ${{ needs.npm-cache.outputs.NPM_CACHE_KEY }}
path: '**/node_modules'
Expand All @@ -94,8 +94,8 @@ jobs:

- name: jest test with coverage
run: npm test -- --json --outputFile=jest-results.json --coverage


```

## Contributing
Expand All @@ -122,7 +122,7 @@ This repo uses [git-version-lite] in its workflows to examine commit messages to

### Source Code Changes

The files and directories that are considered source code are listed in the `files-with-code` and `dirs-with-code` arguments in both the [build-and-review-pr] and [increment-version-on-merge] workflows.
The files and directories that are considered source code are listed in the `files-with-code` and `dirs-with-code` arguments in both the [build-and-review-pr] and [increment-version-on-merge] workflows.

If a PR contains source code changes, the README.md should be updated with the latest action version and the action should be recompiled. The [build-and-review-pr] workflow will ensure these steps are performed when they are required. The workflow will provide instructions for completing these steps if the PR Author does not initially complete them.

Expand All @@ -143,7 +143,7 @@ If changes are made to the action's [source code], the [usage examples] section

### Tests

The build and review PR workflow includes tests which are linked to a status check. That status check needs to succeed before a PR is merged to the default branch. The tests do not need special permissions, so they should succeed whether they come from a branch or a fork.
The build and review PR workflow includes tests which are linked to a status check. That status check needs to succeed before a PR is merged to the default branch. The tests do not need special permissions, so they should succeed whether they come from a branch or a fork.

## Code of Conduct

Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ outputs:
primary-key:
description: 'The primary key that should be used when saving the cache.'
runs:
using: 'node16'
using: 'node20'
main: './dist/index.js'
Loading

0 comments on commit 37ba585

Please sign in to comment.