Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

@lifeomic/bitrise

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lifeomic/bitrise - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

2

package.json
{
"name": "@lifeomic/bitrise",
"version": "0.0.2",
"version": "0.1.0",
"description": "Bitrise API client",

@@ -5,0 +5,0 @@ "main": "src/client.js",

@@ -38,4 +38,10 @@ bitrise

- **commitHash** — the hash of the commit to checkout of SCM. By default
the `master` branch is run.
- **branch** — the branch to run (or the source of a pull request). The
default is `master`.
- **commitHash** — the hash of the commit to checkout of SCM. If not provided
then the `branch` parameter is used.
- **commitMessage** — a description to include on the build.
- **disableStatusReporting** — disable sending status reports to SCM.
- **pullRequest** — the ID of the pull request being built.
- **target** — the destination branch of the pull request.
- **workflow** — the ID of the Bitrise workflow to run.

@@ -52,2 +58,10 @@

### async build.abort({ reason })
Abort the build. If supplied the `reason` string will be included in the build
details.
References:
- https://devcenter.bitrise.io/api/v0.1/#post-appsapp-slugbuildsbuild-slugabort
### async build.describe()

@@ -54,0 +68,0 @@

const build = require('./build');
const isNil = require('lodash/isNil');
const negate = require('lodash/negate');
const pickBy = require('lodash/pickBy');
const project = require('../package.json');
const buildParameters = ({ commitHash, workflow }) => {
const parameters = {};
const buildParameters = (
{ branch, commitHash, commitMessage, disableStatusReporting, pullRequest, target, workflow }
) => pickBy(
{
branch: branch || 'master',
branch_dest: target,
commit_hash: commitHash,
commit_message: commitMessage,
pull_request_id: pullRequest,
skip_git_status_report: disableStatusReporting,
workflow_id: workflow
},
negate(isNil)
);
if (commitHash) {
parameters.commit_hash = commitHash;
} else {
parameters.branch = 'master';
}
if (workflow) {
parameters.workflow_id = workflow;
}
return parameters;
};
const triggerBuild = async ({ client, slug }, options = {}) => {

@@ -21,0 +23,0 @@ const buildOptions = {

@@ -0,1 +1,10 @@

const abortBuild = async ({ appSlug, buildSlug, client }, options = {}) => {
if (options.reason) {
await client.post(`/apps/${appSlug}/builds/${buildSlug}/abort`, { abort_reason: options.reason });
return;
}
await client.post(`/apps/${appSlug}/builds/${buildSlug}/abort`);
};
const describeBuild = async ({ appSlug, buildSlug, client }) => {

@@ -47,2 +56,3 @@ const response = await client.get(`/apps/${appSlug}/builds/${buildSlug}`);

build.abort = abortBuild.bind(build, state);
build.describe = describeBuild.bind(build, state);

@@ -49,0 +59,0 @@ build.follow = followBuild.bind(build, state);

@@ -64,2 +64,23 @@ const app = require('../src/app');

test('a commit message can be included on a build', async (test) => {
const { app, client, slug } = test.context;
const commitMessage = uuid();
const stub = stubTriggerBuild({ appSlug: slug, axios: client });
const build = await app.triggerBuild({ commitMessage });
test.is(build.appSlug, slug);
test.is(build.buildSlug, stub.build.build_slug);
sinon.assert.calledOnce(client.post);
sinon.assert.calledWithExactly(
client.post,
sinon.match.string,
sinon.match({
build_params: { commit_message: commitMessage },
hook_info: { type: 'bitrise' },
triggered_by: '@lifeomic/bitrise'
})
);
});
test('an app can trigger a specific build workflow', async (test) => {

@@ -85,1 +106,84 @@ const { app, client, slug } = test.context;

});
test('build status reporting can be disabled', async (test) => {
const { app, client, slug } = test.context;
const stub = stubTriggerBuild({ appSlug: slug, axios: client });
const build = await app.triggerBuild({ disableStatusReporting: true });
test.is(build.appSlug, slug);
test.is(build.buildSlug, stub.build.build_slug);
sinon.assert.calledOnce(client.post);
sinon.assert.calledWithExactly(
client.post,
sinon.match.string,
sinon.match({
build_params: { skip_git_status_report: true },
hook_info: { type: 'bitrise' },
triggered_by: '@lifeomic/bitrise'
})
);
});
test('a pull request ID can be assigned to a build', async (test) => {
const { app, client, slug } = test.context;
const pullRequest = uuid();
const stub = stubTriggerBuild({ appSlug: slug, axios: client });
const build = await app.triggerBuild({ pullRequest });
test.is(build.appSlug, slug);
test.is(build.buildSlug, stub.build.build_slug);
sinon.assert.calledOnce(client.post);
sinon.assert.calledWithExactly(
client.post,
sinon.match.string,
sinon.match({
build_params: { pull_request_id: pullRequest },
hook_info: { type: 'bitrise' },
triggered_by: '@lifeomic/bitrise'
})
);
});
test('a target branch can be included on a build', async (test) => {
const { app, client, slug } = test.context;
const target = uuid();
const stub = stubTriggerBuild({ appSlug: slug, axios: client });
const build = await app.triggerBuild({ target });
test.is(build.appSlug, slug);
test.is(build.buildSlug, stub.build.build_slug);
sinon.assert.calledOnce(client.post);
sinon.assert.calledWithExactly(
client.post,
sinon.match.string,
sinon.match({
build_params: { branch_dest: target },
hook_info: { type: 'bitrise' },
triggered_by: '@lifeomic/bitrise'
})
);
});
test('a source branch can be included on a build', async (test) => {
const { app, client, slug } = test.context;
const branch = uuid();
const stub = stubTriggerBuild({ appSlug: slug, axios: client });
const build = await app.triggerBuild({ branch });
test.is(build.appSlug, slug);
test.is(build.buildSlug, stub.build.build_slug);
sinon.assert.calledOnce(client.post);
sinon.assert.calledWithExactly(
client.post,
sinon.match.string,
sinon.match({
build_params: { branch },
hook_info: { type: 'bitrise' },
triggered_by: '@lifeomic/bitrise'
})
);
});

@@ -8,3 +8,3 @@ const axios = require('axios');

const { DateTime } = require('luxon');
const { stubArchivedBuildLog, stubBuildLogStream, stubGetBuild } = require('./stubs');
const { stubAbortBuild, stubArchivedBuildLog, stubBuildLogStream, stubGetBuild } = require('./stubs');

@@ -143,1 +143,20 @@ test.beforeEach((test) => {

});
test('a build can be aborted', async (test) => {
const { appSlug, build, buildSlug, client } = test.context;
const stub = stubAbortBuild({ appSlug, axios: client, buildSlug });
await build.abort();
sinon.assert.calledWithExactly(stub, sinon.match.string);
});
test('a build can be aborted with a reason', async (test) => {
const { appSlug, build, buildSlug, client } = test.context;
const reason = uuid();
const stub = stubAbortBuild({ appSlug, axios: client, buildSlug });
await build.abort({ reason });
sinon.assert.calledWithExactly(
stub,
sinon.match.string,
sinon.match({ abort_reason: reason })
);
});

@@ -25,2 +25,14 @@ const get = require('lodash/get');

exports.stubAbortBuild = ({ appSlug, axios, buildSlug }) => {
const stub = getStub(axios, 'post');
stub.withArgs(`/apps/${appSlug}/builds/${buildSlug}/abort`)
.resolves({
data: { status: 'ok' },
status: 200
});
return stub;
};
exports.stubArchivedBuildLog = ({ appSlug, axios, buildSlug, logText }) => {

@@ -27,0 +39,0 @@ const logUrl = 'http://localhost/logs/example.txt';

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc