Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: fixes ci to fail fast #363

Merged
merged 2 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/ci-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ jobs:
run: |
go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest
go vet -vettool=$(which shadow) ./... 2>&1 | awk -f .etc/action.awk
shell: bash
- name: Verifying Code
run: |
go generate -v ./... && test -z "$(git status --porcelain)"
go generate -v ./...
test -z "$(git status --porcelain)"
go vet ./...
shell: bash
- name: Building
run: go build -v ./...
- name: Testing
Expand Down
8 changes: 4 additions & 4 deletions dh/sidh/internal/p434/fp2.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions dh/sidh/internal/p503/fp2.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions dh/sidh/internal/p751/fp2.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions dh/sidh/internal/templates/fp2.gotemp
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ func sqr(dest, x *common.Fp2) {

// In case choice == 1, performs following swap in constant time:
//
// xPx <-> xQx
// xPz <-> xQz
// xPx <-> xQx
// xPz <-> xQz
//
// Otherwise returns xPx, xPz, xQx, xQz unchanged
func cswap(xPx, xPz, xQx, xQz *common.Fp2, choice uint8) {
Expand All @@ -161,8 +161,8 @@ func cswap(xPx, xPz, xQx, xQz *common.Fp2, choice uint8) {

// In case choice == 1, performs following moves in constant time:
//
// xPx <- xQx
// xPz <- xQz
// xPx <- xQx
// xPz <- xQz
//
// Otherwise returns xPx, xPz, xQx, xQz unchanged
func cmov(xPx, xPz, xQx, xQz *common.Fp2, choice uint8) {
Expand Down
18 changes: 9 additions & 9 deletions pke/kyber/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func generateParamsFiles() {
if offset == -1 {
panic("Missing template warning in params.templ.go")
}
err = io.WriteFile(mode.Pkg()+"/internal/params.go",
err = os.WriteFile(mode.Pkg()+"/internal/params.go",
[]byte(res[offset:]), 0o644)
if err != nil {
panic(err)
Expand All @@ -120,7 +120,7 @@ func generatePackageFiles() {
if offset == -1 {
panic("Missing template warning in pkg.templ.go")
}
err = io.WriteFile(mode.Pkg()+"/kyber.go", []byte(res[offset:]), 0o644)
err = os.WriteFile(mode.Pkg()+"/kyber.go", []byte(res[offset:]), 0o644)
if err != nil {
panic(err)
}
Expand All @@ -136,7 +136,7 @@ func generateSourceFiles() {
return x == "params.go" || x == "params_test.go"
}

fs, err := io.ReadDir("kyber512/internal")
fs, err := os.ReadDir("kyber512/internal")
if err != nil {
panic(err)
}
Expand All @@ -147,7 +147,7 @@ func generateSourceFiles() {
if ignored(name) {
continue
}
files[name], err = io.ReadFile(path.Join("kyber512/internal", name))
files[name], err = os.ReadFile(path.Join("kyber512/internal", name))
if err != nil {
panic(err)
}
Expand All @@ -159,7 +159,7 @@ func generateSourceFiles() {
continue
}

fs, err = io.ReadDir(path.Join(mode.Pkg(), "internal"))
fs, err = os.ReadDir(path.Join(mode.Pkg(), "internal"))
for _, f := range fs {
name := f.Name()
fn := path.Join(mode.Pkg(), "internal", name)
Expand All @@ -174,10 +174,10 @@ func generateSourceFiles() {
panic(err)
}
}
if f.Mode().IsDir() {
if f.IsDir() {
panic(fmt.Sprintf("%s: is a directory", fn))
}
if f.Mode()&os.ModeSymlink != 0 {
if f.Type()&os.ModeSymlink != 0 {
fmt.Printf("Removing symlink: %s\n", fn)
err = os.Remove(fn)
if err != nil {
Expand All @@ -193,14 +193,14 @@ func generateSourceFiles() {
name,
string(expected),
))
got, err := io.ReadFile(fn)
got, err := os.ReadFile(fn)
if err == nil {
if bytes.Equal(got, expected) {
continue
}
}
fmt.Printf("Updating %s\n", fn)
err = io.WriteFile(fn, expected, 0o644)
err = os.WriteFile(fn, expected, 0o644)
if err != nil {
panic(err)
}
Expand Down
20 changes: 10 additions & 10 deletions sign/dilithium/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func generateParamsFiles() {
if offset == -1 {
panic("Missing template warning in params.templ.go")
}
err = io.WriteFile(mode.Pkg()+"/internal/params.go",
err = os.WriteFile(mode.Pkg()+"/internal/params.go",
[]byte(res[offset:]), 0o644)
if err != nil {
panic(err)
Expand All @@ -180,7 +180,7 @@ func generateModeToplevelFiles() {
if offset == -1 {
panic("Missing template warning in mode.templ.go")
}
err = io.WriteFile(mode.Pkg()+".go", []byte(res[offset:]), 0o644)
err = os.WriteFile(mode.Pkg()+".go", []byte(res[offset:]), 0o644)
if err != nil {
panic(err)
}
Expand All @@ -206,7 +206,7 @@ func generateModePackageFiles() {
if offset == -1 {
panic("Missing template warning in modePkg.templ.go")
}
err = io.WriteFile(mode.Pkg()+"/dilithium.go", []byte(res[offset:]), 0o644)
err = os.WriteFile(mode.Pkg()+"/dilithium.go", []byte(res[offset:]), 0o644)
if err != nil {
panic(err)
}
Expand All @@ -223,7 +223,7 @@ func generateSourceFiles() {
strings.HasSuffix(x, ".swp")
}

fs, err := io.ReadDir("mode3/internal")
fs, err := os.ReadDir("mode3/internal")
if err != nil {
panic(err)
}
Expand All @@ -234,7 +234,7 @@ func generateSourceFiles() {
if ignored(name) {
continue
}
files[name], err = io.ReadFile(path.Join("mode3/internal", name))
files[name], err = os.ReadFile(path.Join("mode3/internal", name))
if err != nil {
panic(err)
}
Expand All @@ -246,7 +246,7 @@ func generateSourceFiles() {
continue
}

fs, err = io.ReadDir(path.Join(mode.Pkg(), "internal"))
fs, err = os.ReadDir(path.Join(mode.Pkg(), "internal"))
for _, f := range fs {
name := f.Name()
fn := path.Join(mode.Pkg(), "internal", name)
Expand All @@ -261,10 +261,10 @@ func generateSourceFiles() {
panic(err)
}
}
if f.Mode().IsDir() {
if f.IsDir() {
panic(fmt.Sprintf("%s: is a directory", fn))
}
if f.Mode()&os.ModeSymlink != 0 {
if f.Type()&os.ModeSymlink != 0 {
fmt.Printf("Removing symlink: %s\n", fn)
err = os.Remove(fn)
if err != nil {
Expand All @@ -280,14 +280,14 @@ func generateSourceFiles() {
name,
string(expected),
))
got, err := io.ReadFile(fn)
got, err := os.ReadFile(fn)
if err == nil {
if bytes.Equal(got, expected) {
continue
}
}
fmt.Printf("Updating %s\n", fn)
err = io.WriteFile(fn, expected, 0o644)
err = os.WriteFile(fn, expected, 0o644)
if err != nil {
panic(err)
}
Expand Down