Feature/git pages -> oma nginx perusteinen raporointipalvelu #48

Merged
niko merged 11 commits from feature/git-pages-sisäinen-toiminta-default-moodiin into main 2026-06-28 09:10:10 +03:00
3 changed files with 21 additions and 12 deletions
Showing only changes of commit c635044a03 - Show all commits
+8
View File
@@ -67,6 +67,14 @@ class H(http.server.BaseHTTPRequestHandler):
self.end_headers() self.end_headers()
self.wfile.write(body.encode()) self.wfile.write(body.encode())
def do_PUT(self):
self._log_request('PUT')
code, body = self._get_response()
self.send_response(code)
self.send_header('Content-Type', 'application/json')
self.end_headers()
self.wfile.write(body.encode())
def do_PATCH(self): def do_PATCH(self):
self._log_request('PATCH') self._log_request('PATCH')
code, body = self._get_response() code, body = self._get_response()
+11 -11
View File
@@ -7,15 +7,15 @@ setup() {
export GIT_PAGES_PUBLISH_TOKEN="publish-token-abc" export GIT_PAGES_PUBLISH_TOKEN="publish-token-abc"
export GITHUB_REPOSITORY="test-owner/test-repo" export GITHUB_REPOSITORY="test-owner/test-repo"
export GITHUB_SHA="abc123def456789012345678901234567890abcd" export GITHUB_SHA="abc123def456789012345678901234567890abcd"
export GITHUB_REF_NAME="main"
REPORT_DIR="reports/abc123de/unit-tests" mkdir -p "unit-tests"
mkdir -p "$REPORT_DIR" echo "<html>test</html>" > "unit-tests/index.html"
echo "<html>test</html>" > "$REPORT_DIR/index.html"
} }
teardown() { teardown() {
mock_stop mock_stop
rm -rf "reports/abc123de" rm -rf "unit-tests" "sub"
} }
@test "missing suite_path argument → exit 1" { @test "missing suite_path argument → exit 1" {
@@ -24,11 +24,11 @@ teardown() {
[[ "$output" == *"ERROR"* ]] [[ "$output" == *"ERROR"* ]]
} }
@test "missing GITEA_API_URL → exit 1" { @test "missing GITHUB_REF_NAME → exit 1" {
unset GITEA_API_URL unset GITHUB_REF_NAME
run bash scripts/publish-git-pages.sh "unit-tests" run bash scripts/publish-git-pages.sh "unit-tests"
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
[[ "$output" == *"GITEA_API_URL"* ]] [[ "$output" == *"GITHUB_REF_NAME"* ]]
} }
@test "missing GIT_PAGES_URL → exit 1" { @test "missing GIT_PAGES_URL → exit 1" {
@@ -65,19 +65,19 @@ teardown() {
mock_start mock_start
run bash scripts/publish-git-pages.sh "unit-tests" run bash scripts/publish-git-pages.sh "unit-tests"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[[ "$output" == "http://localhost:18080/test-owner/test-repo/reports/abc123de" ]] [[ "$output" == "http://localhost:18080/test-owner/test-repo/main/abc123de/unit-tests/" ]]
} }
@test "publish with suite subpath" { @test "publish with suite subpath" {
mkdir -p "reports/abc123de/sub/suite" mkdir -p "sub/suite"
echo "sub" > "reports/abc123de/sub/suite/result.html" echo "sub" > "sub/suite/result.html"
mock_set_sequence '[ mock_set_sequence '[
{"code":200,"body":"published"} {"code":200,"body":"published"}
]' ]'
mock_start mock_start
run bash scripts/publish-git-pages.sh "sub/suite" run bash scripts/publish-git-pages.sh "sub/suite"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[[ "$output" == "http://localhost:18080/test-owner/test-repo/reports/abc123de" ]] [[ "$output" == "http://localhost:18080/test-owner/test-repo/main/abc123de/sub/suite/" ]]
} }
@test "git-pages returns HTTP 500 → exit 1" { @test "git-pages returns HTTP 500 → exit 1" {
+2 -1
View File
@@ -8,6 +8,7 @@ setup() {
export GITHUB_REPOSITORY="test-owner/test-repo" export GITHUB_REPOSITORY="test-owner/test-repo"
export GITHUB_SHA="abc123def456789012345678901234567890abcd" export GITHUB_SHA="abc123def456789012345678901234567890abcd"
export GITHUB_RUN_ID="42" export GITHUB_RUN_ID="42"
export GITHUB_REF_NAME="main"
} }
teardown() { teardown() {
@@ -35,7 +36,7 @@ teardown() {
body=$(mock_get_request_body) body=$(mock_get_request_body)
[[ "$body" == *'"state":"success"'* ]] [[ "$body" == *'"state":"success"'* ]]
[[ "$body" == *'"context":"unit-test"'* ]] [[ "$body" == *'"context":"unit-test"'* ]]
[[ "$body" == *'"target_url":"https://reports.example.com/test-owner/test-repo/reports/abc123de/cucumber/"'* ]] [[ "$body" == *'"target_url":"https://reports.example.com/test-owner/test-repo/main/abc123de/cucumber/"'* ]]
} }
@test "failure status constructs run URL when no suite" { @test "failure status constructs run URL when no suite" {