Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check format for Continous integration

I am trying to write a Makefile command that will output an error if the Go code is not correctly formatted. This is for a CI step. I am struggling with how to get it working in the make file. This solution works on the bash command line:

! gofmt -l . 2>&1 | read

But copying this into the Makefile:

ci-format:
    @echo "$(OK_COLOR)==> Checking formatting$(NO_COLOR)"
    @go fmt ./...
    @! gofmt -l . 2>&1 | read

I get the following error:

/bin/sh: 1: read: arg count
like image 269
snorberhuis Avatar asked Feb 28 '17 13:02

snorberhuis


People also ask

What is check-in in continuous integration?

Continuous Integration is a practice where code is checked in by the developers on the source code repository regularly and after every check-in, there are automated steps to approve the integrations. The integrated code is usually tested with the help of automated test cases that are executed after every check-in.

Which of the following point is to check before starting continuous integration?

Check-In Regularly − The most important practice for continuous integration to work properly is frequent check-ins to trunk or mainline of the source code repository. The check-in of code should happen at least a couple of times a day.

What are the three basic steps of continuous integration?

Continuous integration, deployment, and delivery are three phases of an automated software release pipeline, including a DevOps pipeline. These three phases take software from idea to delivery to the end-user. The integration phase is the first step in the process.

What is an example of continuous integration?

Here's a typical continuous integration workflow that Semaphore users practice on a daily basis: A developer creates a new branch of code in GitHub, makes changes in the code, and commits them. When the developer pushes her work to GitHub, Semaphore builds the code and then runs the automated test suite.

What is continuous integration in software testing?

Continuous Integration. Continuous Integration (CI) is the process of taking features from the Program Backlog and developing, testing, integrating, and validating them in a staging environment where they are ready for deployment and release.

How do I create custom continuous integration (CI) workflows?

You can create custom continuous integration (CI) workflows directly in your GitHub repository with GitHub Actions. Continuous integration (CI) is a software practice that requires frequently committing code to a shared repository.

What are the key indicators of continuous integration maturity?

Version control – Effective version control allows teams to recover quickly from problems and to improve quality by making sure the right components are integrated together. Aggregating assets under version control is a leading indicator of continuous integration maturity.

What is continuous integration in the context of continuous delivery pipeline?

Continuous integration in the context of the continuous delivery pipeline. Continuous integration is a critical technical practice for each Agile Release Train (ART). It improves quality, reduces risk, and establishes a fast, reliable, and sustainable development pace.


1 Answers

These days, I use golangci-lint, which includes gofmt checking as an option.

But if for some reason you want to do this yourself, the command I previously used for precisely that purpose is:

diff -u <(echo -n) <(gofmt -d ./)

See, for example, the .travis.yml files on one of my projects.

like image 85
Flimzy Avatar answered Sep 25 '22 02:09

Flimzy