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

Improve ci 6 sonar #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
58 changes: 58 additions & 0 deletions .github/workflows/sonarqube.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: SonarCloud

on: [pull_request]

jobs:
sonarcloud:
runs-on: ubuntu-20.04

steps:
- name: Checkout code including full history and submodules
uses: actions/checkout@v2
with:
submodules: true
fetch-depth: 0

- name: Install dependencies from APT repository
run: |
sudo apt-get update
sudo apt-get install gcovr libcunit1-dev wget unzip

- name: Install CMake
uses: lukka/get-cmake@latest

- name: Install Ninja
uses: seanmiddleditch/gha-setup-ninja@master

- name: Setup SonarScanner
uses: warchant/setup-sonar-scanner@v3
with:
version: 4.6.0.2311

- name: Install Build Wrapper
run: |
wget https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip -O /tmp/build-wrapper-linux-x86.zip
mkdir ~/opt/
unzip /tmp/build-wrapper-linux-x86.zip -d ~/opt/

- name: Collect test coverage data
run: |
tools/ci/run_ci.sh \
--all \
--sonarqube ~/opt/build-wrapper-linux-x86/build-wrapper-linux-x86-64

- name: Run SonarCloud Scan
run: |
sonar-scanner \
-Dsonar.branch.name="${GITHUB_REF_NAME}" \
-Dsonar.cfamily.build-wrapper-output=build-wakaama/sonar-cloud-build-wrapper-output \
-Dsonar.cfamily.cache.enabled=false \
-Dsonar.cfamily.gcov.reportsPath=build-wakaama \
-Dsonar.cfamily.threads=2 \
-Dsonar.exclusions="build-wakaama-*/**, .git/**" \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.login=${{ secrets.SONAR_TOKEN }} \
-Dsonar.organization=${{ github.repository_owner }} \
-Dsonar.projectKey="$(echo ${{ github.repository }} | tr / _)" \
-Dsonar.sourceEncoding=UTF-8 \
-Dsonar.sources=.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ core/cmake_install.cmake
lwm2mclient
lwm2mserver
tlvdecode

# SonarQube default work directory
.scannerwork
2 changes: 1 addition & 1 deletion about.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>About</title>
Expand Down
1 change: 0 additions & 1 deletion coap/er-coap-13/er-coap-13.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,6 @@ coap_parse_message(void *packet, uint8_t *data, uint16_t data_len)
PRINTF("Proxy-Uri NOT IMPLEMENTED [%.*s]\n", coap_pkt->proxy_uri_len, coap_pkt->proxy_uri);
coap_error_message = "This is a constrained server (Contiki)";
return PROXYING_NOT_SUPPORTED_5_05;
break;

case COAP_OPTION_OBSERVE:
coap_pkt->observe = coap_parse_int_option(current_option, option_length);
Expand Down
3 changes: 0 additions & 3 deletions core/liblwm2m.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,6 @@ int lwm2m_step(lwm2m_context_t * contextP,
contextP->state = STATE_BOOTSTRAP_REQUIRED;
}
goto next_step;
break;

case STATE_BOOTSTRAP_REQUIRED:
#ifdef LWM2M_BOOTSTRAP
Expand All @@ -425,7 +424,6 @@ int lwm2m_step(lwm2m_context_t * contextP,
case STATE_BS_FINISHED:
contextP->state = STATE_INITIAL;
goto next_step;
break;

case STATE_BS_FAILED:
return COAP_503_SERVICE_UNAVAILABLE;
Expand Down Expand Up @@ -457,7 +455,6 @@ int lwm2m_step(lwm2m_context_t * contextP,
// TODO avoid infinite loop by checking the bootstrap info is different
contextP->state = STATE_BOOTSTRAP_REQUIRED;
goto next_step;
break;

case STATE_REG_PENDING:
default:
Expand Down
5 changes: 1 addition & 4 deletions examples/client/object_access_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,10 @@ static uint8_t prv_set_tlv(lwm2m_data_t* dataP, acc_ctrl_oi_t* accCtrlOiP)
if (dataP->type == LWM2M_TYPE_MULTIPLE_RESOURCE) return COAP_404_NOT_FOUND;
lwm2m_data_encode_int(accCtrlOiP->objectId, dataP);
return COAP_205_CONTENT;
break;
case RES_M_OBJECT_INSTANCE_ID:
if (dataP->type == LWM2M_TYPE_MULTIPLE_RESOURCE) return COAP_404_NOT_FOUND;
lwm2m_data_encode_int(accCtrlOiP->objectInstId, dataP);
return COAP_205_CONTENT;
break;
case RES_O_ACL:
{
size_t count;
Expand Down Expand Up @@ -128,12 +126,11 @@ static uint8_t prv_set_tlv(lwm2m_data_t* dataP, acc_ctrl_oi_t* accCtrlOiP)
}
return COAP_205_CONTENT;
}
} break;
}
case RES_M_ACCESS_CONTROL_OWNER:
if (dataP->type == LWM2M_TYPE_MULTIPLE_RESOURCE) return COAP_404_NOT_FOUND;
lwm2m_data_encode_int(accCtrlOiP->accCtrlOwner, dataP);
return COAP_205_CONTENT;
break;
default:
return COAP_404_NOT_FOUND ;
}
Expand Down
3 changes: 0 additions & 3 deletions examples/client/object_connectivity_moni.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ static uint8_t prv_set_value(lwm2m_data_t * dataP,
}
return COAP_205_CONTENT ;
}
break;

