diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index e471ee7..8cfbe4b 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -930,7 +930,7 @@ jobs: - name: Test working-directory: md4 run: go test ./... - golang-go: + golang-go-src-crypto-internal-bigmod: runs-on: ubuntu-latest steps: - name: Install Go @@ -947,7 +947,45 @@ jobs: uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 with: repository: golang/go - ref: go1.19 + ref: go1.20rc2 + path: go + persist-credentials: false + - name: Compile Go Toolchain + working-directory: go/src + run: ./make.bash + - name: Avo Module Replacement + working-directory: go/src/crypto/internal/bigmod/_asm + run: | + go mod edit -modfile=go.mod -require=github.com/mmcloughlin/avo@v0.0.0-00010101000000-000000000000 + go mod edit -modfile=go.mod -replace=github.com/mmcloughlin/avo=${{ github.workspace }}/avo + go mod tidy -modfile=go.mod + - name: Generate + working-directory: go + run: env --unset=GOROOT ./bin/go generate -v -x ./src/crypto/internal/bigmod/_asm + - name: Diff + working-directory: go + run: git diff + - name: Test + working-directory: go + run: env --unset=GOROOT ./bin/go test crypto/... + golang-go-src-crypto-internal-edwards25519: + runs-on: ubuntu-latest + steps: + - name: Install Go + uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 + with: + go-version: 1.19.x + check-latest: true + - name: Checkout avo + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 + with: + path: avo + persist-credentials: false + - name: Checkout golang/go + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 + with: + repository: golang/go + ref: go1.20rc2 path: go persist-credentials: false - name: Compile Go Toolchain @@ -960,8 +998,8 @@ jobs: go mod edit -modfile=go.mod -replace=github.com/mmcloughlin/avo=${{ github.workspace }}/avo go mod tidy -modfile=go.mod - name: Generate - working-directory: go/src/crypto/internal/edwards25519/field/_asm - run: go generate -v -x + working-directory: go + run: env --unset=GOROOT ./bin/go generate -v -x ./src/crypto/internal/edwards25519/field/_asm - name: Diff working-directory: go run: git diff diff --git a/.github/workflows/thirdparty.yml b/.github/workflows/thirdparty.yml index bb09359..2b11a12 100644 --- a/.github/workflows/thirdparty.yml +++ b/.github/workflows/thirdparty.yml @@ -25,4 +25,4 @@ jobs: persist-credentials: false - name: Run Third-Party Tests working-directory: tests/thirdparty - run: go test -net -suite suite.json + run: go test -timeout 15m -args -net -suite suite.json diff --git a/tests/thirdparty/config.go b/tests/thirdparty/config.go index 2634623..5c16be2 100644 --- a/tests/thirdparty/config.go +++ b/tests/thirdparty/config.go @@ -132,9 +132,8 @@ func (s *Step) Validate() error { // Package defines an integration test for a package within a project. type Package struct { - // Sub-package within the project under test. All file path references will - // be relative to this directory. If empty the root of the repository is - // used. + // Sub-package within the project under test. Used as the root directory for + // the test unless explicitly overridden. SubPackage string `json:"pkg,omitempty"` // Path to the module file for the avo generator package. This is necessary @@ -142,6 +141,11 @@ type Package struct { // version under test. Module string `json:"module"` + // Root directory for all steps in the test. All file path references will + // be relative to this directory. If empty, the sub-package directory is + // used, or otherwise the root of the repository. + Root string `json:"root,omitempty"` + // Setup steps. These run prior to the insertion of avo replace directives, // therefore should be used if it's necessary to initialize new go modules // within the repository. @@ -219,6 +223,17 @@ func (p *Package) IsRoot() bool { return p.SubPackage == "" } +// WorkingDirectory returns the base directory for all steps in the test. +func (p *Package) WorkingDirectory() string { + if p.Root != "" { + return p.Root + } + if p.SubPackage != "" { + return p.SubPackage + } + return "" +} + // Context specifies execution environment parameters for a third-party test. type Context struct { // Path to the avo version under test. @@ -272,9 +287,9 @@ func (p *Package) Steps(c *Context) []*Step { } // Prepend sub-directory to every step. - if p.SubPackage != "" { + if dir := p.WorkingDirectory(); dir != "" { for _, s := range steps { - s.WorkingDirectory = filepath.Join(p.SubPackage, s.WorkingDirectory) + s.WorkingDirectory = filepath.Join(dir, s.WorkingDirectory) } } @@ -304,20 +319,33 @@ func (p Projects) defaults(set bool) { // Validate the project collection. func (p Projects) Validate() error { - seen := map[string]bool{} + // Projects are valid. for _, prj := range p { - // Project is valid. if err := prj.Validate(); err != nil { return fmt.Errorf("project %s: %w", prj.ID(), err) } + } - // No duplicate entries. + // No duplicate project IDs. + pid := map[string]bool{} + for _, prj := range p { id := prj.ID() - if seen[id] { + if pid[id] { return fmt.Errorf("duplicate project %q", id) } - seen[id] = true + pid[id] = true } + + // No duplicate test IDs. + tid := map[string]bool{} + for _, t := range p.Tests() { + id := t.ID() + if tid[id] { + return fmt.Errorf("duplicate test %q", id) + } + tid[id] = true + } + return nil } diff --git a/tests/thirdparty/packages_test.go b/tests/thirdparty/packages_test.go index fa5a7d6..d34b9ce 100644 --- a/tests/thirdparty/packages_test.go +++ b/tests/thirdparty/packages_test.go @@ -2,6 +2,7 @@ package thirdparty import ( "flag" + "os" "os/exec" "path/filepath" "runtime" @@ -69,6 +70,7 @@ type PackageTest struct { // Run the test. func (t *PackageTest) Run() { t.checkout() + t.validate() t.steps() } @@ -88,6 +90,24 @@ func (t *PackageTest) checkout() { test.Exec(t.T, "git", "-C", t.repopath, "checkout", "FETCH_HEAD") } +// validate the test configuration relative to the checked out project. +func (t *PackageTest) validate() { + // Confirm expected directories exist. + expect := map[string]string{ + "package": t.Package.SubPackage, + "root": t.Package.WorkingDirectory(), + } + for name, subdir := range expect { + if subdir == "" { + continue + } + path := filepath.Join(t.repopath, subdir) + if _, err := os.Stat(path); err != nil { + t.Fatalf("expected %s directory: %s", name, err) + } + } +} + func (t *PackageTest) steps() { // Determine the path to avo. _, self, _, ok := runtime.Caller(1) diff --git a/tests/thirdparty/suite.json b/tests/thirdparty/suite.json index d9ac6b6..1901ea9 100644 --- a/tests/thirdparty/suite.json +++ b/tests/thirdparty/suite.json @@ -749,9 +749,39 @@ "stars": 107376 }, "default_branch": "master", - "version": "go1.19", + "version": "go1.20rc2", "packages": [ { + "pkg": "src/crypto/internal/bigmod", + "root": ".", + "module": "src/crypto/internal/bigmod/_asm/go.mod", + "setup": [ + { + "name": "Compile Go Toolchain", + "dir": "src", + "commands": [ + "./make.bash" + ] + } + ], + "generate": [ + { + "commands": [ + "env --unset=GOROOT ./bin/go generate -v -x ./src/crypto/internal/bigmod/_asm" + ] + } + ], + "test": [ + { + "commands": [ + "env --unset=GOROOT ./bin/go test crypto/..." + ] + } + ] + }, + { + "pkg": "src/crypto/internal/edwards25519", + "root": ".", "module": "src/crypto/internal/edwards25519/field/_asm/go.mod", "setup": [ { @@ -764,9 +794,8 @@ ], "generate": [ { - "dir": "src/crypto/internal/edwards25519/field/_asm", "commands": [ - "go generate -v -x" + "env --unset=GOROOT ./bin/go generate -v -x ./src/crypto/internal/edwards25519/field/_asm" ] } ],