forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(assets): parallel docker image publishing fails on macOS (aws#20117)
Changes container image publishing so that publishing doesn't re-run docker logins for the same repository and so logins are run one at a time. Fixes aws#20116 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
1 parent
fa23b47
commit 548c9ca
Showing
7 changed files
with
251 additions
and
35 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
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
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
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,12 @@ | ||
/** | ||
* Creates a critical section, ensuring that at most one function can | ||
* enter the critical section at a time. | ||
*/ | ||
export function createCriticalSection() { | ||
let lock = Promise.resolve(); | ||
return async (criticalFunction: () => Promise<void>) => { | ||
const res = lock.then(() => criticalFunction()); | ||
lock = res.catch(e => e); | ||
return res; | ||
}; | ||
}; |
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
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
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,32 @@ | ||
import { createCriticalSection } from '../lib/private/util'; | ||
|
||
test('critical section', async () => { | ||
// GIVEN | ||
const criticalSection = createCriticalSection(); | ||
|
||
// WHEN | ||
const arr = new Array<string>(); | ||
void criticalSection(async () => { | ||
await new Promise(res => setTimeout(res, 500)); | ||
arr.push('first'); | ||
}); | ||
await criticalSection(async () => { | ||
arr.push('second'); | ||
}); | ||
|
||
// THEN | ||
expect(arr).toEqual([ | ||
'first', | ||
'second', | ||
]); | ||
}); | ||
|
||
test('exceptions in critical sections', async () => { | ||
// GIVEN | ||
const criticalSection = createCriticalSection(); | ||
|
||
// WHEN/THEN | ||
await expect(() => criticalSection(async () => { | ||
throw new Error('Thrown'); | ||
})).rejects.toThrow('Thrown'); | ||
}); |