Skip to content

Commit

Permalink
Check failure logs
Browse files Browse the repository at this point in the history
  • Loading branch information
niveathika committed Nov 11, 2023
1 parent 9390e52 commit ff70094
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dashboard/tests/utils_test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import ballerina/test;

const IO_MODULE = "module-ballerina-io";
const JAVA_ARRAYS_MODULE = "module-ballerina-jballerina.java.arrays";
const GMAIL_MODULE = "module-ballerinax-googleapis.gmail";

@test:Config
function getRepoLinkTest() {
Expand All @@ -16,11 +17,13 @@ function getReleaseBadgeTest() {
@test:Config
function getBuildStatusBadgeTest() {
test:assertEquals(getBuildStatusBadge(IO_MODULE, "master"), "[![Build](https://img.shields.io/github/actions/workflow/status/ballerina-platform/module-ballerina-io/build-timestamped-master.yml?branch=master&label=)](https://github.com/ballerina-platform/module-ballerina-io/actions/workflows/build-timestamped-master.yml)");
test:assertEquals(getBuildStatusBadge(GMAIL_MODULE, "master"), "[![Build](https://img.shields.io/github/actions/workflow/status/ballerina-platform/module-ballerinax-googleapis.gmail/ci.yml?branch=master&label=)](https://github.com/ballerina-platform/module-ballerinax-googleapis.gmail/actions/workflows/ci.yml)" );
}

@test:Config
function getTrivyBadgeTest() {
test:assertEquals(getTrivyBadge(IO_MODULE, "master"), "[![Trivy](https://img.shields.io/github/actions/workflow/status/ballerina-platform/module-ballerina-io/trivy-scan.yml?branch=master&label=)](https://github.com/ballerina-platform/module-ballerina-io/actions/workflows/trivy-scan.yml)");
test:assertEquals(getTrivyBadge(GMAIL_MODULE, "master"), "[![Trivy](https://img.shields.io/badge/-N%2FA-yellow)](https://github.com/ballerina-platform/module-ballerinax-googleapis.gmail/actions/workflows/trivy-scan.yml)");
}

@test:Config
Expand Down
7 changes: 7 additions & 0 deletions dashboard/utils.bal
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import ballerina/http;
import ballerina/regex;
import ballerina/url;
import ballerina/io;

function getDashboardRow(Module module, string level) returns string|error {
string moduleName = module.name;
Expand Down Expand Up @@ -60,6 +61,9 @@ function getBuildStatusBadge(string moduleName, string defaultBranch) returns st
string workflowName = WORKFLOW_MASTER_BUILD;
string workflowFileUrl = string `/${BALLERINA_ORG_NAME}/${moduleName}/master/.github/workflows/${workflowName}`;
http:Response openUrlResponse = check openUrl(GITHUB_RAW_LINK, workflowFileUrl);
io:println(workflowFileUrl);
io:println(openUrlResponse.statusCode);
io:println(openUrlResponse.getTextPayload());
if openUrlResponse.statusCode == http:STATUS_NOT_FOUND {
workflowName = WORKFLOW_MASTER_CI_BUILD;
}
Expand All @@ -73,6 +77,9 @@ function getTrivyBadge(string moduleName, string defaultBranch) returns string|e
http:Response openUrlResponse = check openUrl(GITHUB_RAW_LINK, workflowFileUrl);
string badgeUrl = getGithubBadgeUrl(moduleName, WORKFLOW_TRIVY, defaultBranch, "");
string repoUrl = string `${BALLERINA_ORG_URL}/${moduleName}/actions/workflows/${WORKFLOW_TRIVY}`;
io:println(workflowFileUrl);
io:println(openUrlResponse.statusCode);
io:println(openUrlResponse.getTextPayload());
if openUrlResponse.statusCode == http:STATUS_NOT_FOUND {
badgeUrl = NABADGE;
}
Expand Down

0 comments on commit ff70094

Please sign in to comment.