Another attempt at getting github actions to pass

This commit is contained in:
David Dworken 2022-11-01 11:03:49 -07:00
parent d2558c8fb5
commit 2efa93762a
No known key found for this signature in database
8 changed files with 71 additions and 56 deletions

View File

@ -576,7 +576,7 @@ func slsaStatusHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("OK")) w.Write([]byte("OK"))
return return
} }
if vNum < 158 { if vNum < 2000000 {
w.Write([]byte("Sigstore deployed a broken change. See https://github.com/slsa-framework/slsa-github-generator/issues/1163")) w.Write([]byte("Sigstore deployed a broken change. See https://github.com/slsa-framework/slsa-github-generator/issues/1163"))
return return
} }

View File

@ -653,6 +653,9 @@ func testUpdate(t *testing.T, tester shellTester) {
if !isExpected { if !isExpected {
t.Fatalf("hishtory update returned unexpected out=%#v", out) t.Fatalf("hishtory update returned unexpected out=%#v", out)
} }
if strings.Contains(out, "skipping SLSA validation") {
t.Fatalf("SLSA validation was skipped, out=%#v", out)
}
// Update again and assert that it skipped the update // Update again and assert that it skipped the update
out = tester.RunInteractiveShell(t, `hishtory update`) out = tester.RunInteractiveShell(t, `hishtory update`)
@ -675,6 +678,8 @@ func testUpdate(t *testing.T, tester shellTester) {
if diff := cmp.Diff(expectedOutput, out); diff != "" { if diff := cmp.Diff(expectedOutput, out); diff != "" {
t.Fatalf("hishtory export mismatch (-expected +got):\n%s\nout=%#v", diff, out) t.Fatalf("hishtory export mismatch (-expected +got):\n%s\nout=%#v", diff, out)
} }
// TODO: write a test that updates from v.prev to latest rather than v.Unknown to latest
} }
func testRepeatedCommandThenQuery(t *testing.T, tester shellTester) { func testRepeatedCommandThenQuery(t *testing.T, tester shellTester) {
@ -1983,9 +1988,9 @@ echo bar`)
// And check that it is all recorded correctly // And check that it is all recorded correctly
tester.RunInteractiveShell(t, `hishtory config-set displayed-columns 'Exit Code' git_remote Command `) tester.RunInteractiveShell(t, `hishtory config-set displayed-columns 'Exit Code' git_remote Command `)
out = tester.RunInteractiveShell(t, `hishtory query -pipefail`) out = tester.RunInteractiveShell(t, `hishtory query -pipefail`)
compareGoldens(t, out, "testCustomColumns-query") compareGoldens(t, out, fmt.Sprintf("testCustomColumns-query-isAction=%v", (os.Getenv("GITHUB_ACTION") != "")))
out = captureTerminalOutput(t, tester, []string{"hishtory SPACE tquery SPACE -pipefail ENTER"}) out = captureTerminalOutput(t, tester, []string{"hishtory SPACE tquery SPACE -pipefail ENTER"})
compareGoldens(t, out, "testCustomColumns-tquery") compareGoldens(t, out, fmt.Sprintf("testCustomColumns-tquery-isAction=%v", (os.Getenv("GITHUB_ACTION") != "")))
} }
type deviceSet struct { type deviceSet struct {

View File

@ -2,7 +2,6 @@ package data
import ( import (
"testing" "testing"
"time"
) )
func TestEncryptDecrypt(t *testing.T) { func TestEncryptDecrypt(t *testing.T) {
@ -21,54 +20,6 @@ func TestEncryptDecrypt(t *testing.T) {
} }
} }
func TestParseTimeGenerously(t *testing.T) {
ts, err := parseTimeGenerously("2006-01-02T15:04:00-08:00")
checkError(t, err)
if ts.Unix() != 1136243040 {
t.Fatalf("parsed time incorrectly: %d", ts.Unix())
}
ts, err = parseTimeGenerously("2006-01-02 T15:04:00 -08:00")
checkError(t, err)
if ts.Unix() != 1136243040 {
t.Fatalf("parsed time incorrectly: %d", ts.Unix())
}
ts, err = parseTimeGenerously("2006-01-02_T15:04:00_-08:00")
checkError(t, err)
if ts.Unix() != 1136243040 {
t.Fatalf("parsed time incorrectly: %d", ts.Unix())
}
ts, err = parseTimeGenerously("2006-01-02T15:04:00")
checkError(t, err)
if ts.Year() != 2006 || ts.Month() != time.January || ts.Day() != 2 || ts.Hour() != 15 || ts.Minute() != 4 || ts.Second() != 0 {
t.Fatalf("parsed time incorrectly: %d", ts.Unix())
}
ts, err = parseTimeGenerously("2006-01-02_T15:04:00")
checkError(t, err)
if ts.Year() != 2006 || ts.Month() != time.January || ts.Day() != 2 || ts.Hour() != 15 || ts.Minute() != 4 || ts.Second() != 0 {
t.Fatalf("parsed time incorrectly: %d", ts.Unix())
}
ts, err = parseTimeGenerously("2006-01-02_15:04:00")
checkError(t, err)
if ts.Year() != 2006 || ts.Month() != time.January || ts.Day() != 2 || ts.Hour() != 15 || ts.Minute() != 4 || ts.Second() != 0 {
t.Fatalf("parsed time incorrectly: %d", ts.Unix())
}
ts, err = parseTimeGenerously("2006-01-02T15:04")
checkError(t, err)
if ts.Year() != 2006 || ts.Month() != time.January || ts.Day() != 2 || ts.Hour() != 15 || ts.Minute() != 4 || ts.Second() != 0 {
t.Fatalf("parsed time incorrectly: %d", ts.Unix())
}
ts, err = parseTimeGenerously("2006-01-02_15:04")
checkError(t, err)
if ts.Year() != 2006 || ts.Month() != time.January || ts.Day() != 2 || ts.Hour() != 15 || ts.Minute() != 4 || ts.Second() != 0 {
t.Fatalf("parsed time incorrectly: %d", ts.Unix())
}
ts, err = parseTimeGenerously("2006-01-02")
checkError(t, err)
if ts.Year() != 2006 || ts.Month() != time.January || ts.Day() != 2 || ts.Hour() != 0 || ts.Minute() != 0 || ts.Second() != 0 {
t.Fatalf("parsed time incorrectly: %d", ts.Unix())
}
}
func checkError(t *testing.T, err error) { func checkError(t *testing.T, err error) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)

View File

@ -0,0 +1,10 @@
Exit Code git_remote Command
0 https://github.com/ddworken/hishtory hishtory config-set displayed-columns 'Exit Code' git_remote Command
0 echo bar
0 cd /
0 https://github.com/ddworken/hishtory echo foo
0 https://github.com/ddworken/hishtory hishtory config-add custom-column git_remote '(git remote -v 2>/dev/null | grep origin 1>/dev/null ) && git remote get-url origin || true'
0 echo baz
0 cd /
0 echo $FOOBAR world
0 export FOOBAR='hello'

View File

@ -8,12 +8,12 @@ Search Query: > -pipefail
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Exit Code git_remote Command │ │ Exit Code git_remote Command │
│─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│ │─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
│ 0 git@github.com:ddworken/hishtory.git source /Users/david/.bashrc │ │ 0 https://github.com/ddworken/hishtory source /Users/david/.bashrc │
│ 0 git@github.com:ddworken/hishtory.git hishtory config-set displayed-columns 'Exit Code' git_remote Command │ │ 0 https://github.com/ddworken/hishtory hishtory config-set displayed-columns 'Exit Code' git_remote Command │
│ 0 echo bar │ │ 0 echo bar │
│ 0 cd / │ │ 0 cd / │
│ 0 git@github.com:ddworken/hishtory.git echo foo │ │ 0 https://github.com/ddworken/hishtory echo foo │
│ 0 git@github.com:ddworken/hishtory.git hishtory config-add custom-column git_remote '(git remote -v 2>/dev/null | grep origin 1>/dev/null ) && git remote get-url origin || … │ │ 0 https://github.com/ddworken/hishtory hishtory config-add custom-column git_remote '(git remote -v 2>/dev/null | grep origin 1>/dev/null ) && git remote get-url origin || … │
│ 0 echo baz │ │ 0 echo baz │
│ 0 cd / │ │ 0 cd / │
│ 0 echo $FOOBAR world │ │ 0 echo $FOOBAR world │

View File

@ -0,0 +1 @@
TODOOOOOOOOO

View File

@ -356,3 +356,51 @@ func TestZshWeirdness(t *testing.T) {
} }
} }
} }
func TestParseTimeGenerously(t *testing.T) {
ts, err := parseTimeGenerously("2006-01-02T15:04:00-08:00")
testutils.Check(t, err)
if ts.Unix() != 1136243040 {
t.Fatalf("parsed time incorrectly: %d", ts.Unix())
}
ts, err = parseTimeGenerously("2006-01-02 T15:04:00 -08:00")
testutils.Check(t, err)
if ts.Unix() != 1136243040 {
t.Fatalf("parsed time incorrectly: %d", ts.Unix())
}
ts, err = parseTimeGenerously("2006-01-02_T15:04:00_-08:00")
testutils.Check(t, err)
if ts.Unix() != 1136243040 {
t.Fatalf("parsed time incorrectly: %d", ts.Unix())
}
ts, err = parseTimeGenerously("2006-01-02T15:04:00")
testutils.Check(t, err)
if ts.Year() != 2006 || ts.Month() != time.January || ts.Day() != 2 || ts.Hour() != 15 || ts.Minute() != 4 || ts.Second() != 0 {
t.Fatalf("parsed time incorrectly: %d", ts.Unix())
}
ts, err = parseTimeGenerously("2006-01-02_T15:04:00")
testutils.Check(t, err)
if ts.Year() != 2006 || ts.Month() != time.January || ts.Day() != 2 || ts.Hour() != 15 || ts.Minute() != 4 || ts.Second() != 0 {
t.Fatalf("parsed time incorrectly: %d", ts.Unix())
}
ts, err = parseTimeGenerously("2006-01-02_15:04:00")
testutils.Check(t, err)
if ts.Year() != 2006 || ts.Month() != time.January || ts.Day() != 2 || ts.Hour() != 15 || ts.Minute() != 4 || ts.Second() != 0 {
t.Fatalf("parsed time incorrectly: %d", ts.Unix())
}
ts, err = parseTimeGenerously("2006-01-02T15:04")
testutils.Check(t, err)
if ts.Year() != 2006 || ts.Month() != time.January || ts.Day() != 2 || ts.Hour() != 15 || ts.Minute() != 4 || ts.Second() != 0 {
t.Fatalf("parsed time incorrectly: %d", ts.Unix())
}
ts, err = parseTimeGenerously("2006-01-02_15:04")
testutils.Check(t, err)
if ts.Year() != 2006 || ts.Month() != time.January || ts.Day() != 2 || ts.Hour() != 15 || ts.Minute() != 4 || ts.Second() != 0 {
t.Fatalf("parsed time incorrectly: %d", ts.Unix())
}
ts, err = parseTimeGenerously("2006-01-02")
testutils.Check(t, err)
if ts.Year() != 2006 || ts.Month() != time.January || ts.Day() != 2 || ts.Hour() != 0 || ts.Minute() != 0 || ts.Second() != 0 {
t.Fatalf("parsed time incorrectly: %d", ts.Unix())
}
}