github.com/joshdk/godel@v0.0.0-20170529232908-862138a45aee/docs/Configuration.md (about) 1 Configuration 2 ============= 3 gödel projects are configured using YML files in the "godel/config" directory. The YML files in that directory specify 4 the declarative configuration for various different aspects of gödel projects. 5 6 Overview 7 -------- 8 9 The following is a list of the supported configuration files: 10 11 | File | Tasks | Struct definitions | 12 | ---- | ----- | ------------------ | 13 | `check.yml` | `check`, `verify` | [apps/okgo/config/config.go] | 14 | `dist.yml` | `artifacts`, `build`, `dist`, `products`, `publish`, `run` | [apps/distgo/config/config.go] | 15 | `exclude.yml` | All | [config/config.go] | 16 | `format.yml` | `format`, `verify` | [apps/gonform/config/config.go] | 17 | `imports.yml` | `imports`, `verify` | [vendor/github.com/palantir/checks/gocd/config/config.go] | 18 | `license.yml` | `license`, `verify` | [vendor/github.com/palantir/checks/golicense/config/config.go] | 19 | `test.yml` | `test`, `verify` | [apps/gunit/config/config.go] | 20 21 check.yml 22 --------- 23 `check.yml` configures the `check` task. It controls which checks are run and allows the checks to be customized. The 24 configuration can be used to disable specific checks, specify command-line arguments that should be provided to a check, 25 or white-list/ignore failure output based on the message, path or name of the file. 26 27 The default behavior runs all checks with no custom arguments and no ignored output. 28 29 The configuration consists of a top-level map named `checks` where the key is the name of the check (`compiles`, 30 `deadcode`, `errcheck`, etc.) and the value is the configuration for that check. 31 32 Example configuration: 33 34 ```yml 35 checks: 36 errcheck: 37 # specify custom command-line arguments provided to the check when run 38 args: 39 - "-ignore" 40 - "github.com/cihub/seelog:(Info|Warn|Error|Critical)f?" 41 golint: 42 filters: 43 # if "type" is unspecified, defaults to "message". Filters (ignores) output generated by the check if the message 44 # matches the provided pattern (regexp). 45 - value: "and that stutters" 46 # "path" and "name" are also valid types. 47 - type: path 48 value: "github.com/org/project/file.go" 49 outparamcheck: 50 # if "skip" is set to true, the check is skipped entirely. 51 skip: true 52 ``` 53 54 For further documentation on individual fields and parameters, refer to the [config documentation](https://godoc.org/github.com/palantir/godel/apps/okgo/config). 55 56 dist.yml 57 -------- 58 `dist.yml` specifies the project structure and controls the behavior of the project and product-related tasks, which 59 are `artifacts`, `build`, `dist`, `products`, `publish` and `run`. 60 61 The configuration consists of a top-level map named `products`, where the key is the name of the product (this is the 62 name that will be used to specify the product to commands such as `build` and `dist`) and the value is the configuration 63 for the product. A product is a `main` package meant to be built and distributed. 64 65 The `build` configuration for a product specifies parameters related to building the executable, including things such 66 as the location of the `main` package, the directory in which the executables should be built, parameters that should be 67 provided to the `build` command and the OS/architecture combinations for which the executable(s) should be built. 68 69 The `dist` configuration for a product specifies parameters related to building the distribution artifact for a product. 70 A distribution artifact is typically a single file (such as a `tgz` or `RPM`) that is generated that contains the 71 executables built by the `build` task and other supporting files such as default configuration. The output artifacts of 72 the `dist` task are also the artifacts that are published by the `publish` task. Because creating a distribution can 73 often involve many customized steps (such as downloading external dependencies), the configuration supports specifying 74 a bash script that can be run as part of the distribution task to create the distribution for a product. 75 76 Example configuration: 77 78 ``` 79 products: 80 distgo: 81 build: 82 output-dir: ./apps/distgo/build 83 main-pkg: ./apps/distgo/main/distgo 84 environment: 85 CGO_ENABLED: "0" 86 version-var: github.com/palantir/godel/cmd/godel.Version 87 dist: 88 output-dir: ./apps/distgo/dist 89 dist-type: 90 type: bin 91 info: 92 omit-init-sh: true 93 example: 94 build: 95 main-pkg: ./example/main/example 96 output-dir: example/build/bin 97 os-archs: 98 - os: linux 99 arch: amd64 100 dist: 101 output-dir: example/build/distributions 102 dist-type: 103 type: sls 104 script: | 105 echo $(date +%Y-%m-%d.%H:%M:%S) >> "$DIST_DIR/timestamp.txt" 106 ``` 107 108 For further documentation on individual fields and parameters, refer to the [config documentation](https://godoc.org/github.com/palantir/godel/apps/distgo/config). 109 110 exclude.yml 111 ----------- 112 `exclude.yml` specifies the files and directories that should be excluded from gödel tasks. This configuration is used 113 by most of the gödel sub-tasks, so if there are files or directories that should always be excluded from tasks 114 (generated source, vendored files, etc.), they should be defined here. 115 116 ### names 117 Regular expressions that match the names of the files or directories that should be excluded. Uses the 118 [Go regular expression syntax](https://golang.org/pkg/regexp/). 119 120 ### paths 121 Relative file paths (which can contain [globs](https://golang.org/pkg/path/filepath/#Glob)) that match the names of the 122 files or directories that should be excluded. 123 124 ### Example 125 126 The default file contains the following configuration: 127 128 ```yml 129 names: 130 - "\\..+" 131 - "vendor" 132 paths: 133 - "godel" 134 ``` 135 136 This configuration excludes all hidden files and directories (those that start with `.`) and all `vendor` directories in 137 the project and also excludes the `godel` directory located in the root of the project (which is where the configuration 138 is stored). 139 140 format.yml 141 ---------- 142 `format.yml` configures the `format` task. This configuration file can be used to customize the arguments that are 143 provided to the formatters. 144 145 The configuration consists of a top-level map named `formatters`, where the key is the name of the formatter (`gofmt` or 146 `ptimports`) and the value is the configuration for that formatter. The configuration for the formatter can be used to 147 customize the command-line flags provided to the formatters. 148 149 The default file contains the following configuration: 150 151 ```yml 152 formatters: 153 gofmt: 154 args: 155 - "-s" 156 ``` 157 158 This configuration runs `gofmt` with the `-s` flag to make it simplify the code for the files on which it is run. 159 160 For further documentation on individual fields and parameters, refer to the [config documentation](https://godoc.org/github.com/palantir/godel/apps/gonform/config). 161 162 imports.yml 163 ----------- 164 `imports.yml` configures the `imports` task, which runs [`gocd`](https://github.com/palantir/checks/tree/master/gocd/config). 165 The `imports.yml` file specifies the directories that should be considered "root" directories that should be analyzed by 166 `gocd` -- directories that are specified as root directories will have a `gocd_imports.json` file produced and verified 167 for it. 168 169 Example configuration: 170 171 ```yml 172 root-dirs: 173 - pkg 174 ``` 175 176 For further documentation on individual fields and parameters, refer to the [config documentation](https://godoc.org/github.com/palantir/godel/vendor/github.com/palantir/checks/gocd/config). 177 178 license.yml 179 ----------- 180 `license.yml` configures the `license` task, which runs [`golicense`](https://github.com/palantir/checks/tree/master/golicense). 181 The `license.yml` file specifies the license header that should be applied to all of the non-excluded `.go` files in the 182 project. If different files in the project should have different license headers, overrides can also be configured using 183 this file. 184 185 Example configuration: 186 187 ``` 188 header: | 189 // Copyright 2016 Palantir Technologies, Inc. 190 // 191 // Licensed under the Apache License, Version 2.0 (the "License"); 192 // you may not use this file except in compliance with the License. 193 // You may obtain a copy of the License at 194 // 195 // http://www.apache.org/licenses/LICENSE-2.0 196 // 197 // Unless required by applicable law or agreed to in writing, software 198 // distributed under the License is distributed on an "AS IS" BASIS, 199 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 // See the License for the specific language governing permissions and 201 // limitations under the License. 202 203 custom-headers: 204 - name: outparamcheck 205 header: | 206 // Copyright 2016 Palantir Technologies, Inc. All rights reserved. 207 // Licensed under the MIT License. See LICENSE in the project root 208 // for license information. 209 210 paths: 211 - outparamcheck 212 - name: outparamcheck-custom 213 header: | 214 // Copyright 2013 Kamil Kisiel 215 // Modifications copyright 2016 Palantir Technologies, Inc. 216 // Licensed under the MIT License. See LICENSE in the project root 217 // for license information. 218 219 paths: 220 - outparamcheck/exprs 221 - outparamcheck/outparamcheck/error.go 222 - outparamcheck/outparamcheck/outparamcheck.go 223 - outparamcheck/outparamcheck/outparamcheck_test.go 224 ``` 225 226 For further documentation on individual fields and parameters, refer to the [config documentation](https://godoc.org/github.com/palantir/godel/vendor/github.com/palantir/checks/golicense/config). 227 228 test.yml 229 -------- 230 `test.yml` configures the `test` task. It can be used to specify and define test "tags" that match certain files or 231 paths in the project. Tests that match a tag are only run when explicitly specified using the `--tags` flag for the 232 `test` task. 233 234 Example configuration: 235 236 ``` 237 tags: 238 integration: 239 names: 240 - "^integration$" 241 ``` 242 243 For further documentation on individual fields and parameters, refer to the [config documentation](https://godoc.org/github.com/palantir/godel/apps/gunit/config).