Skip to content

Commit

Permalink
integration_tests: automate corpus tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jmccarthy committed Mar 12, 2024
1 parent 372977e commit 1d0f13d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/corpus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Nightly Test Corpus
on:
schedule:
- cron: "0 0 * * *"
push:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.22"

- name: Download
run: curl -L -o integration_tests/corpus-tests.tar.gz https://raw.githubusercontent.com/cedar-policy/cedar-integration-tests/main/corpus-tests.tar.gz

- name: Extract
run: mkdir -p integration_tests/tmp && tar -xzf integration_tests/corpus-tests.tar.gz -C integration_tests/tmp

- name: Corpus Tests
run: go test -tags corpus ./integration_tests/...
1 change: 1 addition & 0 deletions integration_tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tmp
20 changes: 10 additions & 10 deletions integration_tests/corpus_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build corpus

package integration_tests

import (
Expand All @@ -12,13 +14,7 @@ import (
"golang.org/x/exp/slices"
)

// TODO: a way to download the corpus tests and test them
// for now, since this folder is 235MB.
//
// Remove the x before the next line if you have the corpus locally.
// And remove t.Skip() from the test itself.
//
// x go:embed tmp/*
//go:embed tmp/**/*.json tmp/**/*.cedar
var integrationFS embed.FS

type corpusTest struct {
Expand All @@ -40,11 +36,9 @@ type corpusTest struct {

func TestCorpus(t *testing.T) {
t.Parallel()
t.Skip()
var tests []string
for _, p := range []string{
"tmp/abac-B/*.json",
"tmp/abac-type-directed-B/*.json",
"tmp/corpus-tests/*.json",
} {
more, err := fs.Glob(integrationFS, p)
if err != nil || len(more) == 0 {
Expand Down Expand Up @@ -79,6 +73,12 @@ func TestCorpus(t *testing.T) {
prefix := func(v string) string {
return "tmp/" + v
}

// detect possible corpus data pipeline failure
if len(tests) < 4_000 {
t.Fatalf("corpus test count too low: %v", len(tests))
}

for _, tn := range tests {
tn := tn
t.Run(tn, func(t *testing.T) {
Expand Down

0 comments on commit 1d0f13d

Please sign in to comment.