mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 10:05:41 +00:00
CI: coverage build step
This commit is contained in:
@@ -35,7 +35,7 @@ pub mod routes {
|
||||
impl Docs {
|
||||
pub const fn new() -> Self {
|
||||
Docs {
|
||||
home: "/docs/",
|
||||
home: "/docs",
|
||||
spec: "/docs/openapi.json",
|
||||
assets: "/docs/{_:.*}",
|
||||
}
|
||||
@@ -84,6 +84,7 @@ async fn spec() -> HttpResponse {
|
||||
}
|
||||
|
||||
async fn index() -> HttpResponse {
|
||||
println!("getting index");
|
||||
handle_embedded_file("index.html")
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
use std::env;
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
@@ -32,8 +33,57 @@ lazy_static! {
|
||||
#[cfg(not(tarpaulin_include))]
|
||||
#[actix_rt::main]
|
||||
async fn main() {
|
||||
pretty_env_logger::init();
|
||||
let data = Data::new().await;
|
||||
|
||||
for arg in env::args() {
|
||||
if arg == "--build" {
|
||||
println!("Building cache buster config");
|
||||
build();
|
||||
}
|
||||
}
|
||||
|
||||
sqlx::migrate!("./migrations/").run(&data.db).await.unwrap();
|
||||
}
|
||||
|
||||
fn build() {
|
||||
use std::process::Command;
|
||||
|
||||
// note: add error checking yourself.
|
||||
let output = Command::new("git")
|
||||
.args(&["rev-parse", "HEAD"])
|
||||
.output()
|
||||
.unwrap();
|
||||
let git_hash = String::from_utf8(output.stdout).unwrap();
|
||||
println!("cargo:rustc-env=GIT_HASH={}", git_hash);
|
||||
|
||||
let yml = include_str!("../openapi.yaml");
|
||||
let api_json: serde_json::Value = serde_yaml::from_str(yml).unwrap();
|
||||
println!(
|
||||
"cargo:rustc-env=OPEN_API_DOCS={}",
|
||||
serde_json::to_string(&api_json).unwrap()
|
||||
);
|
||||
cache_bust();
|
||||
}
|
||||
|
||||
fn cache_bust() {
|
||||
use cache_buster::BusterBuilder;
|
||||
let types = vec![
|
||||
mime::IMAGE_PNG,
|
||||
mime::IMAGE_SVG,
|
||||
mime::IMAGE_JPEG,
|
||||
mime::IMAGE_GIF,
|
||||
mime::APPLICATION_JAVASCRIPT,
|
||||
mime::TEXT_CSS,
|
||||
];
|
||||
|
||||
let config = BusterBuilder::default()
|
||||
.source("./static-assets")
|
||||
.result("./static")
|
||||
.mime_types(types)
|
||||
.copy(true)
|
||||
.follow_links(true)
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
config.process().unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user