Skip to content

Commit

Permalink
Merge pull request #92 from breez/golang-ci
Browse files Browse the repository at this point in the history
Golang ci
  • Loading branch information
JssDWt authored Nov 10, 2023
2 parents 51d1432 + 5c2f2b7 commit ea782b6
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 3 deletions.
45 changes: 44 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
repository: breez/breez-sdk
ref: ${{ needs.setup.outputs.sdk-ref }}
package-version: ${{ needs.setup.outputs.package-version }}
packages-to-publish: '["csharp", "flutter"]'
packages-to-publish: '["csharp", "flutter", "golang"]'
use-dummy-binaries: true

check-rust:
Expand Down Expand Up @@ -157,6 +157,49 @@ jobs:
working-directory: snippets/csharp
run: dotnet build

check-golang:
needs:
- setup
- build-packages
name: Check Go snippets
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3

- uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Download archived package
uses: actions/download-artifact@v3
with:
name: breez-sdk-go-${{ needs.setup.outputs.package-version }}
path: snippets/go/packages/breez-sdk-go

- name: Format the Go snippets
working-directory: snippets/go
run: go fmt

- name: Test formatted correctly
working-directory: snippets/go
run: |
status=$(git status --porcelain)
if [[ -n "$status" ]]; then
echo "Git status has changes"
echo "$status"
git diff
exit 1
else
echo "No changes in git status"
fi
- name: Build the Go snippets
working-directory: snippets/go
run: |
go get
go build .
build:
name: Build mdbook
runs-on: ubuntu-latest
Expand Down
5 changes: 4 additions & 1 deletion snippets/go/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ go.work
# Ignore Go binaries
**/*
!**/*.go
!**/
!**/*.md
!**/

breez-sdk-go
6 changes: 6 additions & 0 deletions snippets/go/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Steps to compile the snippets locally
1. Build a golang package
- By running the publish-all-platforms CI in the breez-sdk repository (use dummy binaries)
- or by cloning https://github.com/breez/breez-sdk-go
2. Place the files in the folder `snippets/go/packages/breez-sdk-go`
3. Happy coding
4 changes: 3 additions & 1 deletion snippets/go/getting_started.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func (BreezListener) OnEvent(e breez_sdk.BreezEvent) {
log.Printf("received event %#v", e)
}

func GettingStarted() {
func GettingStarted() *breez_sdk.BlockingBreezServices {
// Create the default config
seed, err := breez_sdk.MnemonicToSeed("<mnemonic words>")
if err != nil {
Expand All @@ -38,6 +38,8 @@ func GettingStarted() {
if err != nil {
log.Fatalf("Connect failed: %#v", err)
}

return sdk
}

// ANCHOR_END: init-sdk
Expand Down
1 change: 1 addition & 0 deletions snippets/go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ module main
go 1.19

require github.com/breez/breez-sdk-go v0.2.7
replace github.com/breez/breez-sdk-go => ./packages/breez-sdk-go

0 comments on commit ea782b6

Please sign in to comment.