• lemmeBe
    link
    fedilink
    arrow-up
    10
    arrow-down
    2
    ·
    1 天前

    Do formatting and linting and such autofix issues automatically as part of pre-commit checks. That way they don’t end up as part of the CI.

    • FizzyOrange@programming.dev
      link
      fedilink
      arrow-up
      5
      arrow-down
      1
      ·
      10 小时前

      You need them in CI anyway to check people have actually done that, but yeah you definitely don’t need to have CI automatically fix formatting and commit the fixes. That’s crazy.

      • lemmeBe
        link
        fedilink
        arrow-up
        1
        arrow-down
        4
        ·
        edit-2
        9 小时前

        No, you don’t.

        To check if people have done what - committed? That’s the only thing they need to do, and they’ll stumble upon a roadblock immediately if the typecheck or lint fails.

        Committing itself won’t be possible… That’s why we have automated pre-commit checks that don’t depend on people remembering to do them manually.

        • FizzyOrange@programming.dev
          link
          fedilink
          arrow-up
          3
          arrow-down
          1
          ·
          8 小时前

          To check that people ran the pre-commit linters.

          Committing itself won’t be possible

          That’s not how pre-commit hooks work. They’re entirely optional and opt-in. You need CI to also run them to ensure people don’t forget.

          • lemmeBe
            link
            fedilink
            arrow-up
            1
            arrow-down
            2
            ·
            6 小时前

            They’re optional if you make them optional. I didn’t. You do as you please. 😄

            • FizzyOrange@programming.dev
              link
              fedilink
              arrow-up
              2
              ·
              6 小时前

              No, they’re inherently optional in Git. There’s no way to “check in” a git hook. You have to put in your README

              Clone the repo and then please run pre-commit install! Oh and whatever you do don’t git commit --no-verify!

              You definitely need to actually check the lints in CI. It’s very easy though, just add pre-commit run -a to your CI script.

    • catalyst@lemmy.world
      link
      fedilink
      arrow-up
      6
      ·
      1 天前

      Agreed. The idea of throwing code up at the CI and expecting it to fix my mistakes seems like a bad habit to me.

      • lemmeBe
        link
        fedilink
        arrow-up
        5
        ·
        1 天前

        Yep, I’d say so too. The moment I read the part about formatting in the CI, I thought to myself: I don’t think GitHub Actions are the problem at hand. 😄

    • Flipper@feddit.org
      link
      fedilink
      arrow-up
      1
      ·
      1 天前

      If it’s open source I’d still add it, because a lot of people can’t follow basic instructions.

      • lemmeBe
        link
        fedilink
        arrow-up
        3
        arrow-down
        2
        ·
        22 小时前

        They don’t have to follow anything except try to commit their changes. Won’t be possible even locally if linting or typechecking fail.

    • normalexit@lemmy.world
      link
      fedilink
      arrow-up
      3
      ·
      1 天前

      This is the way. I do my checks on pre push because my team has a PR driven workflow. I also have an alias to run-tests && git push origin HEAD since my tests are expensive (minutes to run thousands of tests), and I didn’t want that in a git hook.