/
BUILD
136 lines (121 loc) · 2.77 KB
/
BUILD
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
load("@rules_python//python:defs.bzl", "py_binary", "py_library")
load("@pip_deps//:requirements.bzl", "requirement")
load("@rules_pkg//:pkg.bzl", "pkg_tar", "pkg_deb")
py_binary(
name = "main",
srcs = ["main.py"],
deps = [
":httpd",
":fetch",
":transit",
"//gtfs_data:database",
requirement("prometheus_client")
],
)
pkg_tar(
name = "deb-bin",
package_dir = "/opt/gtfs-upcoming/bin",
# This depends on --build_python_zip.
srcs = [":main"],
mode = "0755",
)
pkg_tar(
name = "deb-config-sample",
package_dir = "/etc/gtfs-upcoming",
srcs = ["config-sample.ini"],
mode = "0644",
)
pkg_tar(
name = "deb-default",
package_dir = "/etc/default",
srcs = ["debian/gtfs-upcoming"],
mode = "0644",
)
pkg_tar(
name = "deb-service",
package_dir = "/lib/systemd/system",
srcs = ["debian/gtfs-upcoming.service"],
mode = "0644",
)
pkg_tar(
name = "deb-update-database",
package_dir = "/opt/gtfs-upcoming/bin",
# This depends on --build_python_zip.
srcs = ["debian/update-database.sh"],
mode = "0755",
)
pkg_tar(
name = "deb-update-database-cron",
package_dir = "/etc/cron.d",
srcs = ["debian/gtfs-upcoming-update-database.sample"],
mode = "0755",
)
pkg_tar(
name = "debian-data",
deps = [
":deb-bin",
":deb-config-sample",
":deb-default",
":deb-service",
":deb-update-database",
":deb-update-database-cron",
]
)
pkg_deb(
name = "main-deb",
architecture = "all",
built_using = "bazel",
data = ":debian-data",
depends = [
"python3",
# For refreshing the GTFS database
"curl",
"unzip"
],
postinst = "debian/postinst",
prerm = "debian/prerm",
postrm = "debian/postrm",
description_file = "debian/description",
maintainer = "Sean Rees <sean at erifax.org>",
package = "gtfs-upcoming",
version = "1.0.1",
)
py_library(
name = "httpd",
srcs = ["httpd.py"],
deps = [
requirement("prometheus_client")
]
)
py_library(
name = "fetch",
srcs = ["fetch.py"],
deps = [
requirement("prometheus_client")
],
)
py_library(
name = "transit",
srcs = ["transit.py"],
deps = [
"//gtfs_data:database",
requirement("gtfs-realtime-bindings"),
requirement("prometheus_client"),
requirement("six")
],
)
py_test(
name = "transit_test",
srcs = ["transit_test.py"],
deps = [
":transit",
"//gtfs_data:database",
requirement("protobuf"),
requirement("gtfs-realtime-bindings"),
],
data = [
"testdata/gtfsv1-sample-onetrip.json",
"testdata/gtfsv1-sample-twotrips.json",
"//gtfs_data:exported_testdata"
]
)