This repository has been archived by the owner on Nov 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
workflow-gtfs-validator.yaml
113 lines (110 loc) · 4.96 KB
/
workflow-gtfs-validator.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#
# Validates a GTFS dataset executing the GTFS validator on Cloud Run.
#
## Input:
# {
# "validator_image": "us-central1-docker.pkg.dev/md-poc-playground/gtfs-validator-registry/gtfs-validator-reporter@sha256:26767d681e5405e0e20a755d88047f126af6c3aebe46d898091f2e7c5c82bdd1",
# "feed_url": "https://storage.googleapis.com/storage/v1/b/mdb-latest/o/ar-buenos-aires-subterraneos-de-buenos-aires-subte-gtfs-6.zip?alt=media",
# "feed_id": "1234",
# "feed_key": "ar-buenos-aires-subterraneos-de-buenos-aires-subte-gtfs-6",
# "reference_validator_version": "4.0.0",
# "target_validator_version": "4.1.0",
# "reports_bucket_path": "gs://gtfs-validator-results-playground/reports"
# }
## Output:
# No output
main:
params: [args]
steps:
- init:
assign:
- reportsBucketPath: ${args.reports_bucket_path}
- feedUrl: ${args.feed_url}
- feedKey: ${args.feed_key}
- location: ${default(map.get(args, "region"), "us-central1")}
- dateTime: ${text.replace_all("" + sys.now(), ".", "")}
- feedId: ${args.feed_id}
- validatorImage: ${args.validator_image}
- referenceValidatorVersion: ${args.reference_validator_version}
- targetValidatorVersion: ${args.target_validator_version}
- jobName: ${"gtfs-" + dateTime + "-" + text.replace_all(feedKey, "-", "")}
- jobName: ${text.substring(jobName, 0, if(len(jobName) > 63, 63, len(jobName) ) )}
- initLog:
call: sys.log
args:
text: ${"Creating Job " + jobName}
severity: INFO
- createCloudRunJob:
call: googleapis.run.v1.namespaces.jobs.create
args:
location: "${location}"
parent: ${"namespaces/" + sys.get_env("GOOGLE_CLOUD_PROJECT_NUMBER")}
body:
apiVersion: run.googleapis.com/v1
kind: Job
metadata:
name: ${jobName}
spec:
template:
metadata:
annotations:
run.googleapis.com/client-name: cloud-console
client.knative.dev/user-image: ${validatorImage}
run.googleapis.com/execution-environment: gen2
spec:
parallelism: 1
taskCount: 1
template:
spec:
containers:
- image: ${validatorImage}
args:
- --url
- ${feedUrl}
- -cs
- ${reportsBucketPath}
- -rr
- ${referenceValidatorVersion}
- -rt
- ${targetValidatorVersion}
- -did
- ${feedKey}
resources:
limits:
cpu: 1000m
memory: 1Gi
maxRetries: 3
timeoutSeconds: '600'
serviceAccountName: [email protected]
result: createJobResult
- createJobLog:
call: sys.log
args:
text: ${json.encode_to_string(createJobResult)}
severity: INFO
- executeJob:
call: googleapis.run.v1.namespaces.jobs.run
args:
location: ${location}
name: ${"namespaces/" + sys.get_env("GOOGLE_CLOUD_PROJECT_NUMBER") + "/jobs/" + jobName}
result: executionResult
- executionJobLog:
call: sys.log
args:
text: ${executionResult}
- deleteCloudRunJob:
call: googleapis.run.v1.namespaces.jobs.delete
args:
location: ${location}
name: ${"namespaces/" + sys.get_env("GOOGLE_CLOUD_PROJECT_NUMBER") + "/jobs/" + jobName}
result: deleteJobResult
- deleteJobLog:
call: sys.log
args:
text: ${deleteJobResult}
- response:
return:
executionResult: ${executionResult}
feedId: ${feedId}
feedKey: ${feedKey}
dateTime: ${dateTime}