Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dashboard failures #5756

Merged
merged 4 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dashboard/constants.bal
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

// Names
const BALLERINA_ORG_NAME = "ballerina-platform";
const BALLERINA_STANDARD_LIBRARY = "ballerina-standard-library";
const BALLERINA_STANDARD_LIBRARY = "ballerina-library";

// Links
const BALLERINA_ORG_URL = "https://github.com/ballerina-platform";
Expand Down Expand Up @@ -57,5 +57,6 @@ const BALX_TITLE = "## Ballerina Extended Modules";
// Workflow files
const WORKFLOW_MASTER_BUILD = "build-timestamped-master.yml";
const WORKFLOW_TRIVY = "trivy-scan.yml";
const WORKFLOW_MASTER_CI_BUILD = "ci.yml";
const WORKFLOW_PROCESS_LOAD_TESTS = "process-load-test-result.yml";
const WORKFLOW_BAL_TEST_NATIVE = "build-with-bal-test-graalvm.yml";
2 changes: 1 addition & 1 deletion dashboard/remote.bal
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function count(github:Issue issue) {
issueCount += 1;
}

function openUrl(string page, string url) returns http:Response|error? {
function openUrl(string page, string url) returns http:Response|error {
http:Client httpClient = check new (page, config = {
auth: {
token: os:getEnv(BALLERINA_BOT_TOKEN)
Expand Down
13 changes: 10 additions & 3 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 @@ -13,14 +14,20 @@ function getReleaseBadgeTest() {
test:assertEquals(getReleaseBadge(IO_MODULE), "[![GitHub Release](https://img.shields.io/github/v/release/ballerina-platform/module-ballerina-io?sort=semver&color=30c955&label=)](https://github.com/ballerina-platform/module-ballerina-io/releases)");
}

@test:Config
@test:Config {
enable: false
}
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
@test:Config {
enable: false
}
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 All @@ -45,5 +52,5 @@ function getLoadTestsBadgeTest() {
enable: false
}
function getBugsBadgeTest() {
test:assertEquals(getBugsBadge(JAVA_ARRAYS_MODULE), "[![Bugs](https://img.shields.io/github/issues-search/ballerina-platform/ballerina-standard-library?query=is%3Aopen%20label%3Amodule%2Fjava.arrays%20label%3AType%2FBug&label=&color=30c955)](https://github.com/ballerina-platform/ballerina-standard-library/issues?q=is%3Aopen%20label%3Amodule%2Fjava.arrays%20label%3AType%2FBug)");
test:assertEquals(getBugsBadge(JAVA_ARRAYS_MODULE), "[![Bugs](https://img.shields.io/github/issues-search/ballerina-platform/ballerina-library?query=is%3Aopen%20label%3Amodule%2Fjava.arrays%20label%3AType%2FBug&label=&color=30c955)](https://github.com/ballerina-platform/ballerina-library/issues?q=is%3Aopen%20label%3Amodule%2Fjava.arrays%20label%3AType%2FBug)");
}
23 changes: 17 additions & 6 deletions dashboard/utils.bal
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ function getDashboardRow(Module module, string level) returns string|error {
}
string repoLink = getRepoLink(moduleName);
string releaseBadge = getReleaseBadge(moduleName);
string buildStatusBadge = getBuildStatusBadge(moduleName, defaultBranch);
string trivyBadge = getTrivyBadge(moduleName, defaultBranch);
string buildStatusBadge = check getBuildStatusBadge(moduleName, defaultBranch);
string trivyBadge = check getTrivyBadge(moduleName, defaultBranch);
string codecovBadge = getCodecovBadge(moduleName, defaultBranch);
string bugsBadge = check getBugsBadge(moduleName);
string pullRequestsBadge = getPullRequestsBadge(moduleName);
Expand All @@ -56,15 +56,26 @@ function getReleaseBadge(string moduleName) returns string {
return string `[![GitHub Release](${badgeUrl})](${repoUrl})`;
}

function getBuildStatusBadge(string moduleName, string defaultBranch) returns string {
string badgeUrl = getGithubBadgeUrl(moduleName, WORKFLOW_MASTER_BUILD, defaultBranch, "");
string repoUrl = string `${BALLERINA_ORG_URL}/${moduleName}/actions/workflows/${WORKFLOW_MASTER_BUILD}`;
function getBuildStatusBadge(string moduleName, string defaultBranch) returns string|error {
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);
if openUrlResponse.statusCode == http:STATUS_NOT_FOUND {
workflowName = WORKFLOW_MASTER_CI_BUILD;
}
string repoUrl = string `${BALLERINA_ORG_URL}/${moduleName}/actions/workflows/${workflowName}`;
string badgeUrl = getGithubBadgeUrl(moduleName, workflowName, defaultBranch, "");
return string `[![Build](${badgeUrl})](${repoUrl})`;
}

function getTrivyBadge(string moduleName, string defaultBranch) returns string {
function getTrivyBadge(string moduleName, string defaultBranch) returns string|error {
string workflowFileUrl = string `/${BALLERINA_ORG_NAME}/${moduleName}/master/.github/workflows/${WORKFLOW_TRIVY}`;
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}`;
if openUrlResponse.statusCode == http:STATUS_NOT_FOUND {
badgeUrl = NABADGE;
}
return string `[![Trivy](${badgeUrl})](${repoUrl})`;
}

Expand Down
4 changes: 2 additions & 2 deletions release/src/commons/functions.bal
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public function publishModule(Module module, string accessToken, http:Client htt
public function checkCurrentPublishWorkflows() {
log:printInfo("Checking for already running workflows");
http:Request request = createRequest();
string apiPath = "/ballerina-standard-library/actions/workflows/build_stdlib_modules.yml/runs?per_page=2";
string apiPath = "/ballerina-library/actions/workflows/build_stdlib_modules.yml/runs?per_page=2";
var result = trap httpClient->get(apiPath, request);
if (result is error) {
log:printWarn("Error occurred while checking the current workflow status");
Expand All @@ -209,7 +209,7 @@ public function checkCurrentPublishWorkflows() {
}

function cancelWorkflow(string id) {
string path = "/ballerina-standard-library/actions/runs/" + id + "/cancel";
string path = "/ballerina-library/actions/runs/" + id + "/cancel";
http:Request request = createRequest();
var result = trap httpClient->post(path, request);
if (result is error) {
Expand Down
2 changes: 1 addition & 1 deletion resources/scripts/build_standard_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pathlib import Path
from urllib import request

MODULE_LIST = "https://raw.githubusercontent.com/ballerina-platform/ballerina-standard-library/main/release/resources/stdlib_modules.json"
MODULE_LIST = "https://raw.githubusercontent.com/ballerina-platform/ballerina-library/main/release/resources/stdlib_modules.json"

# Module Fields
FIELD_BRANCH = "branch"
Expand Down
Loading