Commit Graph

52 Commits

Author SHA1 Message Date
Anders Eknert 54f79cee8f Change setup-opa action to new location
Signed-off-by: Anders Eknert <anders@eknert.com>
2022-01-21 15:27:50 -08:00
Anders Eknert 53b4b9ee5f Commit generated code/docs in same job (#4248)
Signed-off-by: Anders Eknert <anders@eknert.com>
2022-01-19 13:57:16 +01:00
Anders Eknert f272af65f6 Add CLI section to docs (#4241)
Fixes #3915

Signed-off-by: Anders Eknert <anders@eknert.com>
2022-01-19 13:00:09 +01:00
Anders Eknert fff9856bb7 Add Dapr integration (#4229)
Also included some improvements to the Rego checks:

* Pass GITHUB_TOKEN to policy to not exceed API quota
* Ensure required attributes included in integration
* Ensure commited .json files are valid JSON

Signed-off-by: Anders Eknert <anders@eknert.com>
2022-01-14 11:46:50 +01:00
Anders Eknert d3fbd53578 Build darwin/arm64 in post tag workflow (#4182)
Signed-off-by: Anders Eknert <anders@eknert.com>
2022-01-04 19:22:53 +01:00
Anders Eknert 0ddf1dbb94 Add Open Service Mesh to ecosystem (#4171)
Also:
* Add some links to Kubernetes authorization item
* Add SPIFFE/SPIRE blog
* Extend Rego tests to verify added/modified YAML files as valid

The last point was intended to be for the integrations.yaml file
only, but thinking more about it made sense not to limit the check
to a single file.

Signed-off-by: Anders Eknert <anders@eknert.com>
2021-12-30 20:25:32 +01:00
Anders Eknert 48b8be309e Check PR for mistakes in ecosystem page change (#4164)
Since both contributors and reviewers (i.e. me!) seem
to easily miss the correct location of the logo for a new
integration - add checks that will fail the PR when this
happens.

This is admittedly mostly for fun, but I figured it would
be pretty cool to explore whether we could integrate Rego
policies into our own build pipeline. There are definitely
more things to explore using the GitHub API as a datasource
for build pipeline policies, but this is at least a start.

Signed-off-by: Anders Eknert <anders@eknert.com>
2021-12-23 12:00:44 +01:00
Anders Eknert c56bc2f8f3 release: add Darwin ARM64 release target (#4060)
Somewhat experimental, but now that pretty much all new macs
run with the ARM64 architecture it would be nice to add it as
a target to our releases. Since there is currently no runner
for GitHub Actions (https://github.com/actions/runner/issues/805)
we can't yet run the binary smoke test for this architecture,
but I'm tracking the issue and hoping that can be resolved soon.

Feel free to dismiss this if you think this should wait until later.

Signed-off-by: Anders Eknert <anders@eknert.com>
2021-12-01 11:05:45 +01:00
Stephan Renatus d7448b5252 workflow: move go-mod-proxy check into nightly tests (#4056)
It seldomly matters for PRs, since only a tiny subset of them alters
dependencies. Having the check run in nightlies, where a failure does
not block a PR, but we still notice it through the notifications,
seems like a good trade-off.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2021-11-26 10:25:03 +01:00
Stephan Renatus 8a1aab376f ast+topdown: add net.lookup_ip_addr built-in function (#3995)
Since the golang stdlib function doesn't do any caching, we add the result
to the BuiltinContext.Cache so it's cached, and consistent, within a single
policy evaluation.

There is no decision made here about using netgo or netcgo: we're following
suit wrt how golang expects you to do it: From my understanding, using the
OS means for DNS resolution is the preferred way: it gives you per-host
caching, and it allows the user to affect how DNS resolution works in many
ways.

This means the same logic that applies to all other places where we resolve
domain names into addresses (notably `http.send`) applies to this built-in,
too.

Also:

* workflow/pull_request: don't fail-fast for matrix jobs

Even if one platform fails it would be interesting to see what happens
on the others.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2021-11-16 07:39:14 +01:00
Torin Sandall d687e0efb3 ci/codeql: Fix indentation issue
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2021-11-10 10:55:02 -08:00
Torin Sandall 8e217297c6 ci/codeql: Override autobuild and run make build instead
This way we do not have to run the entire test and benchmark suite
that takes about 25m in total.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2021-11-10 10:48:30 -08:00
Torin Sandall 2f7a9e2dab ci: Tweak the post-tag workflow
* Do not run ci-release-tag target--the tests have already been run
  pre-merge and post-merge so there is little reason to run them again
  post-tag. The only thing this would do is find non-deterministic
  test failures--which begs the question: what do we do with the
  release? We already run tests pre-merge, post-merge, and nightly so
  it's unlikely that post-tag will help improve quality.

* Use the RELEASE_DIR from the makefile for the `hub release` asset
  parameter rather than assuming the TAG <=> RELEASE_DIR (this is not
  always true if tagging an arbitrary commit.) This enables us to cut
  release candidates without commiting changes to the repo.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2021-11-05 16:33:41 -07:00
Torin Sandall b197376f27 ci: Add post release job to kick the netlify deploy (#3972)
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2021-11-05 07:34:20 +01:00
Stephan Renatus c23bf8d451 fuzz: add golang-native fuzzing to nightly tests (#3940)
This installs gotip (the lastest build) and uses its (beta) fuzzing feature in
the nightly tests.

We can remove the previous setup at a later date.

The "seed corpus" was converted from the previous fuzzer's using this script:

    package main

    import (
    	"bytes"
    	"fmt"
    	"io/ioutil"
    	"log"
    	"path/filepath"
    )

    const oldCorpusDir = "build/fuzzer/corpus/"
    const newCorpusDir = "ast/testdata/fuzz/FuzzParseStatementsAndCompileModules"

    func main() {
    	files, err := ioutil.ReadDir(oldCorpusDir)
    	if err != nil {
    		log.Fatal(err)
    	}
    	for _, f := range files {
    		c, err := ioutil.ReadFile(filepath.Join(oldCorpusDir, f.Name()))
    		if err != nil {
    			log.Fatal(err)
    		}
    		buf := bytes.Buffer{}
    		buf.WriteString("go test fuzz v1\n")
    		fmt.Fprintf(&buf, "string(%q)\n", string(c))
    		err = ioutil.WriteFile(filepath.Join(newCorpusDir, f.Name()), buf.Bytes(), 0644)
    		if err != nil {
    			log.Fatal(err)
    		}
    	}
    }

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2021-10-29 13:50:47 +02:00
Stephan Renatus 0aaf70ac21 workflow/nightly: dump all crashers to stdout
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2021-10-27 11:45:56 -07:00
Stephan Renatus 8b52a08b74 ci: check go proxy mod checksums (#3810)
This extra check is meant to catch go module proxy checksum mismatches,
like the one we've released 0.32.1 to fix, earlier.

It causes the go mod tooling to fetch all modules from their external sources,
most likely all github references, and compares the contents' checksums with
what we have in go.sum. It deliberately bypasses the "sumdb" service that is
part of the golang infrastructure.

The event of a mismatch would happen if a git tag was published, and later
changed, and the golang infrastructure's module proxy (and sumdb service)
had picked up the first tag. This is rather unlikely, and this test is thus a bit
over-cautious. The idea is that if it becomes invisible, it's fine to keep, and
gives us a bit of extra safety. However, if it becomes annoying (it's a giant
network dependency in our CI runs), it's not critical enough to be kept and
is OK to disable again.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2021-09-21 09:29:13 +02:00
Stephan Renatus 03020183df workflow/pull_request: run tests on macos (#3795)
This splits off the generate call, so that we can have the wasm bits (and capabilities.json) from the PR used in the PR checks.

The Perf check still is the one taking longest, even with the added matrix build job and the jobs depending on it. The test matrix job was split off to run those in parallel, the binary smoke tests for example can already proceed.

To simplify things, we're relying on the setup-go action for both the linux and the darwin unit tests. (We could also use it for the builds of linux and windows binaries... but there, I'm more concerned about a clean build env and reproducibility.)

Fixes #3176.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2021-09-16 09:27:31 +02:00
Stephan Renatus 4a4185d799 ci: ensure we can build with different go versions
We only check the build, not the tests.
And we only check the latest release of the 1.15 and 1.16 series.
since 1.17 is what we build and test with anyways.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2021-08-30 16:56:53 -07:00
Stephan Renatus 3877595601 ci: add binary smoke tests (windows, macos)
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2021-06-21 09:29:55 -04:00
Will Beason 1281473250 Run dockerized golangci-lint
This means that "make lint" will work the same for everyone and the
workflow without additional coordination. Before this PR, it was
possible for maintainers to be on a different version of golangci-lint
than the one used by the GitHub workflow and so "make check" would
provide inconsistent results.

Also add timeout to configuration so we don't time out.`

Signed-off-by: Will Beason <willbeason@google.com>
2021-06-03 16:09:02 -04:00
Stephan Renatus c657cc0b0f build: fix post-merge action (#3514)
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2021-05-31 11:30:21 +02:00
Stephan Renatus f8ef59c184 build: add static (wasm-disabled) linux build (#3511)
* build: add static (wasm-disabled) linux build

Fixes #3499.

Also:

* build: deprecate 'release' and 'release-local' targets that aren't used in
   our build anymore, and will go away eventually.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2021-05-31 11:18:32 +02:00
Torin Sandall 8f1d7455d5 build: Fix post-tag workflow to run make generate
The post-tag workflow was broken in the recent release. This commit adds
the generate step back into the workflow.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2021-05-27 16:44:18 -04:00
Stephan Renatus db726336bd fix nightly fuzz build (#3474)
* workflow: add 'quick fuzz' run

This is just a very short (3m) fuzz check, to ensure that we don't
surprise ourselves when merging something that in some weird way
affects the nightly fuzzer run. It's probably unlikely to come up
with interesting results, but that's what the long nightly run is for.

* build/fuzzer: fix go module state

Something went amiss here. It seems like running these two commands
makes the build work again:

    $ go mod tidy
    $ go get github.com/dvyukov/go-fuzz/go-fuzz-dep
    go get: added github.com/dvyukov/go-fuzz v0.0.0-20210429054444-fca39067bc72

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2021-05-19 13:15:20 +02:00
Stephan Renatus f7de26ca2a fix codeql go version; use ioutil.Discard. (#3466)
* workflow: fix codeql go version
* cmd/fmt_test: use ioutil.Discard

I had proposed that in a PR review... not thinking that it meant
we couldn't run tests using Go 1.15. My assumption that using

    go 1.15

in go.mod would protect us from that was wrong, apparently.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2021-05-17 11:06:14 +02:00
Stephan Renatus 1a4227b7dc nightly checks: fix races, bump logrus version (#3439)
* runtime_test: avoid race condition

This had been flagged by our nightly race deteector run. Now, we'll
wait for the server to have stopped before checking its log output.

* plugins: avoid races, bump github.com/sirupsen/logrus

To fix that other one, I've first tried updating logrus (there was a
mention of fixed races in the changelog), but to no avail. Setting up
the hook before any plugin would log from that test resolved the issue.

No harm in updating logrus, though, let's keep that: 1.6.0 -> 1.8.1

* plugins/bundle: fix race

Golang for-range loops need special care when using a reference to the
second variable (v in `for k, v := range m`). We had been copying the
value of m[k], which is a pointer to Status, we had not been -- as was
intended -- copying the values of the struct that the pointer had been
pointing to.

Tests needed to be adapted for this, the s4 update will NOT contain
any bundle-activation-related metrics, as no bundle was activated, and
its status is a fresh copy.

* workflow: add race detector to PR checks

When run from nightly, we use ubuntu-latest; whereas the other checks
in the pull-request workflow use ubuntu-18.04.

I don't think it matters at all for the race detector, since that one
runs only from another docker container, using the golang image.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2021-05-12 11:06:40 +02:00
Stephan Renatus e173a7722a build: ensure the binaries in docker images are executable (#3433)
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2021-05-05 18:48:14 +02:00
Stephan Renatus f23fb0f40a build: WASM_ENABLED=1 for all platforms (#3416)
* build: WASM_ENABLED=1 for all platforms, bump go to 1.16.3

Notes:
- If there are other users of the 'build-windows' make target they would
  likely be annoyed by the change that's now apt-get'ting packages
- We could build a builder image instead of installing the package every
  time.
- ci-go-*: run as root now, so we're able to install the packages for
  windows.
- tests: skip tests that depend on not being run as root when root. The
  change to ci-go-* makes that necessary; the impact is rather limited
  right now. We can reconsider if there are more tests depending on not
  being run as root.

- build: add '-buildmode=exe' to GOFLAGS

  Primarily for the windows build, but I don't think it should be wrong
  for the others either:

  https://github.com/golang/go/issues/40795

  See https://golang.org/cmd/go/#hdr-Build_modes:

  > -buildmode=exe
  > Build the listed main packages and everything they import into
  > executables. Packages not named main are ignored.

- go: fix version as 1.16.3 (not 1.16)

  We'd rather keep this an exact match.

- build: update go module related env vars

  With 1.16, https://blog.golang.org/go116-module-changes,

  > The go command now builds packages in module-aware mode by default.

  Also, since we've added the `go 1.15` directive to go.mod, we can drop
  all -mod=vendor flags, https://golang.org/ref/mod#go-mod-file-go,

  > At go 1.14 or higher, automatic vendoring may be enabled. If the file
  > vendor/modules.txt is present and consistent with go.mod, there is no
  > need to explicitly use the -mod=vendor flag.

- build: override docker id/gid in 'image' target, to keep existing
  behaviour.

* workflow: use binaries built before, remove workaround

split linux and windows to not wait for the windows build to finish
before starting the npm-opa-wasm tests.

* wasm-sdk: show where to get binaries, don't panic

Fixes #3264.

* Makefile: deprecate old targets, introduce new ones

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2021-05-05 17:06:08 +02:00
Torin Sandall 306623a73e github: Update default branch name
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2021-04-15 15:32:15 -04:00
Stephan Renatus 30a06544f2 wasm: introduce abi_versions to capabilities (#3142)
* wasm: emit ABI version as global

This takes inspiration from the proxy-spec (Envoy's Wasm support).
There, it's recorded in an exported function's name. However, it's
been included like that in the spec because it's the least common
denominator among the different languages (potentially) used to
implement proxy-spec. We've got a pretty good grip on our generated
Wasm code, so we do what's noted in proxy-spec as "ideally, we'd do
xyz instead".

However, our ABI version is a simple integer, no semver.

Ref: https://github.com/proxy-wasm/spec/tree/master/abi-versions/vNEXT#proxy_abi_version_x_y_z

* ast.CapabilitiesForThisVersion: include WasmABIVersions

Extending the ast.Capabilities like this is somewhat unsatisfying -- the Wasm ABI has little to do with the ast package. However, moving Capabilities outside of ast in a way that's not introducing import cycles and is backwards-compatible proved to be quite an effort; so let's go with "simple" here.

* capatibilities.json: ensure it is generated with ABI versions

The build tag `generate` is what `go generate` would set, too. We're losing
that in the main.go -> gen-run-go.sh indirection, so we've got to set it
ourselves.

* ci: fix npm-opa-wasm e2e test

The CI build uses a version of OPA built in a previous step -- with the Wasm SDK _disabled_.
To still build Wasm modules, we thus fix the call to use the capabilities.json file from master,
which corresponds to the capabilities of a build of OPA with Wasm SDK enabled.

* docs/content/wasm.md: mention abi version, change headers

There is only one `#` header in a markdown document, so this fixes
that by adding a few `#`. I haven't added it everywhere below
`# Compiling`, but I think the structure is OK now.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2021-02-12 13:29:02 +01:00
Torin Sandall e6c543ff6b build: Remove codecov check
The codecov check is not providing any value. Over time we have had to
tweak the check parameters because of false-positives. As well, the
service is often unavailable when clicking through from GitHub. The
final straw was today when the check stopped showing inside of PRs. At
this point everyone is ignoring it.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2021-02-03 20:30:38 +01:00
Stephan Renatus e53a7a64ca ci: run npm-opa-wasm example (#3094)
This attempts to give us some more safety for WASM-related changes.
We don't want to break the SDK!

It's introducing some coordination efforts in the future: when a WASM-
related change is supposed to be merged that requires SDKs to change,
we'll have to merge that into npm-opa-wasm first, before the PR can go
in. However, it's better to have this sort of breaking change smoke
test.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2021-01-25 20:41:23 +01:00
Anders Eknert 2452ba10b4 Reduce CodeQL frequency (#2992)
Since this more than doubled build times, run only on pushes to master/release branches and not on each PR.

Signed-off-by: Anders Eknert <anders@eknert.com>
2020-12-09 00:42:04 +01:00
Chris Aniszczyk 01bf0cfa6b Add CodeQL Security Scanning
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2020-12-08 14:05:14 -05:00
Patrick East 26be9e2194 ci: Move wasm sdk e2e tests into separate job
Rather than have the tests run as part of the normal go `make test`
target we add a new one specific to them, and a github action for PR's
to match.

This helps keep reduce the response time for PR's waiting on golang
unit tests significantly.

Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-11-25 14:04:55 -05:00
Ashutosh Narkar 38ab0e1006 .github: Update post tag workflow to use env files
The post tag workflow used the set-env command to
set the TAG_NAME env variable. The set-env command is
now disabled due to a security vulnerability in the GitHub Actions
runner that can allow environment variable and path injection in
workflows that log untrusted data to STDOUT. For more information see:
https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/

This change updates the workflow to remove
usage of the set-env command to use environment files
instead.

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2020-11-23 10:37:30 -08:00
Patrick East e8cc9cd32d ci: Use a separate token for pushing code
Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-10-30 16:35:41 -07:00
Patrick East 8340883551 ci: Prevent commit loop if build is non-deterministic
The "post-merge" flow would trigger whenever a commit is pushed, which
includes when we auto-generate the wasm binaries. If (for whatever
reason) that generate step was non-deterministic it would potentially
mean the CI looping and adding commits until we manually intervene.

This changes to prevent the step from being able to commit on top of
another auto-generated commit.

Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-10-30 15:50:13 -07:00
Patrick East 250ee9631e ci: Auto generate and commit wasm binaries
Rather than force PR's to include the generated wasm binaries we can
accept changes which require regenerating them. The post merge
workflow will now generate them and commit+push the new binaries.

The PR check for generated changes includes new functionality to
exclude files, the first ones being the wasm generated ones.

Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-10-30 14:51:42 -04:00
Patrick East 35b78b8afb CI: Skip asset upload/push when missing config
Previously we had some required configuration for the Github Actions,
and forks of OPA would need to set them _and_ have the underlying
infra configured (eg, docker registries, s3 bucket, etc).

Now it will check if the secrets are set, and if any required ones
are missing it will skip the steps.

This significantly lowers the bar for OPA forks to be able to run the
normal action workflows without getting errors. The only lost
functionality is primarily around publishing release assets, which
is not required for dev forks, and other forks can opt int to pieces
they care about (eg, only want to publish docker images and no
s3 release assets).

Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-07-24 10:49:19 -04:00
Patrick East 8ce7c8a76a report: Support build-time telemetry URL
We previously supported overriding via an environment variable, but
this meant for anyone who wanted to run their own telemetry endpoint
they would _always_ have to specify it while running their OPA's.

This change allows for someone to build OPA and encode the custom
url as the default. Ex:

```
make build TELEMETRY_URL=http://localhost:9876/custom/
```

Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-07-22 11:07:17 -07:00
Patrick East 0764de1170 CI: Fix slack notifications
Update the conditional syntax to be valid and switch to a different
slack action helper that provides a better end result.

Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-07-16 15:32:39 -07:00
Patrick East 4eaf9ab597 CI: Upload fuzz crashers on failure
The step was skipped because the previous one failed. This should now
only upload on failures.

Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-07-15 12:01:34 -07:00
Patrick East 5227ed0923 CI: Add slack notifications for periodic jobs
We are using a 3rd party action to simplify this. It appears to be
relatively well used, and the code looked pretty safe. It only has
access to the slack webhook secret, which is itself restricted in
permissions, so the risk is minimal.

It is configured to post a message for jobs that fail to the OPA
slack in the #development channel.

Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-07-15 12:01:25 -07:00
Patrick East 2cd46e0f1f Add periodic fuzzer job and required tooling
This adds the tooling from:

https://github.com/tsandall/fuzz-opa

plus some new helper scripts and make targets to use it as a pass/fail
CI step.

The script will (as of now) run the fuzzing for an hour and raise an
error if any crashers were found. We can adjust the timing as needed,
this initial setting is pretty arbitrary.

Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-07-14 15:11:55 -07:00
Patrick East 26e939d719 Add nightly github workflow with race detector job
We will run the golang race detector nightly (to start with.. we'll
adjust the workflow as needed).

One thing to note is that currently cgo is required for the race
detector, so we have to enable it when running this make target.

Fixes: #2388
Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-07-10 11:03:29 -07:00
Patrick East afb1c4ca29 wasm: Automate builder image deployment and build
Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-07-10 11:00:25 -07:00
Patrick East 558bd67264 Upload Codecov report on master after merge
We were only doing it on the PR workflows, but we should have one
uploaded on master after merges to keep an up to date baseline.

Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-07-08 17:43:09 -07:00
Patrick East d5c0e1a32d Update Codecov action configuration
We had `tags` specified but its looking for `flags`. This was causing
a warning on the tests.

Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-07-08 17:23:22 -07:00