Skip to content

Commit

Permalink
Fix the examples and improve the README.md
Browse files Browse the repository at this point in the history
- Added information about searching for games to the main README.md
- Debugged the PowerShell example script
- Added code coverage and code quality badges to README.md
- Updated the GitHub Actions workflow to generate the code coverage report
- Updated the Makefile to include a target for generating the coverage report
  • Loading branch information
habedi committed Jan 17, 2025
1 parent 767e656 commit ef44a2a
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 21 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ jobs:
make format
continue-on-error: false

- name: Run Tests
- name: Run Tests and Generate Coverage Report
run: |
make test
make codecov
continue-on-error: false

# Upload the coverage report to Codecov
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,4 @@ catalogue.csv
gogg/
games/
gogg_catalogue*
coverage.txt
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ help:
@echo " snap Build the Snap package"
@echo " install-deps Install development dependencies on Debian-based systems"
@echo " lint Lint Go files to check for potential errors"
@echo " codecov Create test coverage report for Codecov"
@echo " help Show this help message"

# Building the project
Expand Down Expand Up @@ -98,3 +99,8 @@ install-deps:
lint:
@echo "Linting Go files..."
golangci-lint run ./...

# Create Test Coverage Report for Codecov
codecov: format
@echo "Uploading coverage report to Codecov..."
go test -coverprofile=coverage.txt ./...
34 changes: 25 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,33 @@
<a href="https://github.com/habedi/gogg/actions/workflows/tests.yml">
<img src="https://github.com/habedi/gogg/actions/workflows/tests.yml/badge.svg" alt="Tests">
</a>
<a href="https://github.com/habedi/gogg/actions/workflows/build_linux.yml">
<img src="https://github.com/habedi/gogg/actions/workflows/build_linux.yml/badge.svg" alt="Linux Build">
</a>
<a href="https://github.com/habedi/gogg/actions/workflows/build_windows.yml">
<img src="https://github.com/habedi/gogg/actions/workflows/build_windows.yml/badge.svg" alt="Windows Build">
</a>
<a href="https://github.com/habedi/gogg/actions/workflows/build_macos.yml">
<img src="https://github.com/habedi/gogg/actions/workflows/build_macos.yml/badge.svg" alt="MacOS Build">
</a>
<br>
<a href="https://goreportcard.com/report/github.com/habedi/gogg">
<img src="https://goreportcard.com/badge/github.com/habedi/gogg" alt="Go Report Card">
</a>
<a href="https://pkg.go.dev/github.com/habedi/gogg">
<img src="https://pkg.go.dev/badge/github.com/habedi/gogg.svg" alt="Go Reference">
</a>
<a href="https://github.com/habedi/gogg/releases/latest">
<img src="https://img.shields.io/github/release/habedi/gogg.svg?style=flat-square" alt="Release">
<a href="https://codecov.io/gh/habedi/gogg">
<img src="https://codecov.io/gh/habedi/gogg/graph/badge.svg?token=1RUL13T0VE" alt="Code Coverage">
</a>
<br>
<a href="https://github.com/habedi/gogg/actions/workflows/build_linux.yml">
<img src="https://github.com/habedi/gogg/actions/workflows/build_linux.yml/badge.svg" alt="Linux Build">
<a href="https://www.codefactor.io/repository/github/habedi/gogg">
<img src="https://www.codefactor.io/repository/github/habedi/gogg/badge" alt="CodeFactor">
</a>
<a href="https://github.com/habedi/gogg/actions/workflows/build_windows.yml">
<img src="https://github.com/habedi/gogg/actions/workflows/build_windows.yml/badge.svg" alt="Windows Build">
<a href="https://github.com/habedi/gogg/releases/latest">
<img src="https://img.shields.io/github/release/habedi/gogg.svg?style=flat-square" alt="Release">
</a>
<a href="https://github.com/habedi/gogg/actions/workflows/build_macos.yml">
<img src="https://github.com/habedi/gogg/actions/workflows/build_macos.yml/badge.svg" alt="MacOS Build">
<a href="https://github.com/habedi/gogg/releases">
<img src="https://img.shields.io/github/downloads/habedi/gogg/total.svg" alt="Total Downloads">
</a>
</p>

Expand Down Expand Up @@ -94,6 +103,13 @@ gogg auth
gogg catalogue refresh
```

#### Searching for Games

```bash
# Will search for games with the the term `witcher` in their title
gogg catalogue search --term witcher
```

#### Downloading a Game

```bash
Expand Down
22 changes: 11 additions & 11 deletions docs/examples/download_all_games.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Write-Host "${GREEN}The code in this script downloads all games owned by the use
Write-Host "${GREEN}============================================================================================${NC}"

$DEBUG_MODE = 1 # Debug mode enabled
$GOGG = (Get-Command "bin\gogg" -ErrorAction SilentlyContinue) -or (Get-Command "gogg" -ErrorAction SilentlyContinue)
$GOGG = ".\gogg" # Path to Gogg's executable file (for example, ".\bin\gogg")

$LANG = "en" # Language English
$PLATFORM = "windows" # Platform Windows
Expand All @@ -22,19 +22,18 @@ $RESUME_DOWNLOAD = 1 # Resume download
$NUM_THREADS = 4 # Number of worker threads for downloading

# Function to clean up the CSV file
function Cleanup {
if ($latest_csv) {
function Cleanup
{
if ($latest_csv)
{
Remove-Item -Force $latest_csv
if ($?) {
if ($?)
{
Write-Host "${RED}Cleanup: removed $latest_csv${NC}"
}
}
}

# Trap Ctrl+C and call Cleanup
$global:latest_csv = $null
Register-ObjectEvent -InputObject $Host -EventName "CancelKeyPress" -Action { Cleanup }

# Update game catalogue and export it to a CSV file
& $GOGG catalogue refresh
& $GOGG catalogue export --format csv --dir ./
Expand All @@ -43,23 +42,24 @@ Register-ObjectEvent -InputObject $Host -EventName "CancelKeyPress" -Action { Cl
$latest_csv = Get-ChildItem -Path . -Filter "gogg_catalogue_*.csv" | Sort-Object LastWriteTime -Descending | Select-Object -First 1

# Check if the catalogue file exists
if (-not $latest_csv) {
if (-not $latest_csv)
{
Write-Host "${RED}No CSV file found.${NC}"
exit 1
}

Write-Host "${GREEN}Using catalogue file: $($latest_csv.Name)${NC}"
Write-Host "${GREEN}Using catalogue file: $( $latest_csv.Name )${NC}"

# Download each game listed in catalogue file, skipping the first line
Get-Content $latest_csv.FullName | Select-Object -Skip 1 | ForEach-Object {
$fields = $_ -split ","
$game_id = $fields[0]
$game_title = $fields[1]
Write-Host "${YELLOW}Game ID: $game_id, Title: $game_title${NC}"
$env:DEBUG_GOGG = $DEBUG_MODE
& $GOGG download --id $game_id --dir "./games" --platform $PLATFORM --lang $LANG `
--dlcs $INCLUDE_DLC --extras $INCLUDE_EXTRA_CONTENT --resume $RESUME_DOWNLOAD --threads $NUM_THREADS
Start-Sleep -Seconds 1
# Remove the break to download all games
}

# Clean up
Expand Down

0 comments on commit ef44a2a

Please sign in to comment.