Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/c-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on: # yamllint disable-line rule:truthy
jobs:
coverage:
name: C/C++ CMake CI Coverage
runs-on: ubuntu-24.04
runs-on: ubuntu-26.04

steps:
- name: Checkout repository
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on: # yamllint disable-line rule:truthy
jobs:
lint:
name: clang-format style check
runs-on: ubuntu-24.04
runs-on: ubuntu-26.04

steps:
- name: Checkout repository
Expand All @@ -21,12 +21,15 @@ jobs:
- name: Install dependencies
# yamllint disable rule:line-length
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy main"
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key \
| sudo gpg --dearmor -o /etc/apt/keyrings/llvm-snapshot.gpg
echo "deb [signed-by=/etc/apt/keyrings/llvm-snapshot.gpg] http://apt.llvm.org/resolute/ llvm-toolchain-resolute-22 main" \
| sudo tee /etc/apt/sources.list.d/llvm.list && \
sudo apt-get -y update
sudo apt-get -y install --no-install-recommends --no-install-suggests clang-format-19
sudo update-alternatives --install /usr/bin/clang-format clang-format $(which clang-format-19) 100
sudo update-alternatives --set clang-format $(update-alternatives --list clang-format | grep clang-format-19)
sudo apt-get -y install --no-install-recommends --no-install-suggests clang-format-22
sudo update-alternatives --install /usr/bin/clang-format clang-format $(which clang-format-22) 100
sudo update-alternatives --set clang-format $(update-alternatives --list clang-format | grep clang-format-22)
# yamllint enable rule:line-length

- name: Check Tools
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cppcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on: # yamllint disable-line rule:truthy
jobs:
lint:
name: CppCheck Lint
runs-on: ubuntu-24.04
runs-on: ubuntu-26.04

steps:
- name: Checkout repository
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

build:
name: "Build Docker images"
runs-on: ubuntu-24.04
runs-on: ubuntu-26.04
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6

Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:

lint:
name: "Run in docker: LINT"
runs-on: ubuntu-24.04
runs-on: ubuntu-26.04
needs: build
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
Expand All @@ -98,7 +98,7 @@ jobs:

test:
name: "Run in docker: TEST"
runs-on: ubuntu-24.04
runs-on: ubuntu-26.04
needs: build
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
Expand All @@ -124,7 +124,7 @@ jobs:
# yamllint disable rule:line-length
# security:
# name: "Snyk Container"
# runs-on: ubuntu-24.04
# runs-on: ubuntu-26.04
# needs: build
# permissions:
# actions: read
Expand Down Expand Up @@ -173,7 +173,7 @@ jobs:

scan:
name: "Trivy"
runs-on: ubuntu-24.04
runs-on: ubuntu-26.04
needs: build
permissions:
actions: read
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gitleaks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on: # yamllint disable-line rule:truthy
jobs:
scan:
name: gitleaks
runs-on: ubuntu-24.04
runs-on: ubuntu-26.04
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/make-coverage-html.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on: # yamllint disable-line rule:truthy
jobs:
make-coverage-html:
name: "Run make coverage/html and verify coverage HTML"
runs-on: ubuntu-24.04
runs-on: ubuntu-26.04
steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/markdown-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ permissions:
jobs:
markdownlint:
name: Markdown Lint
runs-on: ubuntu-24.04
runs-on: ubuntu-26.04

strategy:
matrix:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on: # yamllint disable-line rule:truthy
jobs:
build:
name: SonarCloud build and run sonar-scanner
runs-on: ubuntu-24.04
runs-on: ubuntu-26.04
env:
# Directory where build-wrapper output will be placed
BUILD_WRAPPER_OUT_DIR: build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/yamllint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on: # yamllint disable-line rule:truthy
jobs:
lint:
name: YAML lint
runs-on: ubuntu-24.04
runs-on: ubuntu-26.04
steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
Expand Down
25 changes: 17 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BASE_IMAGE_VERSION=ubuntu:noble-20260509.1
ARG BASE_IMAGE_VERSION=ubuntu:26.04
FROM ${BASE_IMAGE_VERSION} AS init

