Skip to content
This repository was archived by the owner on Nov 20, 2023. It is now read-only.

Conversation

@kamerat
Copy link
Contributor

@kamerat kamerat commented Oct 8, 2019

After the beautiful work on the pr #139 finally got released, I implemented it to my org's codebase but in the process, I felt it was missing something:

1. Nesting/Grouping of setCommits options

The new options: commit, previousCommit, repo, auto feels a bit polluting in the sentry-webpack-plugin's "global" options scope in my opinion. The key annoying me the most is auto.
auto has no context when seen like this:

const sentryCliPlugin = new SentryCliPlugin({
      release: '42',
      auto: true,
});

My suggestion is to group the setCommits/git options in a object:

const sentryCliPlugin = new SentryCliPlugin({
      release: '42',
      setCommits: {
          auto: true,
          //Other setCommits options here...
      }
});

I modified the code in index.js to reflect this and tried to do the same in the tests. However, the tests are not passing. I have no experience with writing tests sadly, so I do not see what I can do to make them pass. Logging this.options.setCommits gives expecting result 🤷‍♂. Hopefully someone can help me out here if they think this PR is reasonable.

2. Readme changes

I do not know if there is a typo here or if I'm too tired to see that i'm wrong, but it seems to me that the key: repo :

* `repo [optional]` - `string`, the full repo name as defined in Sentry

is indeed not optional:

if (repo && (commit || auto)) {

I don't know about the others, but I think we should do a deeper check to see what is required and what is not.

Yet again, awesome PR! I have been waiting for this for a long time ❤️

@kamerat
Copy link
Contributor Author

kamerat commented Oct 8, 2019

Thoughts, @dmitryrn?

@kamilogorek
Copy link
Contributor

kamilogorek commented Oct 9, 2019

I was thinking about doing that, however, I let it be as is, because this is how sentry-cli implements it – getsentry/sentry-cli@4b913f0#diff-1f9d9d0fe3b1cdb764fff6a8b443cb7dR49-R54

It'd be breaking change now, so we'd have to allow for both versions and just document grouped one. This'd require a change here:

const { commit, previousCommit, repo, auto } = this.options.setCommits || this.options;

This makes it possible to use both nested and non-nested setOptions
@kamilogorek
Copy link
Contributor

kamilogorek commented Oct 9, 2019

Now that your updated README table is merged, can you include the update in this commit as well?

@kamerat
Copy link
Contributor Author

kamerat commented Oct 9, 2019

Now that README includes a table, can you include the update in this commit as well?

It would be my honor. 🛡

Comment on lines 232 to 240
const sentryCliPlugin = new SentryCliPlugin({
include: 'src',
release: '42',
commit: '4d8656426ca13eab19581499da93408e30fdd9ef',
previousCommit: 'b6b0e11e74fd55836d3299cef88531b2a34c2514',
repo: 'group / repo',
// auto,
setCommits: {
commit: '4d8656426ca13eab19581499da93408e30fdd9ef',
previousCommit: 'b6b0e11e74fd55836d3299cef88531b2a34c2514',
repo: 'group / repo',
},
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to add test for both versions of calling SentryCliPlugin({ ..., commit, previousCommit, repo }) and SentryCliPlugin({ ..., setCommits: { commit, previousCommit, repo } })

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds like a good idea! 🎉
Sadly, I don't know how to write them 😭

Copy link
Contributor

@dmitryrn dmitryrn Oct 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this should be fine (from line 231):

  test('test setCommits with commits range', done => {
    const sentryCliPlugin = new SentryCliPlugin({
      include: 'src',
      release: '42',
      commit: '4d8656426ca13eab19581499da93408e30fdd9ef',
      previousCommit: 'b6b0e11e74fd55836d3299cef88531b2a34c2514',
      repo: 'group / repo',
    });

    sentryCliPlugin.apply(compiler);

    setImmediate(() => {
      expect(mockCli.releases.setCommits).toBeCalledWith('42', {
        repo: 'group / repo',
        commit: '4d8656426ca13eab19581499da93408e30fdd9ef',
        previousCommit: 'b6b0e11e74fd55836d3299cef88531b2a34c2514',
      });
      expect(compilationDoneCallback).toBeCalled();
      done();
    });
  });

  test('test setCommits with auto option', done => {
    const sentryCliPlugin = new SentryCliPlugin({
      include: 'src',
      release: '42',
      repo: 'group / repo',
      auto: true,
    });

    sentryCliPlugin.apply(compiler);

    setImmediate(() => {
      expect(mockCli.releases.setCommits).toBeCalledWith('42', {
        repo: 'group / repo',
        auto: true,
      });
      expect(compilationDoneCallback).toBeCalled();
      done();
    });
  });

  test('test setCommits with commits range under setCommits object', done => {
    const sentryCliPlugin = new SentryCliPlugin({
      include: 'src',
      release: '42',
      setCommits: {
        commit: '4d8656426ca13eab19581499da93408e30fdd9ef',
        previousCommit: 'b6b0e11e74fd55836d3299cef88531b2a34c2514',
        repo: 'group / repo',
      },
    });

    sentryCliPlugin.apply(compiler);

    setImmediate(() => {
      expect(mockCli.releases.setCommits).toBeCalledWith('42', {
        repo: 'group / repo',
        commit: '4d8656426ca13eab19581499da93408e30fdd9ef',
        previousCommit: 'b6b0e11e74fd55836d3299cef88531b2a34c2514',
      });
      expect(compilationDoneCallback).toBeCalled();
      done();
    });
  });

  test('test setCommits with auto option under setCommits object', done => {
    const sentryCliPlugin = new SentryCliPlugin({
      include: 'src',
      release: '42',
      setCommits: {
        repo: 'group / repo',
        auto: true,
      },
    });

    sentryCliPlugin.apply(compiler);

    setImmediate(() => {
      expect(mockCli.releases.setCommits).toBeCalledWith('42', {
        repo: 'group / repo',
        auto: true,
      });
      expect(compilationDoneCallback).toBeCalled();
      done();
    });
  });

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I just used the "easy way" by using the patch posted below. Is there something you would like to add on that, or are we good? :D

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are good 🚀

@kamilogorek
Copy link
Contributor

kamilogorek commented Oct 9, 2019

Sadly, I don't know how to write them 😭

tests.patch.zip

@BlitZz96 Download, unzip, git apply <path-to-tests.patch> :)

@kamilogorek
Copy link
Contributor

Also call yarn fix before pushing new changes, it'll fix linting issues for you and CI will be green again

Sølve Tornøe and others added 2 commits October 9, 2019 16:12
Co-authored-by: Kamil Ogórek <kamil.ogorek@gmail.com>
@kamilogorek kamilogorek merged commit 937b360 into getsentry:master Oct 9, 2019
@kamilogorek
Copy link
Contributor

10/10 cooperation skills. v1.9.1 released. Thanks! 🙇‍♂️

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants