-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref: upload to twine synchronously in a single call (#530)
I suspect pypi can't handle parallel requests
- Loading branch information
1 parent
25e9aa8
commit a28e295
Showing
2 changed files
with
50 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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,45 @@ | ||
import { PypiTarget } from '../pypi'; | ||
import { NoneArtifactProvider } from '../../artifact_providers/none'; | ||
import { RemoteArtifact } from '../../artifact_providers/base'; | ||
|
||
jest.mock('../../utils/system', () => ({ | ||
...jest.requireActual('../../utils/system'), | ||
checkExecutableIsPresent: jest.fn(), | ||
})); | ||
|
||
describe('pypi', () => { | ||
const oldEnv = { ...process.env }; | ||
|
||
beforeEach(() => { | ||
process.env.TWINE_USERNAME = '__token__'; | ||
process.env.TWINE_PASSWORD = 'getsentry/craft:bogus'; | ||
}); | ||
|
||
afterAll(() => { | ||
process.env = { ...oldEnv }; | ||
}); | ||
|
||
test('it uploads all artifacts in a single twine call', async () => { | ||
const target = new PypiTarget({name: 'pypi'}, new NoneArtifactProvider()); | ||
target.getArtifactsForRevision = jest | ||
.fn() | ||
.mockResolvedValueOnce([ | ||
{ filename: 'pkg-1-py3-none-macos_11_0_arm64.whl' }, | ||
{ filename: 'pkg-1-py3-none-manylinux_2_17_x86_64.whl' }, | ||
{ filename: 'pkg-1.tar.gz' }, | ||
]); | ||
target.artifactProvider.downloadArtifact = jest.fn( | ||
async (artifact: RemoteArtifact, _downloadDirectory?: string | undefined) => `downloaded/path/${artifact.filename}` | ||
); | ||
const upload = jest.fn(); | ||
target.uploadAssets = upload; | ||
|
||
await target.publish('version', 'deadbeef'); | ||
|
||
expect(upload.mock.lastCall[0]).toStrictEqual([ | ||
'downloaded/path/pkg-1-py3-none-macos_11_0_arm64.whl', | ||
'downloaded/path/pkg-1-py3-none-manylinux_2_17_x86_64.whl', | ||
'downloaded/path/pkg-1.tar.gz', | ||
]); | ||
}); | ||
}); |
This file contains 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