ENV WORKDIR=/app
Expand Down Expand Up @@ -34,7 +34,7 @@ RUN apt-get -y update && \
ca-certificates curl git ninja-build unzip zip && \
rm -rf /var/lib/apt/lists/* && \
mkdir /opt/vcpkg && \
git clone --branch ${VCPKG_VERSION} https://github.com/microsoft/vcpkg "${VCPKG_ROOT}" && \
git clone --branch "${VCPKG_VERSION}" https://github.com/microsoft/vcpkg "${VCPKG_ROOT}" && \
/opt/vcpkg/bootstrap-vcpkg.sh && \
ln -s /opt/vcpkg/vcpkg /usr/local/bin/vcpkg && \
rm -rf /var/lib/apt/lists/* && \
Expand Down Expand Up @@ -69,12 +69,15 @@ FROM builder AS lint
RUN apt-get update && \
apt-get -y install --no-install-recommends --no-install-suggests gnupg software-properties-common && \
rm -rf /var/lib/apt/lists/*
ADD https://apt.llvm.org/llvm-snapshot.gpg.key llvm-snapshot.gpg.key
RUN apt-key add llvm-snapshot.gpg.key && \
apt-add-repository -y "deb https://apt.llvm.org/plucky/ llvm-toolchain-plucky-20 main" && \

RUN mkdir -p /etc/apt/keyrings && \
curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key \
| gpg --dearmor -o /etc/apt/keyrings/llvm-snapshot.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/llvm-snapshot.gpg] http://apt.llvm.org/resolute/ llvm-toolchain-resolute-22 main" \
| tee /etc/apt/sources.list.d/llvm.list && \
apt-get -y update && \
apt-get -y install --no-install-recommends --no-install-suggests clang-format-19 && \
update-alternatives --install /usr/bin/clang-format clang-format $(which clang-format-19) 100 && \
apt-get -y install --no-install-recommends --no-install-suggests clang-format-22 && \
update-alternatives --install /usr/bin/clang-format clang-format $(which clang-format-22) 100 && \
rm -rf /var/lib/apt/lists/*

ADD https://deb.nodesource.com/setup_22.x nodesource_setup.sh
Expand All @@ -83,10 +86,16 @@ RUN bash nodesource_setup.sh && \
npm install -g --ignore-scripts markdownlint-cli@0.47.0 && \
apt-get -y install --no-install-recommends --no-install-suggests python3-minimal python3-pip && \
rm /usr/lib/python3.*/EXTERNALLY-MANAGED && \
pip install --no-cache-dir yamllint && \
apt-get -y install --no-install-recommends --no-install-suggests yamllint && \
apt-get -y install --no-install-recommends --no-install-suggests cppcheck && \
rm -rf /var/lib/apt/lists/*

# Tooling test
RUN clang-format --version && \
markdownlint --version && \
yamllint --version && \
cppcheck --version

# Code source
COPY ./src ${WORKDIR}/src
COPY ./vcpkg.json ${WORKDIR}/vcpkg.json
Expand Down
3 changes: 3 additions & 0 deletions src/lib/exercises/src/hackerrank/warmup/compare_triplets.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ int *HACKERRANK_WARMUP_compareTriplets(int a_count, const int *a, int b_count,

*result_count = 2;
int *awards = malloc(sizeof(int) * *result_count);
if (awards == NULL) {
return NULL;
}

awards[0] = 0;
awards[1] = 0;
Expand Down
7 changes: 7 additions & 0 deletions src/lib/exercises/src/hackerrank/warmup/mini_max_sum.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,20 @@ char *HACKERRANK_WARMUP_miniMaxSumCalculate(int arr_count, const int *arr) {

const int BUFFER_MAX_SIZE = 100;
char *buffer = malloc(BUFFER_MAX_SIZE * sizeof(char));
if (buffer == NULL) {
return NULL;
}

snprintf(buffer, BUFFER_MAX_SIZE, "%lld %lld", tsum - tmax, tsum - tmin);
return buffer;
}

void HACKERRANK_WARMUP_miniMaxSum(int arr_count, const int *arr) {
char *result = HACKERRANK_WARMUP_miniMaxSumCalculate(arr_count, arr);
if (result == NULL) {
return;
}

printf("%s\n", result);
free(result);
}
13 changes: 13 additions & 0 deletions src/lib/exercises/src/hackerrank/warmup/plus_minus.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const int BUFFER_MAX_SIZE = 10;

char *format_result(double number) {
char *buffer = malloc(BUFFER_MAX_SIZE * sizeof(char));
if (buffer == NULL) {
return NULL;
}

snprintf(buffer, BUFFER_MAX_SIZE, "%0.6lf", number);
return buffer;
Expand Down Expand Up @@ -45,9 +48,16 @@ char **HACKERRANK_WARMUP_plusMinusCalculate(int arr_count, const int *arr) {

int n = 3; // Número de strings (puede ser arbitrario)
char **answer = malloc(n * sizeof(char *)); // Array de punteros
if (answer == NULL) {
return NULL;
}

for (i = 0; i < n; i++) {
char *formatted = format_result(results[i]);
if (formatted == NULL) {
HACKERRANK_WARMUP_freePlusMinus(answer, i);
return NULL;
}
answer[i] = formatted;
}

Expand All @@ -63,6 +73,9 @@ void HACKERRANK_WARMUP_freePlusMinus(char **plusMinusAnswer, int n) {

void HACKERRANK_WARMUP_plusMinus(int arr_count, const int *arr) {
char **output = HACKERRANK_WARMUP_plusMinusCalculate(arr_count, arr);
if (output == NULL) {
return;
}

for (int i = 0; i < HACKERRANK_WARMUP_PLUSMINUS_LIMIT_ANSWERS; i++) {
printf("%s", output[i]);
Expand Down
10 changes: 10 additions & 0 deletions src/lib/exercises/src/hackerrank/warmup/staircase.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@
char **HACKERRANK_WARMUP_staircaseCalculate(int n) {

char **answer = malloc(n * sizeof(char *)); // Array of char pointers
if (answer == NULL) {
return NULL;
}

for (int i = 0; i < n; i++) {
char *line = malloc((n + 1) * sizeof(char)); // Array of char values
if (line == NULL) {
HACKERRANK_WARMUP_freeStaircase(answer, i);
return NULL;
}

for (int j = 0; j < n; j++) {
if (j < n - i - 1) {
Expand All @@ -38,6 +45,9 @@ void HACKERRANK_WARMUP_freeStaircase(char **staircase, int n) {

void HACKERRANK_WARMUP_staircase(int n) {
char **output = HACKERRANK_WARMUP_staircaseCalculate(n);
if (output == NULL) {
return;
}

for (int i = 0; i < n; i++) {
printf("%s\n", output[i]);
Expand Down
4 changes: 4 additions & 0 deletions src/lib/exercises/src/hackerrank/warmup/time_conversion.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ char *HACKERRANK_WARMUP_timeConversion(const char *s) {
char *conversion =
malloc((HACKERRANK_WARMUP_SHORT_TIME_FORMAT_SIZE + 1) * sizeof(char));

if (conversion == NULL) {
return NULL;
}

for (int i = 0; i < HACKERRANK_WARMUP_SHORT_TIME_FORMAT_SIZE; i++) {
conversion[i] = s[i];
}
Expand Down
Loading