Skip to content

Commit

Permalink
feat: upgrade project dependencies, tests and GHA workflows (#11)
Browse files Browse the repository at this point in the history
* chore: update go.mod dependencies
* Update test cases
* Add installation of MongoDB Database Tools and migrate database in unit-test.yml
* Update PR template and fix checklist conventions
  • Loading branch information
Pradumnasaraf authored Sep 16, 2024
1 parent 7e9d73d commit 97dc7cf
Show file tree
Hide file tree
Showing 21 changed files with 1,666 additions and 636 deletions.
7 changes: 4 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MONGO_URI=mongodb://localhost:27017
MONGO_DB=opensource
MONGO_COLLECTION=contributors
PORT=8088
BASIC_AUTH_USERNAME=opensource
BASIC_AUTH_PASSWORD=greensquare
PORT=8080
BASIC_AUTH_USERNAME=user
BASIC_AUTH_PASSWORD=pass
GIN_MODE=release
10 changes: 5 additions & 5 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<!-- If your PR fixes an open issue, use `Closes #101` to link your PR with the issue. #101 stands for the issue number you are fixing -->

## 🛠️ Fixes Issue
## Fixes Issue

<!-- Remove this section if not applicable -->

<!-- Example: Closes #31 -->

## 👨‍💻 Changes proposed
## Changes proposed

<!-- List all the proposed changes in your PR -->

## ✔️ Check List (Check all the applicable boxes) <!-- Follow the below conventions to check the box -->
## Check List (Check all the applicable boxes) <!-- Follow the below conventions to check the box -->

<!-- Mark all the applicable boxes. To mark the box as done follow the following conventions -->
<!--
Expand All @@ -22,8 +22,8 @@
- [ ] This PR does not contain plagiarized content.
- [ ] The title of my pull request is a short description of the requested changes.

## 📄 Note to reviewers
## Note to reviewers

<!-- Add notes to reviewers if applicable -->

## 📷 Screenshots
## Screenshots
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: 1.19
go-version: 1.23
- name: Build
run: go build -v ./...
- name: Format
Expand All @@ -27,11 +27,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: 1.19
go-version: 1.23
cache: false
- name: GolangCI-Lint Check
uses: golangci/golangci-lint-action@v3
5 changes: 3 additions & 2 deletions .github/workflows/greetings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ on:

jobs:
welcome:
name: Welcome Message
if: github.actor != 'Pradumnasaraf'
name: Welcome Step
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- uses: EddieHubCommunity/gh-action-community/src/welcome@main
with:
github-token: ${{ secrets.github_token }}
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/publish-ghcr.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Publish Package - GHCR
name: Publish Image - GHCR

on:
workflow_dispatch:
release:
types: [published]

Expand All @@ -10,26 +11,26 @@ env:

jobs:
build-and-push-image:
name: Build and push Docker image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4


- name: Log in to the Container registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

Expand All @@ -40,7 +41,7 @@ jobs:
config: ${{ github.workspace }}/version.yaml

- name: Build and push Docker image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v6
with:
context: .
push: true
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ on:
- main

jobs:
changelog:
name: Create Release and Changelog
create-release:
name: Creating Tag and Release
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Checkout the repo
uses: actions/checkout@v4

- name: Changelog + Version update
- name: Creating Tag
id: changelog
uses: TriPSs/conventional-changelog-action@v3
uses: TriPSs/conventional-changelog-action@v5
with:
github-token: ${{ secrets.PA_TOKEN }}
output-file: "false"
skip-commit: "true"
create-summary: 'true'
version-file: './version.yaml'

- name: Create Release
Expand Down
35 changes: 28 additions & 7 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,38 @@ jobs:
name: Unit Tests
runs-on: ubuntu-latest
env:
MONGO_URI: ${{ secrets.TEST_MONGO_URI }}
MONGO_URI: mongodb://localhost:27017
MONGO_DB: opensource
MONGO_COLLECTION: contributors
PORT: 8000
GIN_MODE: release
BASIC_AUTH_USERNAME: user
BASIC_AUTH_PASSWORD: pass

steps:
- name: MongoDB
uses: supercharge/mongodb-github-action@v1
with:
mongodb-version: '7.0'
mongodb-port: 27017

- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup mongodb-tools
run: |
wget https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2204-x86_64-100.6.1.deb
sudo apt install ./mongodb-database-tools-*-100.6.1.deb
mongorestore --version
- name: Migrate database
run: mongoimport --db $MONGO_DB --collection $MONGO_COLLECTION --file ./tests/testdata.json --jsonArray --drop

- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: 1.19
- name: Test
go-version: 1.23

- name: Clear Test Cache
run: go clean -testcache

- name: Run Unit Tests
run: go test -v ./tests/...
46 changes: 0 additions & 46 deletions CHANGELOG.md

This file was deleted.

6 changes: 4 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package config

import (
"fmt"
"log"

"github.com/joho/godotenv"
)
Expand All @@ -10,7 +10,9 @@ func Config() {

err := godotenv.Load(".env")
if err != nil {
fmt.Println(".env file not found. Loading the system environment variables.")
log.Print("Using default environment variables")
} else {
log.Print("Environment variables loaded successfully from .env file")
}

}
66 changes: 35 additions & 31 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,51 +1,55 @@
module github.com/Pradumnasaraf/Contributors

go 1.20
go 1.23

require (
github.com/99designs/gqlgen v0.17.31
github.com/gin-gonic/gin v1.9.0
github.com/99designs/gqlgen v0.17.50
github.com/gin-gonic/gin v1.10.0
github.com/joho/godotenv v1.5.1
github.com/magiconair/properties v1.8.7
github.com/vektah/gqlparser/v2 v2.5.1
go.mongodb.org/mongo-driver v1.11.6
github.com/vektah/gqlparser/v2 v2.5.16
go.mongodb.org/mongo-driver v1.16.1
)

require (
github.com/agnivade/levenshtein v1.1.1 // indirect
github.com/bytedance/sonic v1.8.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/bytedance/sonic v1.12.2 // indirect
github.com/bytedance/sonic/loader v0.2.0 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.5 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.11.2 // indirect
github.com/goccy/go-json v0.10.0 // indirect
github.com/golang/snappy v0.0.1 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.1 // indirect
github.com/go-playground/validator/v10 v10.22.1 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/sosodev/duration v1.3.1 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.9 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.1 // indirect
github.com/xdg-go/stringprep v1.0.3 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
golang.org/x/arch v0.10.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.18.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 97dc7cf

Please sign in to comment.