42 Commits

Author SHA1 Message Date
Alexander Hughes
abb28716c8 [#81] makefile to check for unused test data
This change adds logic to the docker-image-unit-tests to ensure that
code is checked within the container for coverage, valid test data,
and reduces the number of containers created in the gate - reducing
the runtime of each gate.

Relates-To: #81

Change-Id: Iab3d9bd74266d32404e6eb06ecebc234df04fd5c
Signed-off-by: Alexander Hughes <Alexander.Hughes@pm.me>
2020-03-08 00:05:48 +00:00
Zuul
15d45199a8 Merge "[#58] Add golint" 2020-03-06 20:25:55 +00:00
Ian Howell
e8892c4e99 [#58] Add golint
This adds the golint linter to the `make lint` target. As of this
commit, the results from golint are not counted as errors. Further
changes to the code will be required to bring it up to golint's
standards, at which point we will allow golint to cause failures for the
`lint` target.

Change-Id: I34134e3deb080e6da0bc0aac299caca6c3b5d0a9
2020-02-26 11:15:10 -06:00
Drew Walters
bcfcd6f9a0 [#33] Publish airshipctl image on Quay
This change introduces a job that publishes the latest airshipctl image
to quay.io/airshipit/airshipctl each time a new change is merged.

Closes #33

Change-Id: I8468b10a8064333d1749015960151e98adb2be97
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-02-26 10:49:22 -06:00
Drew Walters
c834b2d22f [#59] Publish documentation output to html dir
OpenDev publishes Ansible roles that enable documentation previews.
These roles expect an html or pdf directory in the Sphinx build dir.
This change updates the documentation output directory to the
doc/build/html so documentation previews are available on each PS.

Related #59

Change-Id: I0853f603b6bc147e7fc33834b5d195c16f71d5ab
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-02-20 11:21:04 -06:00
Drew Walters
3a5f25c22e [#59] Build docs with Python 3
Most systems have /usr/bin/python, the interpreter the airshipctl
Makefile uses to build documentation, linked to an end-of-life
interpreter. This change updates the Makefile to use the Python 3
interpreter.

Related #59

Change-Id: I19b4d623a5a76dc455184bac2f54d8bfe0947530
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-02-20 10:16:47 -06:00
Ian Howell
9d72a01fc3 [#41] Update make godoc target
Ideally, installing and using an external tool should not modify the
go.mod or go.sum files in anyway. Unfortunately, this may not be
completely possible until Go1.14
(https://github.com/golang/go/issues/30515). This change prevents the
godoc target from modifying the go.mod file, though there may still be
anomalies with modifying the go.sum file (e.g. this change).

Further, since the godoc tool defaults to -goroot=$(go env GOROOT), it
doesn't make sense to provide a default value for -goroot, as it may not
be what the user has set as $(go env GOROOT)

Change-Id: I92de6bf8af4c00464b857db363bd07fdb55ee143
2020-02-12 11:06:10 -06:00
Ian Howell
1b8a965105 Add a simple whitespace linter
The goimports tool does not check for trailing whitespaces in multiline
strings. This commit adds a simple linter to address this deficiency.

This change will also have the benefit of providing light linting of any
non-go files.

Change-Id: I253dd7c4895f476fa3a6f0c4fccf7c9cada16366
2020-01-15 10:57:44 -06:00
Ian H. Pittwood
b8a2bb3b27 Updates to Makefile
Implements `make docs` command to create rtd-themed docs using Sphinx
from the existing Markdown documents in the docs directory.

Changes the `get-modules` command to `depend` to more closely match
OpenStack guidelines in [0].

Adds `fmt` command as specified in [0], currently referencing the `lint`
command.

Adds `godoc` command that will host a local godoc server instance with a
link directly to airshipctl technical documentation.

Adds `releasenotes` commands specified in [0], currently
noted as "TODO".

Adds `images` command as found in other Airship projects, referencing
`docker-image`.

[0] https://governance.openstack.org/tc/reference/pti/golang.html

Change-Id: I134fc2c2714bce6d23dc9cf8b86c3016d68def7e
2020-01-10 09:20:10 -06:00
Ian H. Pittwood
5b7de06eec Add proxy options to Makefile docker build
Adds options relating to proxy settings in the Makefile to be used
during the execution of docker build. The settings are optional to be
used and are set up similarly to other Airship projects such as [0] and
[1].

To set proxy settings during docker build, execute the command as
follows:

```
make docker-image \
  -e PROXY=<The proxy URL> \
  -e NO_PROXY=<comma-separated list of URLs/IPs not using the proxy> \
  -e USE_PROXY=true
```

[0] https://opendev.org/airship/pegleg/src/branch/master/Makefile
[1] https://opendev.org/airship/promenade/src/branch/master/Makefile

Change-Id: I92258465d9638b40797d38ba5d8b835fc38df23f
2019-12-19 18:22:41 +00:00
Ian Howell
7ecae507e0 Add make tidy to check for up-to-date go.mod
This commit adds the `tidy` target. This target will fail if the go.mod
or go.sum files are not up to date with the code. It will also be a
prerequisite to the `lint` command, implying that it will also be caught
by the Zuul gates.

Change-Id: Ie33de2d793beca100435670346eb0e2ea7b3b0dd
2019-11-15 09:41:41 -06:00
Zuul
1a1a9391ed Merge "Fix the make cover target" 2019-11-05 15:52:14 +00:00
Ian Howell
6fb4af06a1 Fix the make cover target
This change has multiple benefits:

* Allows testing/coverage Makefile flags to be set from the command
  line. This allows a dev to easily test both correctness and coverage of
  a subset of packages by simply providing a value for the `PKG` make
  variable.

* Fixes an issue where an error message was being printed to stderr on
  each Zuul run, since the `COVER_PKG` variable required that Go is
  installed, and yet we don't install Go to the Zuul VM.

* Fixes an issue where Zuul VMs were crashing due to an Out Of Memory
  error. This was happening because of the way that the `coverpkg` flag
  works, which caused tests to occasionally require more than 8G of
  memory, exceeding the amount of memory on each Zuul VM.

* Cleans up the output when running `make cover`. Previously, the list
  of all packages was printed for coverage for each package, creating a
  lot of noise on the console.

However, it has the following negative:

* With the removal of the `coverpkg` flag, the `go test` command will no
  longer check coverage of packages which do not include any `_test.go`
  files. This puts the responsibility of assuring that coverage is
  correctly reflected onto the shoulders of developers and reviewers.

Change-Id: I7fef1dd26ef19b5f2ab4cf2d1be223bf82210492
2019-11-01 15:28:56 -05:00
Ian Howell
5b25f0bd00 This removes golangci-lint as a go module dependency.
golangci-lint is GPL-licensed, and its presence in go.mod might lead
people to believe that airshipctl links against a GPL-licensed
dependency. In reality airshipctl does not link against golangci-lint
(thanks to the // +build tools comment), but this change helps to avoid
that misconception from being made.

Change-Id: I95c223a7f6597e1aa07a025ed2cebbbd6bd7cbd8
2019-10-30 09:26:42 -05:00
James Gu
d294a6ba37 Move up to go 1.13.1
Updated go version to 1.13.1 and updated dependency versions in mod
file. Updated Dockerfile to use golang 1.13.1 image. Removed GO111MODULE
env in Makefile which is no longer necessary.

Change-Id: Ib120e8bdfbd3724b72169c4b5ce2cbc7fd9f3ce6
2019-10-04 15:31:45 +00:00
Ian Howell
dc9c78b210 Fix the coverage tests
This fixes a bug where `make cover` was missing packages. The target now
covers all code except for code placed in the top level package (such as
main.go) and anything placed in the testutils directory.

This also fixes minor issues with the Dockerfile and the coverage_check
script

Note that this commit also strives to increase code coverage beyond the
80% margin

Change-Id: I9e1cbcf841cc869345a00f05e39774cb3da10065
2019-10-02 15:18:56 -05:00
Ian Howell
1c999e2095 Add coverage checks
This commit adds a makefile target for generating a report for unit test
coverage. It also adds the coverage_check tool to assert that the actual
test coverage meets the specified requirement.

This also improves various aspects of the testing utilities:
* The "test" package has been renamed to "testutil"
* The "Objs" member has been removed from the CmdTest object
* The "Cmd" member has been added to the CmdTest object. This allows
  testing of multiple variants of a root airshipctl command

Finally, this commit includes additional tests for root.go. These are
required in order to meet the required coverage threshold.

Change-Id: Id48343166c0488c543a405ec3143e4a75355ba43
2019-08-15 11:11:51 -05:00
Ian Howell
c3f61a37c7 Fix various minor nits in the Makefile
* Remove the unused SCRIPTS_DIR variable
* Make bracket/parenthesis usage consistent
* Add the delete-golden target and add it as a pre-req for
  update-golden. This will help to keep the testdata directories from
  accruing bloat

Change-Id: Ie4b7377872d48371e5e134fe18ed9347e89b7c70
2019-07-17 08:17:54 -05:00
Ian Howell
129ccb3e3e Add a configuration file for golangci-lint
This adds the .golangci.example.yaml, allowing for more precise control
over how linting is done.

This configuration is highly opinionated and is subject to change.

Change-Id: Ida13bf0dca12e152b75427f5060ad4931e426c72
2019-07-15 12:11:08 -05:00
Pete Birley
5cf0b2327c CI: Add a functional test for interacting with a existing k8s cluster
This adds Ansible playbooks to install kubernetes using minikube and
then assert that airshipctl is able to communicate with the cluster.

Change-Id: Ice5cf3de8d9192d508c79c68caf8f5a61896da9c
Signed-off-by: Pete Birley <pete@port.direct>
2019-07-09 21:04:15 +00:00
Ian Howell
6e41a56a7d Rename module to reflect its new location
Change-Id: I5c8c524c4d3f569b21b5b829722b3c49952cb0ab
2019-07-01 12:15:29 -05:00
Ian Howell
d6b06a8787 Zuul: Switch from travis to zuul
This PS adds the skeleton for a set of zuul checks and gates for
airshipctl and removes the travis config.

This PS also removes some dead code from the util package. This change
is required to get unit tests passing.

Change-Id: Ifb1be49cb1bb82c62a0085b6da9b8ff1b261a95b
2019-07-01 11:00:26 -05:00
Ian Howell
50f29ca75d Remove coverage tests 2019-06-06 08:59:59 -05:00
Ian Howell
cb0d15bdb8 Fix coverage to handle all packages sans generated code 2019-05-30 15:34:10 -05:00
Ian Howell
e4b45002c9 Enable the linter, and fix uncovered linting issues
This uses the current master commit of golangci-lint. We will want to
update to use a tagged version as soon as the golangci-lint team pushes
a new tag
2019-05-30 10:02:54 -05:00
Ian Howell
d68cfdfe6b Force coverage to check all packages 2019-05-28 15:38:24 -05:00
Ian Howell
49ddd449a7 Fix the update-golden target to update all subpackages of cmd 2019-05-21 14:14:02 -05:00
Ian Howell
3ea070bcd5 Refrain from linting until golangci-lint issues are fixed
See the following issues:
https://github.com/golangci/golangci-lint/issues/538
https://github.com/golangci/golangci-lint/issues/539
2019-05-21 12:31:16 -05:00
Ian Howell
3566507284 Remove useless build flag 2019-05-17 15:57:56 -05:00
Ian Howell
7a58b57b22 Remove the silly line length linter 2019-05-17 14:41:12 -05:00
Ian Howell
714f9ecf6e Static compilation :) 2019-05-17 10:19:38 -05:00
Ian Howell
b5de5bf967 Change to "compile-in" plugins
Move away from the builtin 'plugin' package in favor of compile-in
plugins. This will require a plugin author to inject code into the
proper packages before building airshipctl
2019-05-17 09:23:30 -05:00
Ian Howell
f76eb8e027 Add a bin packer 2019-05-15 16:10:50 -05:00
Ian Howell
6f879da587 Separate plugins from airshipctl 2019-05-14 12:02:51 -05:00
Ian Howell
35ed575fbc Move workflow to plugins 2019-05-10 08:23:59 -05:00
Ian Howell
7a34fd98d9 Change airshipadm to airshipctl 2019-05-07 10:07:54 -05:00
Ian Howell
2880bea640 Add coverage checks 2019-05-07 10:00:07 -05:00
Ian Howell
b019ba757f Add checks for readable kube config 2019-05-06 13:58:58 -05:00
Ian Howell
d26c6c76a1 Update the way golden files are updated 2019-05-01 16:56:42 -05:00
Ian Howell
1d624fb05f Add a linter 2019-05-01 12:26:51 -05:00
Ian Howell
248f694740 Fix testing in makefile 2019-04-26 15:43:23 -05:00
Ian Howell
e0c7746d62 Rudimentary makefile 2019-04-26 11:33:16 -05:00