Skip to content

Commit

Permalink
Fix macOS cache support
Browse files Browse the repository at this point in the history
  • Loading branch information
eifinger committed Feb 20, 2024
1 parent 98309e0 commit a9df2ca
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
version: '0.11.0'
enable-cache: true
working-directory: __tests__/fixtures/rye-project
cache-prefix: ${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.os }}
cache-prefix: ${{ github.run_id }}-${{ github.run_attempt }}
- run: rye sync
working-directory: __tests__/fixtures/rye-project
test-restore-cache:
Expand All @@ -41,7 +41,7 @@ jobs:
version: '0.11.0'
enable-cache: true
working-directory: __tests__/fixtures/rye-project
cache-prefix: ${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.os }}
cache-prefix: ${{ github.run_id }}-${{ github.run_attempt }}
- name: Cache was hit
run: |
if [ "$CACHE_HIT" != "true" ]; then
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/test-latest-scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ jobs:
os: [ubuntu-latest, macos-latest, macos-14, oracle-aarch64]
steps:
- uses: actions/checkout@v4
- name: Should not be on path
run: |
if ! which rye;
then
exit 0
else
exit 1
fi
- name: Setup rye
uses: ./
- run: rye sync
Expand Down
19 changes: 0 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,6 @@ jobs:
npm install
- run: |
npm run all
test-latest:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, macos-14, oracle-aarch64]
steps:
- uses: actions/checkout@v4
- name: Should not be on path
run: |
if ! which rye;
then
exit 0
else
exit 1
fi
- name: Install latest
uses: ./
- run: |
which rye
test-specific-version:
runs-on: ${{ matrix.os }}
strategy:
Expand Down
14 changes: 12 additions & 2 deletions dist/save-cache/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/save-cache/index.js.map

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions dist/setup/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/setup/index.js.map

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion dist/update-checksums/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/update-checksums/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/restore-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as core from '@actions/core'
import {cp} from '@actions/io/'
import {exists} from '@actions/io/lib/io-util'

import {getLinuxInfo} from './utils'
import {IS_MAC, getLinuxInfo, getMacOSInfo} from './utils'

export const STATE_CACHE_PRIMARY_KEY = 'cache-primary-key'
export const STATE_CACHE_MATCHED_KEY = 'cache-matched-key'
Expand Down Expand Up @@ -54,7 +54,7 @@ async function computeKeys(
const workingDirHash = workingDir
? `-${crypto.createHash('sha256').update(workingDir).digest('hex')}`
: ''
const osInfo = await getLinuxInfo()
const osInfo = IS_MAC ? await getMacOSInfo() : await getLinuxInfo()
const prefix = cachePrefix ? `${cachePrefix}-` : ''
const primaryKey = `${prefix}setup-rye-${process.env['RUNNER_OS']}-${osInfo.osVersion}-${osInfo.osName}-rye-${version}${workingDirHash}-${dependencyPathHash}`
const restoreKey = `${prefix}setup-rye-${process.env['RUNNER_OS']}-${osInfo.osVersion}-${osInfo.osName}-rye-${version}${workingDirHash}`
Expand Down
13 changes: 13 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,19 @@ export function getArch(): Architecture | undefined {
}
}

export async function getMacOSInfo(): Promise<{
osName: string
osVersion: string
}> {
const {stdout} = await exec.getExecOutput('sw_vers', ['-productVersion'], {
silent: true
})

const macOSVersion = stdout.trim()

return {osName: 'macOS', osVersion: macOSVersion}
}

export async function getLinuxInfo(): Promise<{
osName: string
osVersion: string
Expand Down

0 comments on commit a9df2ca

Please sign in to comment.