github.com/jonsyu1/godel@v0.0.0-20171017211503-64567a0cf169/docs/Verify.md (about)

     1  Summary
     2  -------
     3  The `verify` task can be used to perform all of the primary operations and checks for a project.
     4  
     5  Tutorial start state
     6  --------------------
     7  
     8  * `$GOPATH/src/github.com/nmiyake/echgo` exists and is the working directory
     9  * Project contains `godel` and `godelw`
    10  * Project contains `main.go`
    11  * Project contains `.gitignore` that ignores IDEA files
    12  * Project contains `echo/echo.go`, `echo/echo_test.go` and `echo/echoer.go`
    13  * `godel/config/dist.yml` is configured to build `echgo`
    14  * Project is tagged as 0.0.1
    15  * `godel/config/dist.yml` is configured to create distributions for `echgo`
    16  * Project is tagged as 0.0.2
    17  * Go files have license headers
    18  * `godel/config/generate.yml` is configured to generate string function
    19  * `godel/config/exclude.yml` is configured to ignore all `.+_string.go` files
    20  * `integration_test` contains integration tests
    21  * `godel/config/test.yml` is configured to specify the "integration" tag
    22  * `docs` contains documentation
    23  
    24  ([Link](https://github.com/nmiyake/echgo/tree/17c7406291096306e92c6f82da2df09388766693))
    25  
    26  Verify a project
    27  ----------------
    28  
    29  Over the course of this tutorial, we have configured and used many different tasks -- `format` to format code, `check`
    30  to run static checks, `generate` to run "go generate" tasks, `license` to apply license headers and `test` to run tests,
    31  among others. Remembering to run all of these tasks separately can be a challenge -- in most cases, we simply want to
    32  make sure that all of the tasks are run properly and that our code is working.
    33  
    34  The `./godelw verify` task can be used to do exactly this -- it runs the `format`, `generate`, `license`, `check` and
    35  `test` tasks. This single task is typically sufficient to ensure that all of the code for a project meets the
    36  declarative specifications and that all of the tests in the project pass.
    37  
    38  Run `./godelw verify` to verify that it runs all the tasks and succeeds:
    39  
    40  ```
    41  ➜ ./godelw verify
    42  Running gofmt...
    43  Running ptimports...
    44  Running gogenerate...
    45  Running gocd...
    46  Running golicense...
    47  Running compiles...
    48  Running deadcode...
    49  Running errcheck...
    50  Running extimport...
    51  Running golint...
    52  Running govet...
    53  Running importalias...
    54  Running ineffassign...
    55  Running nobadfuncs...
    56  Running novendor...
    57  Running outparamcheck...
    58  Running unconvert...
    59  Running varcheck...
    60  ok  	github.com/nmiyake/echgo                 	0.160s [no tests to run]
    61  ok  	github.com/nmiyake/echgo/echo            	0.185s
    62  ok  	github.com/nmiyake/echgo/generator       	0.166s [no tests to run]
    63  ok  	github.com/nmiyake/echgo/integration_test	1.279s
    64  ```
    65  
    66  Tutorial end state
    67  ------------------
    68  
    69  * `$GOPATH/src/github.com/nmiyake/echgo` exists and is the working directory
    70  * Project contains `godel` and `godelw`
    71  * Project contains `main.go`
    72  * Project contains `.gitignore` that ignores IDEA files
    73  * Project contains `echo/echo.go`, `echo/echo_test.go` and `echo/echoer.go`
    74  * `godel/config/dist.yml` is configured to build `echgo`
    75  * Project is tagged as 0.0.1
    76  * `godel/config/dist.yml` is configured to create distributions for `echgo`
    77  * Project is tagged as 0.0.2
    78  * Go files have license headers
    79  * `godel/config/generate.yml` is configured to generate string function
    80  * `godel/config/exclude.yml` is configured to ignore all `.+_string.go` files
    81  * `integration_test` contains integration tests
    82  * `godel/config/test.yml` is configured to specify the "integration" tag
    83  * `docs` contains documentation
    84  
    85  ([Link](https://github.com/nmiyake/echgo/tree/17c7406291096306e92c6f82da2df09388766693))
    86  
    87  Tutorial next step
    88  ------------------
    89  
    90  [Set up CI to run tasks](https://github.com/palantir/godel/wiki/CI-setup)
    91  
    92  More
    93  ----
    94  
    95  ### Verify that a project complies with checks without applying changes
    96  
    97  The `--apply=false` flag can be used to run `verify` in a mode that verifies that the project passes checks without
    98  actually modifying it. Specifically, it runs the `format`, `generate` and `license` tasks in a mode that verifies that
    99  the project complies with the settings without modifying the project. The task exits with a non-0 exit code if any of
   100  the verifications fail. This task is suitable to run in a CI environment where one wants to verify that a project passes
   101  all of its checks without actually modifying it.
   102  
   103  The one exception to this principle is the `generate` task. Because `go generate` can run arbitrary tasks, there is no
   104  general way in which verification can be performed besides running the `generate` tasks and comparing the state of the
   105  impacted files before and after the task was run. Running `generate` with the `--apply=false` flag will print
   106  information about how the state after the run differs from the state before the run for the files specified in the
   107  configuration and will cause the verification to fail if differences exist, but the modification will have already been
   108  made and will persist after the task.
   109  
   110  ### Skip specific tasks
   111  
   112  In some cases, you may want to run `verify` but skip specific aspects of it -- for example, if the `generate` task takes
   113  a long time to run and you want to run all verification tasks except for `generate`, you can use the `--skip-generate`
   114  flag to skip the generation step. Run `./godelw verify --help` for a full list of the skip flags.