Skip to content

Commit

Permalink
Update runner base image + tweaks to support it (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcspragu authored Dec 8, 2024
1 parent fd79e9d commit 4ee80b0
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 22 deletions.
4 changes: 2 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ oci_pull(

oci_pull(
name = "runner_base",
# This digest is of the nightly/main tag as of 2024-07-22
digest = "sha256:7adec544294b5cb9e11c6bb4c43d0b2de646e5f933639f86c85f3f03c99f650e",
# This digest is of the nightly/main tag as of 2024-12-06
digest = "sha256:35c8eaac721350ca6ef3bfb3e6080c5412ddb9061299c62bb4fd2fc6df8d0227",
image = "ghcr.io/rmi-pacta/workflow.pacta.webapp",
platforms = ["linux/amd64"],
)
Expand Down
18 changes: 12 additions & 6 deletions async/async.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ type ReportInput struct {
}

type ReportInputPortfolio struct {
Files string `json:"files"`
HoldingsDate string `json:"holdingsDate"`
Name string `json:"name"`
Files []string `json:"files"`
HoldingsDate string `json:"holdingsDate"`
Name string `json:"name"`
}

type ReportEnv struct {
Expand Down Expand Up @@ -378,7 +378,7 @@ func (h *Handler) CreateReport(ctx context.Context, taskID task.ID, req *task.Cr

inp := ReportInput{
Portfolio: ReportInputPortfolio{
Files: fileNameWithExt,
Files: []string{fileNameWithExt},
HoldingsDate: "2023-12-31", // TODO(#206)
Name: "FooPortfolio", // TODO(#206)
},
Expand Down Expand Up @@ -499,7 +499,7 @@ func (h *Handler) uploadDirectory(ctx context.Context, dirPath, container string
// Returns pacta.FileType_UNKNOWN for unrecognized extensions, which we'll serve as binary blobs.
ft := fileTypeFromFilename(fn)
if ft == pacta.FileType_UNKNOWN {
h.logger.Error("unhandled file extension", zap.String("dir", dirPath), zap.String("file_ext", filepath.Ext(fn)))
h.logger.Error("unhandled file extension", zap.String("dir", dirPath), zap.String("filename", fn), zap.String("file_ext", filepath.Ext(fn)))
}
artifacts = append(artifacts, &task.AnalysisArtifact{
BlobURI: pacta.BlobURI(uri),
Expand Down Expand Up @@ -538,6 +538,8 @@ func fileTypeFromFilename(fn string) pacta.FileType {
switch ext2 := filepath.Ext(strings.TrimSuffix(fn, ext)); ext2 {
case ".js":
return pacta.FileType_JS_MAP
case ".css":
return pacta.FileType_CSS_MAP
default:
return pacta.FileType_UNKNOWN
}
Expand All @@ -556,7 +558,11 @@ func fileTypeFromFilename(fn string) pacta.FileType {
case ".jpg":
return pacta.FileType_JPG
case ".pdf":
return pacta.FileType_TTF
return pacta.FileType_PDF
case ".xlsx":
return pacta.FileType_XLSX
case ".rds":
return pacta.FileType_RDS
default:
return pacta.FileType_UNKNOWN
}
Expand Down
5 changes: 4 additions & 1 deletion db/sqldb/golden/human_readable_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ CREATE TYPE file_type AS ENUM (
'svg',
'png',
'jpg',
'pdf');
'pdf',
'xlsx',
'rds',
'css.map');
CREATE TYPE language AS ENUM (
'en',
'de',
Expand Down
5 changes: 4 additions & 1 deletion db/sqldb/golden/schema_dump.sql
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ CREATE TYPE public.file_type AS ENUM (
'svg',
'png',
'jpg',
'pdf'
'pdf',
'xlsx',
'rds',
'css.map'
);


Expand Down
34 changes: 34 additions & 0 deletions db/sqldb/migrations/0015_add_more_report_file_types.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
BEGIN;

-- There isn't a way to delete a value from an enum, so this is the workaround
-- https://stackoverflow.com/a/56777227/17909149

ALTER TABLE blob ALTER file_type TYPE TEXT;

DROP TYPE file_type;
CREATE TYPE file_type AS ENUM (
'csv',
'yaml',
'zip',
'html',
'json',
'txt',
'css',
'js',
'ttf',
'unknown',
'js.map',
'woff',
'woff2',
'eot',
'svg',
'png',
'jpg',
'pdf'
);

ALTER TABLE blob
ALTER file_type TYPE file_type
USING file_type::file_type;

COMMIT;
7 changes: 7 additions & 0 deletions db/sqldb/migrations/0015_add_more_report_file_types.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
BEGIN;

ALTER TYPE file_type ADD VALUE 'xlsx';
ALTER TYPE file_type ADD VALUE 'rds';
ALTER TYPE file_type ADD VALUE 'css.map';

COMMIT;
1 change: 1 addition & 0 deletions db/sqldb/sqldb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func TestSchemaHistory(t *testing.T) {
{ID: 12, Version: 12}, // 0012_portfolio_properties
{ID: 13, Version: 13}, // 0013_user_search
{ID: 14, Version: 14}, // 0014_add_more_report_file_types
{ID: 15, Version: 15}, // 0015_add_more_report_file_types
}

if diff := cmp.Diff(want, got); diff != "" {
Expand Down
34 changes: 22 additions & 12 deletions pacta/pacta.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,18 +208,21 @@ const (
FileType_JSON = "json"

// All for serving reports
FileType_TEXT = "txt"
FileType_CSS = "css"
FileType_JS = "js"
FileType_JS_MAP = "js.map"
FileType_TTF = "ttf"
FileType_WOFF = "woff"
FileType_WOFF2 = "woff2"
FileType_EOT = "eot"
FileType_SVG = "svg"
FileType_PNG = "png"
FileType_JPG = "jpg"
FileType_PDF = "pdf"
FileType_TEXT = "txt"
FileType_CSS = "css"
FileType_CSS_MAP = "css.map"
FileType_JS = "js"
FileType_JS_MAP = "js.map"
FileType_TTF = "ttf"
FileType_WOFF = "woff"
FileType_WOFF2 = "woff2"
FileType_EOT = "eot"
FileType_SVG = "svg"
FileType_PNG = "png"
FileType_JPG = "jpg"
FileType_PDF = "pdf"
FileType_XLSX = "xlsx"
FileType_RDS = "rds"

FileType_UNKNOWN = "unknown"
)
Expand All @@ -243,6 +246,7 @@ var FileTypeValues = []FileType{
FileType_PNG,
FileType_JPG,
FileType_PDF,
FileType_XLSX,
FileType_UNKNOWN,
}

Expand All @@ -266,6 +270,8 @@ func ParseFileType(s string) (FileType, error) {
return FileType_TEXT, nil
case "css":
return FileType_CSS, nil
case "css.map":
return FileType_CSS_MAP, nil
case "js":
return FileType_JS, nil
case "js.map":
Expand All @@ -286,6 +292,10 @@ func ParseFileType(s string) (FileType, error) {
return FileType_JPG, nil
case "pdf":
return FileType_PDF, nil
case "xlsx":
return FileType_XLSX, nil
case "rds":
return FileType_RDS, nil
case "unknown":
return FileType_UNKNOWN, nil
}
Expand Down

0 comments on commit 4ee80b0

Please sign in to comment.