From da9767a1ef3176f7304b76a0444c11c5cecd4b67 Mon Sep 17 00:00:00 2001 From: Torgrim <sir_alexiner@hotmail.com> Date: Thu, 18 Apr 2024 02:26:07 +0200 Subject: [PATCH] Updated Repo with Pipeline and Coverage Badge in readme.md --- gitlab-ci.yml => .gitlab-ci.yml | 3 ++- Go/.env.example | 2 +- Go/Dockerfile-test | 4 ++-- Go/docker-compose.yml | 2 +- readme.md | 19 ++++++++++++------- 5 files changed, 18 insertions(+), 12 deletions(-) rename gitlab-ci.yml => .gitlab-ci.yml (93%) diff --git a/gitlab-ci.yml b/.gitlab-ci.yml similarity index 93% rename from gitlab-ci.yml rename to .gitlab-ci.yml index 0f0cd64..859265f 100644 --- a/gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,7 +24,7 @@ Test: stage: Test before_script: - cd ./Go/ - - apk add --no-cache curl bash go + - apk add --no-cache curl bash - curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | bash > /dev/null 2>&1 script: - docker compose up globeboard-test --exit-code-from globeboard-test @@ -32,6 +32,7 @@ Test: after_script: - cd ./Go/ - docker compose down globeboard-test + coverage: '/coverage:\s+(\d+\.\d+)%\s+of statements/' artifacts: when: always paths: diff --git a/Go/.env.example b/Go/.env.example index 3718be9..37a44f9 100644 --- a/Go/.env.example +++ b/Go/.env.example @@ -1,3 +1,3 @@ PORT=8080 TOKEN=your_api_token -SECRETS=path_to_Firebase_credentials_file \ No newline at end of file +FIREBASE_CREDENTIALS_FILE=path_to_Firebase_credentials_file \ No newline at end of file diff --git a/Go/Dockerfile-test b/Go/Dockerfile-test index 7dfc3ac..aeed904 100644 --- a/Go/Dockerfile-test +++ b/Go/Dockerfile-test @@ -13,7 +13,7 @@ COPY go.mod go.sum ./ COPY ../ ./ # Build -RUN CGO_ENABLED=0 GOOS=linux go test -c -installsuffix cgo -o test ./cmd/globeboard +RUN CGO_ENABLED=0 GOOS=linux go test -cover -coverpkg=./... -c -installsuffix cgo -o test ./cmd/globeboard # Use a minimal alpine image for the final build stage. FROM golang:1.22-alpine @@ -30,4 +30,4 @@ WORKDIR /root/ COPY --from=builder /app/test . # Run -CMD ./test -test.v | go-junit-report > report.xml && ./test -test.v \ No newline at end of file +CMD ./test -test.v | go-junit-report > report.xml && ./test -test.v diff --git a/Go/docker-compose.yml b/Go/docker-compose.yml index 4cd856d..c60cce2 100644 --- a/Go/docker-compose.yml +++ b/Go/docker-compose.yml @@ -31,4 +31,4 @@ services: secrets: Firebase: - file: ${SECRETS} \ No newline at end of file + file: ${FIREBASE_CREDENTIALS_FILE} \ No newline at end of file diff --git a/readme.md b/readme.md index bdc0fb3..c0480c0 100644 --- a/readme.md +++ b/readme.md @@ -1,8 +1,13 @@ -# GlobeBoard Go REST API [](https://opensource.org/license/mit/) +# GlobeBoard Go REST API  ## Introduction + +[](https://git.gvk.idi.ntnu.no/Nintendo_Alex/globeboard_cicd/-/commits/main) +[](https://git.gvk.idi.ntnu.no/Nintendo_Alex/globeboard_cicd/-/commits/main) +[](https://opensource.org/license/mit/) + GlobeBoard Go REST API is a webapplication REST API service designed to provide GeoLocational Information. ## Author @@ -21,9 +26,9 @@ This code was developed by: - **Endpoint**: `/library/v1/?languages={:two_letter_language_code+}{&search={:string}}{&page={:number}}` - **Method**: GET - **Description**: This endpoint provides access to the Gutendex library, allowing users to retrieve various information about books and their metadata. Users can specify parameters to filter the results: - - `languages`: Optional parameter to filter books by language. Users can specify one or more two-letter language codes. - - `search`: Optional parameter to search for books based on a provided string. - - `page`: Optional parameter to paginate through the results, specifying the page number. + - `languages`: Optional parameter to filter books by language. Users can specify one or more two-letter language codes. + - `search`: Optional parameter to search for books based on a provided string. + - `page`: Optional parameter to paginate through the results, specifying the page number. Example: ``` @@ -42,7 +47,7 @@ This endpoint enables users to query the Gutendex library and retrieve relevant - **Method**: GET - **Description**: This endpoint allows users to retrieve the count of books, authors, and pages available in the Gutendex library for the specified languages. - **Parameters**: - - `languages`: (Required) Specifies the languages for which book count is requested. It accepts one or more two-letter language codes. + - `languages`: (Required) Specifies the languages for which book count is requested. It accepts one or more two-letter language codes. - **Example**: ``` /librarystats/v1/bookcount/?languages=en,fr @@ -52,8 +57,8 @@ This endpoint enables users to query the Gutendex library and retrieve relevant - **Endpoint**: `/librarystats/v1/readership/{:two_letter_language_code}/{?limit={:number}}` - **Description**: This endpoint retrieves statistics related to readership, such as the number of possible readers for the Gutendex library from countries for a specified language. - **Parameters**: - - `language_code`: (Required) Specifies the language for which readership statistics are requested. - - `limit`: (Optional) Limits the number of results returned. Defaults to all readership statistics if not provided. + - `language_code`: (Required) Specifies the language for which readership statistics are requested. + - `limit`: (Optional) Limits the number of results returned. Defaults to all readership statistics if not provided. - **Example**: ``` /librarystats/v1/readership/en/?limit=10 -- GitLab