| 1 | import * as Effect from "effect/Effect"; |
| 2 | import * as Semaphore from "effect/Semaphore"; |
| 3 | |
| 4 | // IAM rejects uploading the same signing certificate body anywhere else in |
| 5 | // the account, even when the certificates belong to different users. The two |
| 6 | // live tests intentionally share one checked-in deterministic certificate, so |
| 7 | // serialize only their certificate lifecycles while leaving unrelated IAM and |
| 8 | // AWS tests concurrent. |
| 9 | const signingCertificateFixtureLock = Semaphore.makeUnsafe(1); |
| 10 | |
| 11 | export const withSigningCertificateFixture = <A, E, R>( |
| 12 | effect: Effect.Effect<A, E, R>, |
| 13 | ) => |
| 14 | Effect.acquireUseRelease( |
| 15 | signingCertificateFixtureLock.take(1), |
| 16 | () => effect, |
| 17 | () => signingCertificateFixtureLock.release(1).pipe(Effect.asVoid), |
| 18 | ); |