case RES_O_ROUTER_IP_ADDRESS:
{
Expand Down Expand Up @@ -197,7 +196,6 @@ static uint8_t prv_set_value(lwm2m_data_t * dataP,
}
return COAP_205_CONTENT ;
}
break;

case RES_O_LINK_UTILIZATION:
if (dataP->type == LWM2M_TYPE_MULTIPLE_RESOURCE) return COAP_404_NOT_FOUND;
Expand Down Expand Up @@ -232,7 +230,6 @@ static uint8_t prv_set_value(lwm2m_data_t * dataP,
}
return COAP_205_CONTENT;
}
break;

case RES_O_CELL_ID:
if (dataP->type == LWM2M_TYPE_MULTIPLE_RESOURCE) return COAP_404_NOT_FOUND;
Expand Down
6 changes: 0 additions & 6 deletions examples/client/object_connectivity_stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,21 @@ static uint8_t prv_set_tlv(lwm2m_data_t * dataP, conn_s_data_t * connStDataP)
case RES_O_SMS_TX_COUNTER:
lwm2m_data_encode_int(connStDataP->smsTxCounter, dataP);
return COAP_205_CONTENT;
break;
case RES_O_SMS_RX_COUNTER:
lwm2m_data_encode_int(connStDataP->smsRxCounter, dataP);
return COAP_205_CONTENT;
break;
case RES_O_TX_DATA:
lwm2m_data_encode_int(connStDataP->txDataByte/1024, dataP);
return COAP_205_CONTENT;
break;
case RES_O_RX_DATA:
lwm2m_data_encode_int(connStDataP->rxDataByte/1024, dataP);
return COAP_205_CONTENT;
break;
case RES_O_MAX_MESSAGE_SIZE:
lwm2m_data_encode_int(connStDataP->maxMessageSize, dataP);
return COAP_205_CONTENT;
break;
case RES_O_AVERAGE_MESSAGE_SIZE:
lwm2m_data_encode_int(connStDataP->avrMessageSize, dataP);
return COAP_205_CONTENT;
break;
default:
return COAP_404_NOT_FOUND ;
}
Expand Down
12 changes: 6 additions & 6 deletions tests/block1tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ static void handle_12345(lwm2m_block_data_t ** blk1,
uint8_t *resultBuffer = NULL;

uint8_t st = coap_block1_handler(blk1, uri, buffer, 5, 5, 0, true, &resultBuffer, &bsize);
CU_ASSERT_EQUAL(st, COAP_231_CONTINUE);
CU_ASSERT_PTR_NULL(resultBuffer);
CU_ASSERT_EQUAL(st, COAP_231_CONTINUE)
CU_ASSERT_PTR_NULL(resultBuffer)
}

static void handle_67(lwm2m_block_data_t ** blk1,
Expand All @@ -40,10 +40,10 @@ static void handle_67(lwm2m_block_data_t ** blk1,
uint8_t *resultBuffer = NULL;

uint8_t st = coap_block1_handler(blk1, uri, buffer, 2, 5, 1, false, &resultBuffer, &bsize);
CU_ASSERT_EQUAL(st, NO_ERROR);
CU_ASSERT_PTR_NOT_NULL(resultBuffer);
CU_ASSERT_EQUAL(bsize, 7);
CU_ASSERT_NSTRING_EQUAL(resultBuffer, "1234567", 7);
CU_ASSERT_EQUAL(st, NO_ERROR)
CU_ASSERT_PTR_NOT_NULL(resultBuffer)
CU_ASSERT_EQUAL(bsize, 7)
CU_ASSERT_NSTRING_EQUAL(resultBuffer, "1234567", 7)
}


Expand Down
Loading