From b72bb4df71fb9eb66062fc962da5f2c35bebe4ce Mon Sep 17 00:00:00 2001 From: Joshua Raphael Date: Wed, 22 Jan 2025 22:57:11 -0700 Subject: [PATCH] add notes api call and artifact upload to CI --- .github/go.mod | 5 +++++ .github/go.sum | 2 ++ .github/main.go | 34 ++++++++++++++++++++++++++++++++++ .github/workflows/test.yaml | 13 +++++++++++++ Makefile | 5 ++++- 5 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 .github/go.mod create mode 100644 .github/go.sum create mode 100644 .github/main.go diff --git a/.github/go.mod b/.github/go.mod new file mode 100644 index 0000000..44c1fb9 --- /dev/null +++ b/.github/go.mod @@ -0,0 +1,5 @@ +module ra-code-notes + +go 1.23.0 + +require github.com/joshraphael/go-retroachievements v1.0.0 \ No newline at end of file diff --git a/.github/go.sum b/.github/go.sum new file mode 100644 index 0000000..80805c0 --- /dev/null +++ b/.github/go.sum @@ -0,0 +1,2 @@ +github.com/joshraphael/go-retroachievements v1.0.0 h1:Hu1bitG8r9O8AZWx7BfGOyVo9Sga3phxQBq0b8Q/3vQ= +github.com/joshraphael/go-retroachievements v1.0.0/go.mod h1:C+9vQbOqyRJmnFt8XIJ5gwRot+AZS/acnaESp45jtCc= diff --git a/.github/main.go b/.github/main.go new file mode 100644 index 0000000..cf1f48b --- /dev/null +++ b/.github/main.go @@ -0,0 +1,34 @@ +package main + +import ( + "encoding/json" + "fmt" + "os" + + "github.com/joshraphael/go-retroachievements" + "github.com/joshraphael/go-retroachievements/models" +) + +func main() { + client := retroachievements.New(retroachievements.ClientConfig{ + Host: retroachievements.RetroAchievementHost, + UserAgent: "go-retroachievements/v1.0.0", + }) + notes, err := client.GetCodeNotes(models.GetCodeNotesParameters{ + GameID: 4111, + }) + if err != nil { + os.Exit(1) + fmt.Println("error getting code notes") + return + } + + jsonNotes, err := json.Marshal(notes.CodeNotes) + if err != nil { + os.Exit(1) + fmt.Println("error converting code notes to json") + return + } + + fmt.Println(string(jsonNotes)) +} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 31d726f..b3a82ff 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -24,6 +24,11 @@ jobs: steps: - name: Checkout repo uses: actions/checkout@v4 + + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version: '^1.23.0' - name: Set ENV vars for github run: echo "RATOOLS_DIR=~/Installs/RATools-${{env.RATOOLS_VERSION}}" >> $GITHUB_ENV # same as Makefile @@ -46,9 +51,17 @@ jobs: - name: Get .NET SDK 6.0.428 run: bash .github/dotnet-sdk.sh + - name: Get Code Notes + run: make notes + - name: Compile Code run: make compile + - uses: actions/upload-artifact@v4 + with: + name: notes-json + path: ${{env.RALIBRETRO_DIR}}/RACache/Data/4111-Notes.json + - uses: actions/upload-artifact@v4 with: name: user-text diff --git a/Makefile b/Makefile index 442b9af..d18e247 100644 --- a/Makefile +++ b/Makefile @@ -6,4 +6,7 @@ export GAME_ID = 4111 compile: touch ${RALIBRETRO_DIR}/RACache/Data/${GAME_ID}.json - wine ${RATOOLS_DIR}/rascript-cli.exe -i ${GAME_ID}.rascript -o ${RALIBRETRO_DIR} \ No newline at end of file + wine ${RATOOLS_DIR}/rascript-cli.exe -i ${GAME_ID}.rascript -o ${RALIBRETRO_DIR} + +notes: + cd .github/ && go get -t ./... && go run main.go > ${RALIBRETRO_DIR}/RACache/Data/4111-Notes.json \ No newline at end of file