Skip to content

Commit 923645c

Browse files
authored
enabled pipelines env var and npm-oidc (#427)
* npm-oidc * enabled pipelines env var
1 parent 0a2576e commit 923645c

5 files changed

Lines changed: 52 additions & 8 deletions

File tree

.github/workflows/cd.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
# push:
66
# branches: [ master ]
77

8+
permissions:
9+
id-token: write # Required for OIDC
10+
contents: read
11+
812
jobs:
913
publish:
1014
runs-on: ubuntu-latest
@@ -14,11 +18,12 @@ jobs:
1418
with:
1519
node-version: 18.x
1620
registry-url: https://registry.npmjs.org/
21+
# Ensure npm 11.5.1 or later is installed
22+
- name: Update npm
23+
run: npm install -g npm@latest
1724
- run: npm ci
1825
- run: npm test
1926
- run: npm publish
20-
env:
21-
NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}}
2227
- uses: sergeysova/jq-action@v2
2328
name: Derive Version
2429
id: version

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aws-lambda-stream",
3-
"version": "1.1.13",
3+
"version": "1.1.14",
44
"description": "Create stream processors with AWS Lambda functions.",
55
"keywords": [
66
"aws",

src/pipelines/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ export const initializeFrom = (rules) => rules.reduce(
4949
);
5050

5151
const assemble = (opt) => (head, includeFaultHandler = true) => {
52-
const disabledPipelines = process.env.DISABLED_PIPELINES?.split(',');
52+
const enabledPipelines = (opt.ENABLED_PIPELINES || process.env.ENABLED_PIPELINES)?.split(',').map((pipeline) => pipeline.trim());
53+
const disabledPipelines = (opt.DISABLED_PIPELINES || process.env.DISABLED_PIPELINES)?.split(',').map((pipeline) => pipeline.trim());
5354
const keys = Object.keys(thePipelines)
54-
.filter((k) => !disabledPipelines?.includes(k));
55+
.filter((k) => !disabledPipelines?.includes(k))
56+
.filter((k) =>
57+
!enabledPipelines || enabledPipelines.length === 0
58+
|| enabledPipelines.includes(k));
5559

5660
debug('assemble: %j', keys);
5761

test/unit/pipelines/pipelines.test.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@ import Connector from '../../../src/connectors/eventbridge';
1212
describe('pipelines/index.js', () => {
1313
beforeEach(() => {
1414
sinon.stub(Connector.prototype, 'putEvents').resolves({ FailedEntryCount: 0 });
15+
delete process.env.ENABLED_PIPELINES;
1516
delete process.env.DISABLED_PIPELINES;
1617
});
17-
afterEach(sinon.restore);
18+
afterEach(() => {
19+
delete process.env.ENABLED_PIPELINES;
20+
delete process.env.DISABLED_PIPELINES;
21+
sinon.restore();
22+
});
1823

1924
it('should invoke all pipelines', (done) => {
2025
let counter = 0;
@@ -46,6 +51,36 @@ describe('pipelines/index.js', () => {
4651
.done(done);
4752
});
4853

54+
it('should only run enabled pipelines - string', (done) => {
55+
process.env.ENABLED_PIPELINES = 'p1,p1b '; // extra space on purpose
56+
let counter = 0;
57+
58+
const count = (uow) => {
59+
uow.counter = counter++; // eslint-disable-line no-plusplus
60+
return uow;
61+
};
62+
63+
const events = toKinesisRecords([{
64+
type: 't1',
65+
}]);
66+
67+
initialize({
68+
p1: (opt) => (s) => s.map(count),
69+
p1a: (opt) => (s) => s.map(count),
70+
p1b: (opt) => (s) => s.map(count),
71+
})
72+
.assemble(fromKinesis(events), false)
73+
.collect()
74+
.tap((collected) => {
75+
// console.log(JSON.stringify(collected, null, 2));
76+
expect(collected.length).to.equal(2);
77+
expect(counter).to.equal(2);
78+
expect(collected[0].pipeline).to.equal('p1b');
79+
expect(collected[1].pipeline).to.equal('p1');
80+
})
81+
.done(done);
82+
});
83+
4984
it('should ignore disabled pipelines - string', (done) => {
5085
process.env.DISABLED_PIPELINES = 'p1a';
5186
let counter = 0;

0 commit comments

Comments
 (0)