Skip to content

Commit

Permalink
Build and include static files in agent
Browse files Browse the repository at this point in the history
  • Loading branch information
hoshiyosan committed Nov 25, 2021
1 parent 03fff58 commit 0dbc1ca
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 2 deletions.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include README.md
recursive-include pytest_agent *
14 changes: 13 additions & 1 deletion pytest_agent/api.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
"""
Defines API endpoints and policy.
"""
import pkg_resources
from typing import List

from fastapi import FastAPI
from fastapi.responses import RedirectResponse
from fastapi.staticfiles import StaticFiles
from fastapi.middleware.cors import CORSMiddleware
from starlette.responses import PlainTextResponse

Expand All @@ -15,9 +18,14 @@
title="Pytest Agent API",
description="Expose testing features and metrics via a REST API.",
version="v1",
docs_url="/",
docs_url="/docs",
redoc_url=None
)

static_path = pkg_resources.resource_filename(__name__, "static")

api.mount("/static", StaticFiles(directory=static_path, html=True), name="static")

api.add_middleware(
CORSMiddleware,
allow_origins=["*"],
Expand All @@ -26,6 +34,10 @@
allow_headers=["*"],
)

@api.get("/")
def home():
return RedirectResponse("/static")


@api.post("/tests/collect", response_model=List[TestStatusReadDTO])
def collect_and_update_tests():
Expand Down
1 change: 1 addition & 0 deletions pytest_agent/static/css/app.1289019b.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.statusbar-icon[data-v-bf2fb7a4]{margin-right:1em}.v-icon[data-v-323527bf]{margin-left:1em}
5 changes: 5 additions & 0 deletions pytest_agent/static/css/chunk-vendors.8d33546b.css

Large diffs are not rendered by default.

Binary file added pytest_agent/static/favicon.ico
Binary file not shown.
Binary file added pytest_agent/static/img/logo.c0a818de.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions pytest_agent/static/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/static/favicon.ico"><title>pytest_dashboard</title><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css"><link href="/static/css/app.1289019b.css" rel="preload" as="style"><link href="/static/css/chunk-vendors.8d33546b.css" rel="preload" as="style"><link href="/static/js/app.98e423ea.js" rel="preload" as="script"><link href="/static/js/chunk-vendors.70c07ae3.js" rel="preload" as="script"><link href="/static/css/chunk-vendors.8d33546b.css" rel="stylesheet"><link href="/static/css/app.1289019b.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but pytest_dashboard doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/static/js/chunk-vendors.70c07ae3.js"></script><script src="/static/js/app.98e423ea.js"></script></body></html>
2 changes: 2 additions & 0 deletions pytest_agent/static/js/app.98e423ea.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pytest_agent/static/js/app.98e423ea.js.map

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions pytest_agent/static/js/chunk-vendors.70c07ae3.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pytest_agent/static/js/chunk-vendors.70c07ae3.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pytest_dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"build": "vue-cli-service build --dest ../pytest_agent/static",
"lint": "vue-cli-service lint"
},
"dependencies": {
Expand Down
4 changes: 4 additions & 0 deletions pytest_dashboard/vue.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
module.exports = {
transpileDependencies: ["vuetify"],
publicPath:
process.env.NODE_ENV === "production"
? "/static" // prod
: "/", // dev
};
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ def load_long_description():
entry_points={"console_scripts": ["pytest-agent=pytest_agent.__main__:cli"]},
long_description=load_long_description(),
long_description_content_type='text/markdown',
include_package_data=True
)

0 comments on commit 0dbc1ca

Please sign in to comment.