forked from the-distro/ofborg
It takes build jobs now?
This commit is contained in:
parent
6abdbb5597
commit
0133c66887
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@ config.php
|
||||||
vendor
|
vendor
|
||||||
*.log
|
*.log
|
||||||
test.php
|
test.php
|
||||||
|
config.json
|
||||||
|
|
86
ofborg/Cargo.lock
generated
86
ofborg/Cargo.lock
generated
|
@ -5,6 +5,9 @@ dependencies = [
|
||||||
"amqp 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"amqp 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"fs2 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"fs2 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"md5 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"md5 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde_derive 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde_json 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -97,6 +100,11 @@ dependencies = [
|
||||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dtoa"
|
||||||
|
version = "0.4.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "enum_primitive"
|
name = "enum_primitive"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
|
@ -172,6 +180,11 @@ dependencies = [
|
||||||
"unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itoa"
|
||||||
|
version = "0.3.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kernel32-sys"
|
name = "kernel32-sys"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
|
@ -281,6 +294,11 @@ dependencies = [
|
||||||
"walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quote"
|
||||||
|
version = "0.3.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rand"
|
name = "rand"
|
||||||
version = "0.3.17"
|
version = "0.3.17"
|
||||||
|
@ -321,6 +339,59 @@ dependencies = [
|
||||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde"
|
||||||
|
version = "1.0.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_derive"
|
||||||
|
version = "1.0.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde_derive_internals 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_derive_internals"
|
||||||
|
version = "0.16.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_json"
|
||||||
|
version = "1.0.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "0.11.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "synom"
|
||||||
|
version = "0.11.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tempdir"
|
name = "tempdir"
|
||||||
version = "0.3.5"
|
version = "0.3.5"
|
||||||
|
@ -359,6 +430,11 @@ name = "unicode-normalization"
|
||||||
version = "0.1.5"
|
version = "0.1.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-xid"
|
||||||
|
version = "0.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "url"
|
name = "url"
|
||||||
version = "1.6.0"
|
version = "1.6.0"
|
||||||
|
@ -415,6 +491,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
"checksum cc 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a9b13a57efd6b30ecd6598ebdb302cca617930b5470647570468a65d12ef9719"
|
"checksum cc 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a9b13a57efd6b30ecd6598ebdb302cca617930b5470647570468a65d12ef9719"
|
||||||
"checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de"
|
"checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de"
|
||||||
"checksum dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97590ba53bcb8ac28279161ca943a924d1fd4a8fb3fa63302591647c4fc5b850"
|
"checksum dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97590ba53bcb8ac28279161ca943a924d1fd4a8fb3fa63302591647c4fc5b850"
|
||||||
|
"checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab"
|
||||||
"checksum enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be4551092f4d519593039259a9ed8daedf0da12e5109c5280338073eaeb81180"
|
"checksum enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be4551092f4d519593039259a9ed8daedf0da12e5109c5280338073eaeb81180"
|
||||||
"checksum env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "15abd780e45b3ea4f76b4e9a26ff4843258dd8a3eed2775a0e7368c2e7936c2f"
|
"checksum env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "15abd780e45b3ea4f76b4e9a26ff4843258dd8a3eed2775a0e7368c2e7936c2f"
|
||||||
"checksum error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9435d864e017c3c6afeac1654189b06cdb491cf2ff73dbf0d73b0f292f42ff8"
|
"checksum error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9435d864e017c3c6afeac1654189b06cdb491cf2ff73dbf0d73b0f292f42ff8"
|
||||||
|
@ -424,6 +501,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
"checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb"
|
"checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb"
|
||||||
"checksum gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0912515a8ff24ba900422ecda800b52f4016a56251922d397c576bf92c690518"
|
"checksum gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0912515a8ff24ba900422ecda800b52f4016a56251922d397c576bf92c690518"
|
||||||
"checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d"
|
"checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d"
|
||||||
|
"checksum itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c"
|
||||||
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
||||||
"checksum lazy_static 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c9e5e58fa1a4c3b915a561a78a22ee0cac6ab97dca2504428bc1cb074375f8d5"
|
"checksum lazy_static 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c9e5e58fa1a4c3b915a561a78a22ee0cac6ab97dca2504428bc1cb074375f8d5"
|
||||||
"checksum libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "5ba3df4dcb460b9dfbd070d41c94c19209620c191b0340b929ce748a2bcd42d2"
|
"checksum libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "5ba3df4dcb460b9dfbd070d41c94c19209620c191b0340b929ce748a2bcd42d2"
|
||||||
|
@ -439,16 +517,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
"checksum percent-encoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de154f638187706bde41d9b4738748933d64e6b37bdbffc0b47a97d16a6ae356"
|
"checksum percent-encoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de154f638187706bde41d9b4738748933d64e6b37bdbffc0b47a97d16a6ae356"
|
||||||
"checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903"
|
"checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903"
|
||||||
"checksum pnacl-build-helper 1.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "dfbe13ee77c06fb633d71c72438bd983286bb3521863a753ade8e951c7efb090"
|
"checksum pnacl-build-helper 1.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "dfbe13ee77c06fb633d71c72438bd983286bb3521863a753ade8e951c7efb090"
|
||||||
|
"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
|
||||||
"checksum rand 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "61efcbcd9fa8d8fbb07c84e34a8af18a1ff177b449689ad38a6e9457ecc7b2ae"
|
"checksum rand 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "61efcbcd9fa8d8fbb07c84e34a8af18a1ff177b449689ad38a6e9457ecc7b2ae"
|
||||||
"checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f"
|
"checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f"
|
||||||
"checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957"
|
"checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957"
|
||||||
"checksum rustc-demangle 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aee45432acc62f7b9a108cc054142dac51f979e69e71ddce7d6fc7adf29e817e"
|
"checksum rustc-demangle 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aee45432acc62f7b9a108cc054142dac51f979e69e71ddce7d6fc7adf29e817e"
|
||||||
"checksum same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d931a44fdaa43b8637009e7632a02adc4f2b2e0733c08caa4cf00e8da4a117a7"
|
"checksum same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d931a44fdaa43b8637009e7632a02adc4f2b2e0733c08caa4cf00e8da4a117a7"
|
||||||
|
"checksum serde 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "395993cac4e3599c7c1b70a6a92d3b3f55f4443df9f0b5294e362285ad7c9ecb"
|
||||||
|
"checksum serde_derive 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "7fa060f679fe2d5a9f7374dd4553dc907eba4f9acf183e4c7baf69eae02e6ca8"
|
||||||
|
"checksum serde_derive_internals 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bd381f6d01a6616cdba8530492d453b7761b456ba974e98768a18cad2cd76f58"
|
||||||
|
"checksum serde_json 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ae1e67ce320daa7e494c578e34d4b00689f23bb94512fe0ca0dfaf02ea53fb67"
|
||||||
|
"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad"
|
||||||
|
"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
|
||||||
"checksum tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "87974a6f5c1dfb344d733055601650059a3363de2a6104819293baff662132d6"
|
"checksum tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "87974a6f5c1dfb344d733055601650059a3363de2a6104819293baff662132d6"
|
||||||
"checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03"
|
"checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03"
|
||||||
"checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5"
|
"checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5"
|
||||||
"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"
|
"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"
|
||||||
"checksum unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "51ccda9ef9efa3f7ef5d91e8f9b83bbe6955f9bf86aec89d5cce2c874625920f"
|
"checksum unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "51ccda9ef9efa3f7ef5d91e8f9b83bbe6955f9bf86aec89d5cce2c874625920f"
|
||||||
|
"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
|
||||||
"checksum url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa35e768d4daf1d85733418a49fb42e10d7f633e394fccab4ab7aba897053fe2"
|
"checksum url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa35e768d4daf1d85733418a49fb42e10d7f633e394fccab4ab7aba897053fe2"
|
||||||
"checksum user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ef4711d107b21b410a3a974b1204d9accc8b10dad75d8324b5d755de1617d47"
|
"checksum user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ef4711d107b21b410a3a974b1204d9accc8b10dad75d8324b5d755de1617d47"
|
||||||
"checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f"
|
"checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f"
|
||||||
|
|
|
@ -7,3 +7,6 @@ authors = ["Graham Christensen <graham@grahamc.com>"]
|
||||||
amqp = "0.1.0"
|
amqp = "0.1.0"
|
||||||
md5 = "0.3.5"
|
md5 = "0.3.5"
|
||||||
fs2 = "0.4.2"
|
fs2 = "0.4.2"
|
||||||
|
serde = "1.0"
|
||||||
|
serde_derive = "1.0"
|
||||||
|
serde_json = "1.0"
|
|
@ -1,6 +1,10 @@
|
||||||
extern crate ofborg;
|
extern crate ofborg;
|
||||||
extern crate amqp;
|
extern crate amqp;
|
||||||
|
|
||||||
|
use std::env;
|
||||||
|
use amqp::{Consumer, Channel};
|
||||||
|
use amqp::protocol::basic::{Deliver,BasicProperties};
|
||||||
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use amqp::Basic;
|
use amqp::Basic;
|
||||||
use amqp::protocol;
|
use amqp::protocol;
|
||||||
|
@ -9,22 +13,19 @@ use amqp::Table;
|
||||||
use std::process;
|
use std::process;
|
||||||
use std::io::Error;
|
use std::io::Error;
|
||||||
|
|
||||||
|
use ofborg::config;
|
||||||
use ofborg::checkout;
|
use ofborg::checkout;
|
||||||
use ofborg::worker;
|
use ofborg::worker;
|
||||||
use ofborg::worker::{Actions,StdPr,StdRepo};
|
use ofborg::message::buildjob;
|
||||||
|
use ofborg::worker::Actions;
|
||||||
|
|
||||||
pub struct BuildJob {
|
|
||||||
pub repo: StdRepo,
|
|
||||||
pub pr: StdPr,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
let cfg = config::load(env::args().nth(1).unwrap().as_ref());
|
||||||
|
|
||||||
println!("Hello, world!");
|
println!("Hello, world!");
|
||||||
|
|
||||||
|
|
||||||
let mut session = Session::open_url("amqps://grahamc:cCbKQmwnRcd8kvPW9cjmMSkp@events.nix.gsc.io//").unwrap();
|
let mut session = Session::open_url(&cfg.rabbitmq.as_uri()).unwrap();
|
||||||
let mut channel = session.open_channel(1).unwrap();
|
let mut channel = session.open_channel(1).unwrap();
|
||||||
|
|
||||||
//queue: &str, passive: bool, durable: bool, exclusive: bool, auto_delete: bool, nowait: bool, arguments: Table
|
//queue: &str, passive: bool, durable: bool, exclusive: bool, auto_delete: bool, nowait: bool, arguments: Table
|
||||||
|
@ -39,7 +40,7 @@ fn main() {
|
||||||
worker::new(BuildWorker{
|
worker::new(BuildWorker{
|
||||||
cloner: cloner
|
cloner: cloner
|
||||||
}),
|
}),
|
||||||
"my_queue_name",
|
"build-inputs-samples",
|
||||||
"lmao1",
|
"lmao1",
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
|
@ -48,11 +49,11 @@ fn main() {
|
||||||
Table::new()
|
Table::new()
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Err(result) = channel.basic_publish("", "my_queue_name", true, false,
|
channel.start_consuming();
|
||||||
protocol::basic::BasicProperties{ content_type: Some("text".to_string()), ..Default::default()}, (b"Hello from rust!").to_vec()) {
|
|
||||||
println!("Failed to publish: {:?}", result);
|
channel.close(200, "Bye").unwrap();
|
||||||
process::exit(1);
|
session.close(200, "Good Bye");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct BuildWorker {
|
struct BuildWorker {
|
||||||
|
@ -60,14 +61,31 @@ struct BuildWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl worker::SimpleWorker for BuildWorker {
|
impl worker::SimpleWorker for BuildWorker {
|
||||||
type J = BuildJob;
|
type J = buildjob::BuildJob;
|
||||||
|
|
||||||
fn consumer(&self, job: BuildJob, resp: Actions) -> Result<(), Error> {
|
fn msg_to_job(&self, method: &Deliver, headers: &BasicProperties,
|
||||||
|
body: &Vec<u8>) -> Result<Self::J, String> {
|
||||||
|
println!("lmao I got a job?");
|
||||||
|
return match buildjob::from(body) {
|
||||||
|
Ok(e) => { return Ok(e) }
|
||||||
|
Err(e) => {
|
||||||
|
println!("{:?}", String::from_utf8(body.clone()));
|
||||||
|
panic!("{:?}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn consumer(&self, job: buildjob::BuildJob, resp: Actions) -> Result<(), Error> {
|
||||||
let project = self.cloner.project(job.repo.full_name, job.repo.clone_url);
|
let project = self.cloner.project(job.repo.full_name, job.repo.clone_url);
|
||||||
let co = project.clone_for("builder".to_string(),
|
let co = project.clone_for("builder".to_string(),
|
||||||
job.pr.number.to_string())?;
|
job.pr.number.to_string())?;
|
||||||
|
|
||||||
let refpath = co.checkout_ref(job.pr.target_branch.as_ref());
|
let target_branch = match job.pr.target_branch {
|
||||||
|
Some(x) => { x }
|
||||||
|
None => { String::from("origin/master") }
|
||||||
|
};
|
||||||
|
|
||||||
|
let refpath = co.checkout_ref(target_branch.as_ref());
|
||||||
co.fetch_pr(job.pr.number).unwrap();
|
co.fetch_pr(job.pr.number).unwrap();
|
||||||
co.merge_commit(job.pr.head_sha.as_ref()).unwrap();
|
co.merge_commit(job.pr.head_sha.as_ref()).unwrap();
|
||||||
|
|
||||||
|
|
32
ofborg/src/config.rs
Normal file
32
ofborg/src/config.rs
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
use serde_json;
|
||||||
|
use std::fs::File;
|
||||||
|
use std::path::Path;
|
||||||
|
use std::io::Read;
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct Config {
|
||||||
|
pub rabbitmq: RabbitMQConfig,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct RabbitMQConfig {
|
||||||
|
pub host: String,
|
||||||
|
pub username: String,
|
||||||
|
pub password: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RabbitMQConfig {
|
||||||
|
pub fn as_uri(&self) -> String{
|
||||||
|
return format!("amqps://{}:{}@{}//", self.username, self.password, self.host);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn load(filename: &Path) -> Config {
|
||||||
|
let mut file = File::open(filename).unwrap();
|
||||||
|
let mut contents = String::new();
|
||||||
|
file.read_to_string(&mut contents).unwrap();
|
||||||
|
|
||||||
|
let deserialized: Config = serde_json::from_str(&contents).unwrap();
|
||||||
|
|
||||||
|
return deserialized;
|
||||||
|
}
|
|
@ -1,3 +1,8 @@
|
||||||
|
#[macro_use]
|
||||||
|
extern crate serde_derive;
|
||||||
|
extern crate serde;
|
||||||
|
extern crate serde_json;
|
||||||
|
|
||||||
extern crate amqp;
|
extern crate amqp;
|
||||||
extern crate fs2;
|
extern crate fs2;
|
||||||
extern crate md5;
|
extern crate md5;
|
||||||
|
@ -6,10 +11,15 @@ pub mod checkout;
|
||||||
pub mod locks;
|
pub mod locks;
|
||||||
pub mod clone;
|
pub mod clone;
|
||||||
pub mod worker;
|
pub mod worker;
|
||||||
|
pub mod config;
|
||||||
|
pub mod message;
|
||||||
|
|
||||||
pub mod ofborg {
|
pub mod ofborg {
|
||||||
|
pub use config;
|
||||||
pub use checkout;
|
pub use checkout;
|
||||||
pub use locks;
|
pub use locks;
|
||||||
pub use clone;
|
pub use clone;
|
||||||
pub use worker;
|
pub use worker;
|
||||||
|
pub use message;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
12
ofborg/src/message/buildjob.rs
Normal file
12
ofborg/src/message/buildjob.rs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
use ofborg::message::{Pr,Repo};
|
||||||
|
use serde_json;
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct BuildJob {
|
||||||
|
pub repo: Repo,
|
||||||
|
pub pr: Pr,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn from(data: &Vec<u8>) -> Result<BuildJob, serde_json::error::Error> {
|
||||||
|
return serde_json::from_slice(&data);
|
||||||
|
}
|
13
ofborg/src/message/common.rs
Normal file
13
ofborg/src/message/common.rs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct Repo {
|
||||||
|
pub full_name: String,
|
||||||
|
pub clone_url: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct Pr {
|
||||||
|
pub target_branch: Option<String>,
|
||||||
|
pub number: i64,
|
||||||
|
pub head_sha: String,
|
||||||
|
}
|
4
ofborg/src/message/mod.rs
Normal file
4
ofborg/src/message/mod.rs
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
mod common;
|
||||||
|
pub mod buildjob;
|
||||||
|
|
||||||
|
use self::common::{Pr,Repo};
|
|
@ -8,23 +8,15 @@ pub struct Worker<T: SimpleWorker> {
|
||||||
internal: T
|
internal: T
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct StdRepo {
|
|
||||||
pub full_name: String,
|
|
||||||
pub clone_url: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct StdPr {
|
|
||||||
pub target_branch: String,
|
|
||||||
pub number: i64,
|
|
||||||
pub head_sha: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Actions {
|
pub struct Actions {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait SimpleWorker {
|
pub trait SimpleWorker {
|
||||||
type J;
|
type J;
|
||||||
fn consumer(&self, job: Self::J, resp: Actions) -> Result<(), Error>;
|
fn consumer(&self, job: Self::J, resp: Actions) -> Result<(), Error>;
|
||||||
|
|
||||||
|
fn msg_to_job(&self, method: &Deliver, headers: &BasicProperties,
|
||||||
|
body: &Vec<u8>) -> Result<Self::J, String>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new<T: SimpleWorker>(worker: T) -> Worker<T> {
|
pub fn new<T: SimpleWorker>(worker: T) -> Worker<T> {
|
||||||
|
@ -33,11 +25,28 @@ pub fn new<T: SimpleWorker>(worker: T) -> Worker<T> {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
impl <T: SimpleWorker + Send> Consumer for Worker<T> {
|
impl <T: SimpleWorker + Send> Consumer for Worker<T> {
|
||||||
fn handle_delivery(&mut self,
|
fn handle_delivery(&mut self,
|
||||||
channel: &mut Channel,
|
channel: &mut Channel,
|
||||||
method: Deliver,
|
method: Deliver,
|
||||||
headers: BasicProperties,
|
headers: BasicProperties,
|
||||||
body: Vec<u8>) {
|
body: Vec<u8>) {
|
||||||
|
|
||||||
|
match self.internal.msg_to_job(&method, &headers, &body) {
|
||||||
|
Ok(job) => {
|
||||||
|
let actions = Actions{};
|
||||||
|
match self.internal.consumer(job, actions) {
|
||||||
|
Ok(_) => { /* :) */ }
|
||||||
|
Err(_) => {
|
||||||
|
panic!("failed to run job!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
panic!(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue