Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: actions/setup-python
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.1.0
Choose a base ref
...
head repository: actions/setup-python
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.1.1
Choose a head ref
  • 3 commits
  • 11 files changed
  • 3 contributors

Commits on Apr 4, 2022

  1. Rework pipenv caching test (#375)

    * Rework python-pipenv-dependencies-caching test
    
    * Update Pipfile.lock hash in the tests
    
    * Rework python-pipenv-dependencies-caching-path test
    
    * Set location for pipenv test
    
    * Remove requests package from tests
    
    * Test pipenv without caching
    
    * Enable pipenv cache
    Vladimir Safonkin authored Apr 4, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7885ec3 View commit details
  2. Add pyton-version to setup PyPy output (#365)

    * Add pyton-version to setup PyPy output
    
    * remove new line from pypy version
    
    * Move setOutput to findPyPyVersion
    
    * Resolve conflict: 2
    dsame authored Apr 4, 2022
    Copy the full SHA
    7933d5a View commit details

Commits on Apr 5, 2022

  1. Cache hit output (#373)

    * Remove useless await in getCacheDistributor calls
    
    * Added cache-hit output
    
    * Build action with cache-hit output
    
    * Remove PromiseReturnType, add matchedKey == primaryKey check
    
    * Update cache-distributor.ts
    
    * Fix tests and rebuild
    dhvcc authored Apr 5, 2022
    Copy the full SHA
    21c0493 View commit details
20 changes: 12 additions & 8 deletions .github/workflows/e2e-cache.yml
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.9', 'pypy-3.7-v7.x']
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup Python
uses: ./
with:
@@ -41,7 +41,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.9', 'pypy-3.7-v7.x']
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup Python
uses: ./
with:
@@ -50,7 +50,9 @@ jobs:
- name: Install pipenv
run: pipx install pipenv
- name: Install dependencies
run: pipenv install numpy
run: |
cd __tests__/data
pipenv install --verbose
python-poetry-dependencies-caching:
name: Test poetry (Python ${{ matrix.python-version}}, ${{ matrix.os }})
@@ -61,7 +63,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.9', 'pypy-3.7-v7.x']
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- name: Setup Python
@@ -83,7 +85,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.9', 'pypy-3.7-v7.x']
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup Python
uses: ./
with:
@@ -102,14 +104,16 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.9', 'pypy-3.7-v7.x']
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup Python
uses: ./
with:
python-version: ${{ matrix.python-version }}
cache: 'pipenv'
cache-dependency-path: '**/requirements-linux.txt'
cache-dependency-path: '**/pipenv-requirements.txt'
- name: Install pipenv
run: pipx install pipenv
- name: Install dependencies
run: pipenv install numpy
run: |
cd __tests__/data
pipenv install --verbose
44 changes: 40 additions & 4 deletions __tests__/cache-restore.test.ts
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import {getCacheDistributor} from '../src/cache-distributions/cache-factory';

describe('restore-cache', () => {
const pipFileLockHash =
'67d817abcde9c72da0ed5b8f235647cb14638b9ff9d742b42e4406d2eb16fe3c';
'd1dd6218299d8a6db5fc2001d988b34a8b31f1e9d0bb4534d377dde7c19f64b3';
const requirementsHash =
'd8110e0006d7fb5ee76365d565eef9d37df1d11598b912d3eb66d398d57a1121';
const requirementsLinuxHash =
@@ -27,6 +27,7 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
let debugSpy: jest.SpyInstance;
let saveSatetSpy: jest.SpyInstance;
let getStateSpy: jest.SpyInstance;
let setOutputSpy: jest.SpyInstance;

// cache spy
let restoreCacheSpy: jest.SpyInstance;
@@ -64,6 +65,9 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
return {stdout: '', stderr: 'Error occured', exitCode: 2};
});

setOutputSpy = jest.spyOn(core, 'setOutput');
setOutputSpy.mockImplementation(input => undefined);

restoreCacheSpy = jest.spyOn(cache, 'restoreCache');
restoreCacheSpy.mockImplementation(
(cachePaths: string[], primaryKey: string, restoreKey?: string) => {
@@ -100,7 +104,7 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
])(
'restored dependencies for %s by primaryKey',
async (packageManager, pythonVersion, dependencyFile, fileHash) => {
const cacheDistributor = await getCacheDistributor(
const cacheDistributor = getCacheDistributor(
packageManager,
pythonVersion,
dependencyFile
@@ -126,7 +130,7 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
dependencyFile,
cacheDependencyPath
) => {
const cacheDistributor = await getCacheDistributor(
const cacheDistributor = getCacheDistributor(
packageManager,
pythonVersion,
dependencyFile
@@ -162,7 +166,7 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
return primaryKey !== fileHash && restoreKey ? pipFileLockHash : '';
}
);
const cacheDistributor = await getCacheDistributor(
const cacheDistributor = getCacheDistributor(
packageManager,
pythonVersion,
dependencyFile
@@ -187,6 +191,38 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
);
});

describe('Check if handleMatchResult', () => {
it.each([
['pip', '3.8.12', 'requirements.txt', 'someKey', 'someKey', true],
['pipenv', '3.9.1', 'requirements.txt', 'someKey', 'someKey', true],
['poetry', '3.8.12', 'requirements.txt', 'someKey', 'someKey', true],
['pip', '3.9.2', 'requirements.txt', undefined, 'someKey', false],
['pipenv', '3.8.12', 'requirements.txt', undefined, 'someKey', false],
['poetry', '3.9.12', 'requirements.txt', undefined, 'someKey', false]
])(
'sets correct outputs',
async (
packageManager,
pythonVersion,
dependencyFile,
matchedKey,
restoredKey,
expectedOutputValue
) => {
const cacheDistributor = getCacheDistributor(
packageManager,
pythonVersion,
dependencyFile
);
cacheDistributor.handleMatchResult(matchedKey, restoredKey);
expect(setOutputSpy).toHaveBeenCalledWith(
'cache-hit',
expectedOutputValue
);
}
);
});

afterEach(() => {
jest.resetAllMocks();
jest.clearAllMocks();
2 changes: 1 addition & 1 deletion __tests__/cache-save.test.ts
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import {State} from '../src/cache-distributions/cache-distributor';

describe('run', () => {
const pipFileLockHash =
'67d817abcde9c72da0ed5b8f235647cb14638b9ff9d742b42e4406d2eb16fe3c';
'd1dd6218299d8a6db5fc2001d988b34a8b31f1e9d0bb4534d377dde7c19f64b3';
const requirementsHash =
'd8110e0006d7fb5ee76365d565eef9d37df1d11598b912d3eb66d398d57a1121';
const requirementsLinuxHash =
13 changes: 13 additions & 0 deletions __tests__/data/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
numpy = "1.22.3"
pandas = "1.4.2"

[dev-packages]

[requires]
python_version = "*"
Loading