34 Commits

Author SHA1 Message Date
Reed Allman
f5297c64d0 go mod tidy (#1464)
* go mod tidy

was getting checksum mismatches, this fixes

* update circleci to build w/ go1.12.1
2019-04-09 09:22:17 -07:00
Tolga Ceylan
44a97f66c4 fn: upgrade to go 1.11.5 (#1388)
For CVE-2019-6486
2019-01-24 10:21:35 -08:00
Reed Allman
303c7203ec update go1.11.4 / fix gosec (#1355)
gosec being in ./bin is causing issues for release script with a dirty working
directory, moves the gosec binary to $GOPATH/bin

go1.11.4 is a security patch
2018-12-17 09:21:22 -08:00
Reed Allman
d85fadb142 add gosec scanning to ci (#1349)
gosec severity=medium passes, all severity=low errors are from unhandled
errors, we have 107 of them. tbh it doesn't look worth it to me, but maybe
there are a few assholes even itchier than mine out there. medium has some
good stuff in it, and of course high makes sense if we're gonna do this at
all.

this adds some nosec annotations for some things like sql sprintfs where we
know it's clean (we're constructing the strings with variables in them). fixed
up other spots where we were sprinting without need.

some stuff like filepath.Clean when opening a file from a variable, and file
permissions, easy stuff...

I can't get the CI build to shut up, but I can locally get it to be pretty
quiet about imports and it just outputs the gosec output. fortunately, it
still works as expected even when it's noisy. I got it to shut up by unsetting
some of the go mod flags locally, but that doesn't seem to quite do it in
circle, printed the env out and don't see them, so idk... i give up, this
works

closes #1303
2018-12-13 17:57:25 -08:00
Reed Allman
292f673747 Go1.11 (#1188)
* update circleci to go1.11

* update opencensus dep to build with go1.11

* fix up for new gofmt rules
2018-08-27 10:55:52 -07:00
Tolga Ceylan
c73d3f362e fn: remove confusing parallelism in test scripts (#1079)
* fn: remove confusing parallelism in test scripts

*) Tests should be consistent when run from makefile versus
running these test scripts from command line. Let go use
GOMAXPROCS instead of hardcoded 4 cpus in Makefile.
*) Moved docker pull for specific image versions into
helpers scripts as well. Easier to maintain image version
for tests in the same place.
*) Minor Makefile cleanup: removed unused makefile targets.

* fn: git-diff rename limit increase
2018-06-20 13:49:31 -07:00
Reed Allman
00c29b8bf3 datastore no longer implements logstore (#1013)
* datastore no longer implements logstore

the underlying implementation of our sql store implements both the datastore
and the logstore interface, however going forward we are likely to encounter
datastore implementers that would mock out the logstore interface and not use
its methods - signalling a poor interface. this remedies that, now they are 2
completely separate things, which our sqlstore happens to implement both of.

related to some recent changes around wrapping, this keeps the imposed metrics
and validation wrapping of a servers logstore and datastore, just moving it
into New instead of in the opts - this is so that a user can have the
underlying datastore in order to set the logstore to it, since wrapping it in
a validator/metrics would render it no longer a logstore implementer (i.e.
validate datastore doesn't implement the logstore interface), we need to do
this after setting the logstore to the datastore if one wasn't provided
explicitly.

* splits logstore and datastore metrics & validation logic
* `make test` should be `make full-test` always. got rid of that so that
nobody else has to wait for CI to blow up on them after the tests pass locally
ever again.

* fix new tests
2018-06-04 00:08:16 -07:00
jan grant
2387d070bf Fix docker login syntax (#933)
With docker 18.04 the behaviour of a documented interface has changed from 18.03 -
to wit, you need to use a specific noninteractive mode of `docker login` to avoid
being prompted about insecure credential storage.
2018-04-11 13:25:37 +01:00
Tolga Ceylan
7b5b091698 fn: update fn dependencies for go 1.10 (#856) 2018-03-14 09:18:30 -07:00
Tolga Ceylan
0ef0118150 fn: wait for async attach with success channel (#810)
* fn: wait for async attach with success channel

* fn: debug logs in test.sh

* fn: circleci test output as artifact

* fn: docker attach non-blocking adjustments

* fn: remove retry from risky NB attach
2018-03-08 15:46:32 -08:00
Tolga Ceylan
ebc6657071 fn: docker version check2 (#744)
1) now required docker version is 17.06
2) enable circle ci latest docker install
3) docker driver & agent check minimum version before start
2018-02-06 16:16:40 -08:00
jan grant
025e598c4b Selective releasing (#708)
* Rejig the build process

During a build, we check and rebuild any dependencies prior to
potentially using them.

Build:
- DIND (this only produces a new docker image, no local code changes)
- fnserver (built as part of the testing)

On master, if everything works, then we release the built artifacts,
if necessary:
- DIND (this pushes a docker image and a tag)
- fnserver (this builds the docker image and releases it, if necessary).

Fnserver is dealt with last by the release script: all previous steps
in CI use locally-run go tests rather than a docker file.

When a commit happens, we need to know (a) if we need to rebuild
a set of tools and artifacts (or whether we can continue to use
published ones); and (b) if we need to release new versions of
those tools, if all tests pass.

We do this by identifying the previous release tag on origin/master
(which is the release branch), then checking for changes between
that point at the current one.

Those changes may appear in various places in the tree: some simple
boolean rules work out whether the change means we need to rebuild
and rerelease.

* Make the fnproject/fnserver build use the latest dind

As docker bumps from 17.12.x, use whatever dind we just built.

* Use bash
2018-02-01 12:43:43 +00:00
jan grant
d85e6bd61b Ensure we have the latest fnproject/dind (#687)
If we need to reissue fnproject/dind:17.12 (which fnproject/fnserver
is based upon) then let's make sure we're using the latest one
when cutting a release.

To ensure we don't accidentally use stale images lying around in
the docker cache (there probably shouldn't be *any*), call
    make clear-images
before running the build.
2018-01-19 10:02:25 -08:00
Reed Allman
aa3ea9f7c9 CI don't install docker (#635)
it's there already, and >17.05
2018-01-02 16:47:08 -06:00
Reed Allman
3e8b24dce4 remove arbitrary docker build (#633)
`release.sh` does this upon release anyway, this is the last step in the
build. while nice to verify this, it does take 2 minutes on every branch
build, which is almost 1/3 of our build time now.
2018-01-02 13:15:43 -08:00
Tolga Ceylan
d329e0ef5b fn: circleci and makefile adjustments (#625)
* fn: circleci and makefile adjustments

*) Moved more tasks into Makefile to allow for
parallelism and dependency checks.
*) Added cpu count in circleci make invocations
for parallelism

* fn: typo sqlite => sqlite3

* fn: removed unnecessary make pull & install
2017-12-23 10:12:18 -06:00
Reed Allman
61b416a9b5 automagic sql db migrations (#461)
* adds migrations

closes #57

migrations only run if the database is not brand new. brand new
databases will contain all the right fields when CREATE TABLE is called,
this is for readability mostly more than efficiency (do not want to have
to go through all of the database migrations to ascertain what columns a table
has). upon startup of a new database, the migrations will be analyzed and the
highest version set, so that future migrations will be run. this should also
avoid running through all the migrations, which could bork db's easily enough
(if the user just exits from impatience, say).

otherwise, all migrations that a db has not yet seen will be run against it
upon startup, this should be seamless to the user whether they had a db that
had 0 migrations run on it before or N. this means users will not have to
explicitly run any migrations on their dbs nor see any errors when we upgrade
the db (so long as things go well). if migrations do not go so well, users
will have to manually repair dbs (this is the intention of the `migrate`
library and it seems sane), this should be rare, and I'm unsure myself how
best to resolve not having gone through this myself, I would assume it will
require running down migrations and then manually updating the migration
field; in any case, docs once one of us has to go through this.

migrations are written to files and checked into version control, and then use
go-bindata to generate those files into go code and compiled in to be consumed
by the migrate library (so that we don't have to put migration files on any
servers) -- this is also in vcs. this seems to work ok. I don't like having to
use the separate go-bindata tool but it wasn't really hard to install and then
go generate takes care of the args. adding migrations should be relatively
rare anyway, but tried to make it pretty painless.

1 migration to add created_at to the route is done here as an example of how
to do migrations, as well as testing these things ;) -- `created_at` will be
`0001-01-01T00:00:00.000Z` for any existing routes after a user runs this
version. could spend the extra time adding 'today's date to any outstanding
records, but that's not really accurate, the main thing is nobody will have to
nuke their db with the migrations in place & we don't have any prod clusters
really to worry about. all future routes will correctly have `created_at` set,
and plan to add other timestamps but wanted to keep this patch as small as
possible so only did routes.created_at.

there are tests that a spankin new db will work as expected as well as a db
after running all down & up migrations works. the latter tests only run on mysql
and postgres, since sqlite3 does not like ALTER TABLE DROP COLUMN; up
migrations will need to be tested manually for sqlite3 only, but in theory if
they are simple and work on postgres and mysql, there is a good likelihood of
success; the new migration from this patch works on sqlite3 fine.

for now, we need to use `github.com/rdallman/migrate` to move forward, as
getting integrated into upstream is proving difficult due to
`github.com/go-sql-driver/mysql` being broken on master (yay dependencies).
Fortunately for us, we vendor a version of the `mysql` bindings that actually
works, thus, we are capable of using the `mattes/migrate` library with success
due to that. this also will require go1.9 to use the new `database/sql.Conn`
type, CI has been updated accordingly.

some doc fixes too from testing.. and of course updated all deps.

anyway, whew. this should let us add fields to the db without busting
everybody's dbs. open to feedback on better ways, but this was overall pretty
simple despite futzing with mysql.

* add migrate pkg to deps, update deps

use rdallman/migrate until we resolve in mattes land

* add README in migrations package

* add ref to mattes lib
2017-11-14 12:54:33 -08:00
Denis Makogon
e9e0d421c6 Run linter with swagger doc from disk 2017-10-26 06:36:21 +03:00
Denis Makogon
9b3aa43a5a Swagger linter for CI 2017-10-20 00:39:56 +03:00
Reed Allman
7f15d5f89b don't run release on forks (#411)
copied https://github.com/fnproject/cli/pull/71
2017-10-09 14:29:46 -07:00
Reed Allman
8a59654582 go vet yourself (#397)
go vet caught some nifty bugs. so fixed those here, and also made it so that
we vet everything from now on since the robots seem to do a better job of
vetting than we have managed to.

also adds gofmt check to circle. could move this to the test.sh script (didn't
want a script calling a script, because $reasons) and it's nice and isolated
in its own little land as it is. side note, changed the script so it runs in
100ms instead of 3s, i think find is a lot faster than go list.

attempted some minor cleanup of various scripts
2017-10-06 08:42:33 -07:00
Travis Reeder
e0d5fccec5 Update circle 2017-10-03 15:01:19 -07:00
Travis Reeder
06cc0fe68a Update circle 2017-10-03 14:58:30 -07:00
Travis Reeder
c2dce68828 Updated machine version for cicle 2017-10-03 14:57:24 -07:00
Travis Reeder
46702b0755 Attempt fix of forked builds. (#382) 2017-10-02 19:45:17 -07:00
Reed Allman
caba9e0ec6 more strict configuration of routes
* idle_timeout max of 1h
* timeout max of 120s for sync, 1h for async
* max memory of 8GB
* do full route validation before call invocation
* ensure that idle_timeout >= timeout

we are now doing validation of updating route inside of the database
transaction, which is what we should have been doing all along really.
we need this behavior to ensure that the idle timeout is longer than the
timeout, among other benefits (like not updating the most recent version of
the existing struct and overwriting previous updates, yay). since we have
this, we can get rid of the weird skipZero behavior on validate too and
validate the real deal holyfield.

validating the route before making the call is handy so that we don't do weird
things like run a func that wants to use 300GB of RAM and run for 3 weeks.

closes #192
closes #344
closes #162
2017-09-21 04:04:34 -07:00
Denis Makogon
ef74b82506 Adding all datastores-based API tests 2017-09-21 12:33:16 +03:00
Denis Makogon
482f8423d6 Run API tests as separate task
Before that we tested only SQLite, deployments we do are using MySQL.
 So, it's better to run that set of tests.
2017-09-21 12:33:15 +03:00
Travis Reeder
d7bf64bf66 Big dependency update, all lowercase sirupsen's for all dependencies. 2017-08-23 19:52:56 -07:00
Travis Reeder
95dc8bc4ed docker login earlier 2017-08-03 10:12:29 -07:00
Travis Reeder
b0494cd25d Boom, circle good to go, releases on commits to master too (#7)
* circle

* circle

* circle

* circle

* circle

* CIRCLE

* circle

* circle

* circle

* circle

* circle

* circle

* circle

* circle

* circle

* circle

* cijrcle

* circle

* circle

* circle

* circle

* c

* c

* circle

* testing release

* circle

* trying release

* c

* c

* functions: 0.3.25 release [skip ci]

* c

* functions: 0.3.26 release [skip ci]

* fn tool: 0.3.19 release [skip ci]

* testing cli release only

* fn tool: 0.3.20 release [skip ci]

* fn tool: 0.3.21 release [skip ci]

* hopefully the last thing

* fn tool: 0.3.22 release [skip ci]

* c

* fn tool: 0.3.23 release [skip ci]

* almost there....

* fn tool: 0.3.24 release [skip ci]

* fnlb: 0.0.2 release [skip ci]

* fn tool: 0.3.25 release [skip ci]

* fnlb: 0.0.3 release [skip ci]

* Added back in commented out lines.

* Fixing middleware example.
2017-07-26 17:38:37 -07:00
Travis Reeder
2949ce0ed0 circle 2017-07-25 15:22:19 -07:00
Travis Reeder
27b665422d circle 2017-07-25 15:13:47 -07:00
Travis Reeder
c296fdd53f resetting up circle. 2017-07-25 15:10:54 -07:00