Hey all! My team at work is struggling with growing pains of getting into a formalized review process, so I was wondering if any of you guys have some things to live or die by in your code reviews. How much of it is manual, or how much is just static code analysis + style guide stuff, etc?

  • reversebananimals@lemmy.world
    link
    fedilink
    arrow-up
    3
    ·
    edit-2
    1 year ago

    I’m a senior at a large tech company - I push all the teams I work with to automate the review process as much as possible. At minimum, teams must have a CI hook on their pull request process that runs a remote dryrun build of the changed packages. The dryrun makes sure the packages compile, pass unit tests and meet linter rules. A failed build blocks the pull request from being merged.

    I try to encourage developers to turn the outcome of every code style discussion into a lint rule that fails the dryrun build when its violated. It saves time by automating something devs were doing manually anyway (reading every line of code to look for their code style pet peeves) and it also makes the dialogue healthier - devs can talk about the team standards and whether the code meets them, instead of making subjective comments about one another’s code style.

  • cark@beehaw.org
    link
    fedilink
    arrow-up
    3
    ·
    edit-2
    1 year ago

    Current place:

    • Work is done on a feature branch on a personal fork of the repo
    • Codebase requires 100% functional coverage, and you’re responsible for writing the tests for your code and including that in the same PR
    • Run pre-commit hooks for style auto-formatters before you can commit and push your code to your origin fork
    • Ideally run local tests as well
    • Create a PR to pull feature branch into the upstream repo’s main branch, which triggers the CI pipeline for style and tests
    • At least 1 other person must review the code before a PR can be approved and merged into upstream main
    • There’s a separate CI pipeline for testing of publishing the packages to TestPyPI
    • Releases to PyPI are currently done manually
  • pnelego@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 year ago

    Small startup - Here is our process

    • Create your branch
    • Implement feature
    • Test independently of other components (with unit tests or otherwise)
    • Test directly with other componenets
    • Work with other devs to ensure stability on dev branch, make any small bug fixes directly in dev branch
    • Push to prod
  • dalarist@programming.dev
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    We’ve got 20 or so devs and some infrequent contributors commiting to a pair of mono-repos, with some extra steps between them.

    Our process looks like this:

    • develop on a feature branch
    • get two or more reviewers, sometimes devs that you’ve been talking with about the design, but if you don’t know who we have a list of devs for different product areas.
    • only our newest stuff has auto-linting, otherwise style and static code analysis is all manual, but we’re trying to automate as we go
    • need at least one approval to merge, not by any got rules, just by convention

    All the code reviews are asynchronous, we’re a distributed team so we don’t like sit down in a room to talk about it, just comments on the PR.

    Sometimes however you find a fix so small, you just commit and push to master. I’m not really in favor of that, but it happens.

    • mustyOrange@beehaw.org
      link
      fedilink
      arrow-up
      0
      ·
      edit-2
      1 year ago

      Midwestern b tier company:

      1. Test your code on its own branch. Make sure it’s not fucked

      2. Pr to dev, do code review with devs that call you out on your bullshit (were all lazy sometimes)

      3. Whip up QA doc, send the ticket to the QA queue

      4. Confirm with BU that all their bases are covered and nothing is missing

      5. Repeat steps for inevitable wishy washy scope creep from BA who wants to have inevitable meetings that could be done in emails

      6. Complete merge to dev, merge dev to master, and tell devops that it’s ready to go

      • pattern@beehaw.orgOP
        link
        fedilink
        arrow-up
        1
        ·
        1 year ago

        Ah yes, sounds about right. I particularly prefer the “make sure it’s not fucked” step, very effective😂 I’d like to get more formal code reviews in place with my current team, I think we could all benefit.

  • vraylle@beehaw.org
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    1 year ago

    We use a version of Git Flow for branching (since everyone is talking about branching strategies here). But technically, you asked specifically about code review process. Every ticket is it’s own branch against the development branch, and when complete is merged by PR into the development branch. We’re a small team, so our current process is:

    1. Merges to the development branch require one approval
    2. Merges to the main branch for a release require two approvals
    3. If the changes are only code, any developer can review and approve
    4. If there are “significant” SQL changes a DBA approval is required.
      • “significant” means a new entity in the DB, or…
      • an inline/Dapper query with a join

    As we grow we’ll probably have to silo more and require specific people’s approval for specific areas.

    A lot of what we do is “cultural”, like encouraging readability, avoiding hard-coded values, and fixing issues near the altered code even when not related to the original ticket. The key is to be constructive. The goal is better code, not competition. So far we have the right people for that to work.

  • macniel@feddit.de
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago

    have you looked at Git Flow? Its pretty solid.

    My team has a develop branch from which we branch feature branches. On it we commit our stuff and when we think its feature complete we build a snapshot version of it so that our QA can test it. Once that test was successful, and the code has been peer reviewed, it will be merged back onto develop.

    PRs will be auto built so that the feature can be integrated and automated tested.

    • flintcedar@beehaw.org
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      There is trunk based way. Although I have not used it heavily at work. https://trunkbaseddevelopment.com/

      My team is very small (3 people). We mostly trust each other on just merging away without PR reviews. Although we ask for reviews when in doubt during development, not when ready to merge. Mostly for asking ideas on where to put stuff.

      On my previous work, we were like a 15+ dev team, doing mandatory PR reviews before merging and doing the shotgun request (ping @review_channel and pray). I hated it.