Commit Graph

22 Commits

Author SHA1 Message Date
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
Patrick East 3fe728c02a Remove travis config and naming
Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-07-08 16:49:16 -07:00
Patrick East fb5ff78c24 Migrate to GitHub actions
This includes some refactors to the build steps. High level items:

* Add variables for DOCKER_IMAGE, S3_RELEASE_BUCKET to allow for forks
  of OPA to re-use the GitHub actions with their own s3 buckets and
  docker orgs/image names.

* Unify the release build steps to use `make release` and the binaries
  being located under `_release/$(VERSION)`. All CI targets now rely
  on binaries being in that `RELEASE_DIR`, including image building
  steps The `make build` target is unaffected.

* Add a wrapper to allow the CI to run the various golang target
  stages separately, but sharing the same docker configuration.

* Conditionally specify `-it` for docker run commands based on whether
  A tty is available.

* Added scripts to automate drafting a release with binary assets vi
  the `hub` CLI.

* The release process triggered on a tag being pushed will now use the
  same binaries from `make release` for the docker images as well as
  the ones attached to the release (which are available under
  https://openpolicyagent.org/downloads/).

The actions themselves are split into 3 workflows:

pull-request.yaml:
  Triggers on pull requests. This will run all the normal tests/checks
  as before on Travis, however they are now split into separate jobs.
  In addition to what was done on Travis we will now have Codecov
  results included.

post-merge.yaml:
  Triggers after a change is pushed to master. This will run tests and
  build+publish the `edge` and `dev` artifacts to dockerhub and s3.

post-tag.yaml:
  Triggers after a tag has been pushed. Similar to post-merge.yaml it
  will run tests and build+publish release artifacts (for the tagged
  version). It will also create a draft release on GitHub with the
  same artifacts and notes from the CHANGELOG.md. If a release already
  exists it will be updated to include the assets, however the release
  notes will _not_ be added.

The RELEASE.md steps have been updated and include notes on the new
steps.

Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-07-08 16:49:16 -07:00