-
Notifications
You must be signed in to change notification settings - Fork 616
Use correct Poetry config when collecting Poetry projects 8000 #447
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
748f3e6
Use correct Poetry config when collecting Poetry projects
oranav 157f5da
Fix typo: saveSatetSpy -> saveStateSpy
oranav dc45b1e
poetry: Support same virtualenv appearing in multiple projects
oranav f350528
Add nested Poetry projects test
oranav 727a4d2
poetry: Set up environment for each project individually
oranav 95696f7
tests/cache-restore: Do not look for dependency files outside `data`
oranav bb9c5ac
poetry: Simplify `virtualenvs.in-project` boolean check
oranav bc3992e
README: Explain that poetry might create multiple caches
oranav 881ca6e
poetry: Run `poetry env use` only after cache is loaded
oranav b69ad35
poetry: Bump cache primary key
oranav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import * as path from 'path'; | ||
import * as core from '@actions/core'; | ||
import * as cache from '@actions/cache'; | ||
import * as exec from '@actions/exec'; | ||
import * as io from '@actions/io'; | ||
import {getCacheDistributor} from '../src/cache-distributions/cache-factory'; | ||
import {State} from '../src/cache-distributions/cache-distributor'; | ||
import * as utils from './../src/utils'; | ||
|
||
describe('restore-cache', () => { | ||
|
@@ -13,7 +15,7 @@ describe('restore-cache', () => { | |
const requirementsLinuxHash = | ||
'2d0ff7f46b0e120e3d3294db65768b474934242637b9899b873e6283dfd16d7c'; | ||
const poetryLockHash = | ||
'571bf984f8d210e6a97f854e479fdd4a2b5af67b5fdac109ec337a0ea16e7836'; | ||
'f24ea1ad73968e6c8d80c16a093ade72d9332c433aeef979a0dd943e6a99b2ab'; | ||
const poetryConfigOutput = ` | ||
cache-dir = "/Users/patrick/Library/Caches/pypoetry" | ||
experimental.new-installer = false | ||
|
@@ -27,7 +29,7 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py | |
let infoSpy: jest.SpyInstance; | ||
let warningSpy: jest.SpyInstance; | ||
let debugSpy: jest.SpyInstance; | ||
let saveSatetSpy: jest.SpyInstance; | ||
let saveStateSpy: jest.SpyInstance; | ||
let getStateSpy: jest.SpyInstance; | ||
let setOutputSpy: jest.SpyInstance; | ||
|
||
|
@@ -52,8 +54,8 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py | |
debugSpy = jest.spyOn(core, 'debug'); | ||
debugSpy.mockImplementation(input => undefined); | ||
|
||
saveSatetSpy = jest.spyOn(core, 'saveState'); | ||
saveSatetSpy.mockImplementation(input => undefined); | ||
saveStateSpy = jest.spyOn(core, 'saveState'); | ||
saveStateSpy.mockImplementation(input => undefined); | ||
|
||
getStateSpy = jest.spyOn(core, 'getState'); | ||
getStateSpy.mockImplementation(input => undefined); | ||
|
@@ -100,21 +102,68 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py | |
|
||
describe('Restore dependencies', () => { | ||
it.each([ | ||
['pip', '3.8.12', undefined, requirementsHash], | ||
['pip', '3.8.12', '**/requirements-linux.txt', requirementsLinuxHash], | ||
[ | ||
'pip', | ||
'3.8.12', | ||
'__tests__/data/**/requirements.txt', | ||
requirementsHash, | ||
undefined | ||
], | ||
[ | ||
'pip', | ||
'3.8.12', | ||
'__tests__/data/**/requirements-linux.txt', | ||
requirementsLinuxHash, | ||
undefined | ||
], | ||
[ | ||
'pip', | ||
'3.8.12', | ||
'__tests__/data/requirements-linux.txt', | ||
requirementsLinuxHash | ||
requirementsLinuxHash, | ||
undefined | ||
], | ||
['pip', '3.8.12', '__tests__/data/requirements.txt', requirementsHash], | ||
['pipenv', '3.9.1', undefined, pipFileLockHash], | ||
MaksimZhukov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
['pipenv', '3.9.12', '__tests__/data/requirements.txt', requirementsHash], | ||
['poetry', '3.9.1', undefined, poetryLockHash] | ||
[ | ||
'pip', | ||
'3.8.12', | ||
'__tests__/data/requirements.txt', | ||
requirementsHash, | ||
undefined | ||
], | ||
[ | ||
'pipenv', | ||
'3.9.1', | ||
'__tests__/data/**/Pipfile.lock', | ||
pipFileLockHash, | ||
undefined | ||
], | ||
[ | ||
'pipenv', | ||
'3.9.12', | ||
'__tests__/data/requirements.txt', | ||
requirementsHash, | ||
undefined | ||
], | ||
[ | ||
'poetry', | ||
'3.9.1', | ||
'__tests__/data/**/poetry.lock', | ||
poetryLockHash, | ||
[ | ||
'/Users/patrick/Library/Caches/pypoetry/virtualenvs', | ||
path.join(__dirname, 'data', 'inner', '.venv'), | ||
path.join(__dirname, 'data', '.venv') | ||
] | ||
] | ||
])( | ||
'restored dependencies for %s by primaryKey', | ||
async (packageManager, pythonVersion, dependencyFile, fileHash) => { | ||
async ( | ||
packageManager, | ||
pythonVersion, | ||
dependencyFile, | ||
fileHash, | ||
cachePaths | ||
) => { | ||
const cacheDistributor = getCacheDistributor( | ||
packageManager, | ||
pythonVersion, | ||
|
@@ -123,10 +172,21 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py | |
|
||
await cacheDistributor.restoreCache(); | ||
|
||
if (cachePaths !== undefined) { | ||
expect(saveStateSpy).toHaveBeenCalledWith( | ||
State.CACHE_PATHS, | ||
cachePaths | ||
); | ||
} | ||
|
||
if (process.platform === 'linux' && packageManager === 'pip') { | ||
expect(infoSpy).toHaveBeenCalledWith( | ||
`Cache restored from key: setup-python-${process.env['RUNNER_OS']}-20.04-Ubuntu-python-${pythonVersion}-${packageManager}-${fileHash}` | ||
); | ||
} else if (packageManager === 'poetry') { | ||
expect(infoSpy).toHaveBeenCalledWith( | ||
`Cache restored from key: setup-python-${process.env['RUNNER_OS']}-python-${pythonVersion}-${packageManager}-v2-${fileHash}` | ||
); | ||
} else { | ||
expect(infoSpy).toHaveBeenCalledWith( | ||
`Cache restored from key: setup-python-${process.env['RUNNER_OS']}-python-${pythonVersion}-${packageManager}-${fileHash}` | ||
|
@@ -164,18 +224,23 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py | |
|
||
describe('Dependencies changed', () => { | ||
it.each([ | ||
['pip', '3.8.12', undefined, pipFileLockHash], | ||
['pip', '3.8.12', '**/requirements-linux.txt', pipFileLockHash], | ||
['pip', '3.8.12', '__tests__/data/**/requirements.txt', pipFileLockHash], | ||
[ | ||
'pip', | ||
'3.8.12', | ||
'__tests__/data/**/requirements-linux.txt', | ||
pipFileLockHash | ||
], | ||
[ | ||
'pip', | ||
'3.8.12', | ||
'__tests__/data/requirements-linux.txt', | ||
pipFileLockHash | ||
], | ||
['pip', '3.8.12', '__tests__/data/requirements.txt', pipFileLockHash], | ||
['pipenv', '3.9.1', undefined, requirementsHash], | ||
['pipenv', '3.9.1', '__tests__/data/**/Pipfile.lock', requirementsHash], | ||
['pipenv', '3.9.12', '__tests__/data/requirements.txt', requirementsHash], | ||
['poetry', '3.9.1', undefined, requirementsHash] | ||
['poetry', '3.9.1', '__tests__/data/**/poetry.lock', requirementsHash] | ||
])( | ||
'restored dependencies for %s by primaryKey', | ||
async (packageManager, pythonVersion, dependencyFile, fileHash) => { | ||
6D4E
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../pyproject.toml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.