mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2025-02-17 00:49:47 +03:00
CI: coverage build step
This commit is contained in:
parent
5466d1f136
commit
9809cb7bea
5 changed files with 57 additions and 4 deletions
2
.github/workflows/coverage.yml
vendored
2
.github/workflows/coverage.yml
vendored
|
@ -66,7 +66,7 @@ jobs:
|
|||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: run
|
||||
args: --bin tests-migrate
|
||||
args: --bin tests-migrate -- --build
|
||||
env:
|
||||
DATABASE_URL: postgres://postgres:password@localhost:5432/postgres
|
||||
|
||||
|
|
|
@ -65,6 +65,8 @@ rand = "0.8"
|
|||
|
||||
sailfish = "0.3.2"
|
||||
|
||||
mime = "0.3.16"
|
||||
|
||||
[build-dependencies]
|
||||
serde_yaml = "0.8.17"
|
||||
serde_json = "1"
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
</a>
|
||||
</li>
|
||||
<li class="secondary-menu__item">
|
||||
<a class="secondary-menu__item-link" href="<.= crate::DOCS.home .>">
|
||||
<a class="secondary-menu__item-link" href="<.= crate::DOCS.home .>/">
|
||||
<img class="secondary-menu__icon" src="<.= crate::FILES.get("./static-assets/img/svg/file-text.svg").unwrap() .>" alt="" />
|
||||
<div class="secondary-menu__item-name">
|
||||
API Docs
|
||||
|
|
Loading…
Add table
Reference in a new issue