Skip to content

Commit

Permalink
Arrange github workflows
Browse files Browse the repository at this point in the history
Signed-off-by: gatici <[email protected]>
  • Loading branch information
gatici committed Jan 17, 2024
1 parent 5c30540 commit c29e844
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
20 changes: 18 additions & 2 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ jobs:
with:
go-version-file: 'go.mod'

- name: Build and push Docker image
- name: Build Docker image
run: |
cd mongoapi/dbtestapp
make docker-build
make docker-push
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -69,6 +68,23 @@ jobs:
version: latest
args: -v --config ./.golangci.yml

lint-dbtestapp:
name: lint-dbtestapp
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- name: golangci-lint
uses: golangci/[email protected]
with:
version: latest
args: -v --config ../../.golangci.yml
working-directory: ./mongoapi/dbtestapp

license-check:
runs-on: ubuntu-latest
steps:
Expand Down
8 changes: 4 additions & 4 deletions mongoapi/dbtestapp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
# SPDX-License-Identifier: Apache-2.0
#

FROM golang:1.21.3-bookworm AS test
FROM golang:1.21.6-bookworm AS test

LABEL maintainer="ONF <[email protected]>"

RUN apt-get update && apt-get -y install vim

RUN cd $GOPATH/src && mkdir -p dbtestapp
COPY . $GOPATH/src/dbtestapp
RUN cd $GOPATH/src/dbtestapp && go install
WORKDIR $GOPATH/src/dbtestapp
COPY . .
RUN go install

FROM alpine:3.16 AS dbtestapp
RUN apk update && apk add -U gcompat vim strace net-tools curl netcat-openbsd bind-tools bash
Expand Down
8 changes: 4 additions & 4 deletions mongoapi/dbtestapp/student.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ func StudentRecordTest(c *gin.Context) {
if err == nil {
log.Printf("Retrieved student %v ", student)
} else {
log.Printf("Failed to retrieve student %v. Error - ", student, err)
log.Printf("Failed to retrieve student %v. Error - %+v", student, err)
}

insertStudentInDB(collName, "John Smith", 25)

// test document fetch from student that doesn't exist.
qName := "Nerf Doodle"
student, err = getStudentFromDB(collName, qName)
_, err = getStudentFromDB(collName, qName)
if err == nil {
log.Printf("Retrieved student %v ", qName)
} else {
log.Printf("Failed to retrieve student %v. Error - ", qName, err)
log.Printf("Failed to retrieve student %v. Error - %+v ", qName, err)
}
c.JSON(http.StatusOK, gin.H{})
}
Expand All @@ -65,7 +65,7 @@ func insertStudentInDB(collName string, name string, age int) {
filter := bson.M{}
_, err := mongoHndl.PutOneCustomDataStructure(collName, filter, student)
if err != nil {
log.Printf("Inserting student %v failed with error ", student, err)
log.Printf("Inserting student %v failed with error %+v ", student, err)
return
}
log.Printf("Inserting student %v successful ", student)
Expand Down

0 comments on commit c29e844

Please sign in to comment.