From 2c8087380cccdd28a0e3252c81a4d539cbe98b13 Mon Sep 17 00:00:00 2001 From: Matt Johnstone Date: Tue, 1 Oct 2024 22:18:44 +0200 Subject: [PATCH 1/3] added format workflow --- .github/workflows/fmt.yaml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/fmt.yaml diff --git a/.github/workflows/fmt.yaml b/.github/workflows/fmt.yaml new file mode 100644 index 0000000..3d9fe8d --- /dev/null +++ b/.github/workflows/fmt.yaml @@ -0,0 +1,26 @@ +name: Go Format Check + +on: + pull_request: + +jobs: + gofmt-check: + name: Check Go Formatting + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.22" + + - name: Check gofmt + run: | + unformatted=$(gofmt -l .) + if [ -n "$unformatted" ]; then + echo "The following files are not formatted correctly:" + echo "$unformatted" + exit 1 + fi \ No newline at end of file From fe98f89df133ed04cfdc15312abfa90cc847057a Mon Sep 17 00:00:00 2001 From: Matt Johnstone Date: Tue, 1 Oct 2024 22:25:48 +0200 Subject: [PATCH 2/3] added go-test workflow --- .github/workflows/go-test.yaml | 35 ++++++++++++++++++++++ .github/workflows/{fmt.yaml => gofmt.yaml} | 0 2 files changed, 35 insertions(+) create mode 100644 .github/workflows/go-test.yaml rename .github/workflows/{fmt.yaml => gofmt.yaml} (100%) diff --git a/.github/workflows/go-test.yaml b/.github/workflows/go-test.yaml new file mode 100644 index 0000000..97c775b --- /dev/null +++ b/.github/workflows/go-test.yaml @@ -0,0 +1,35 @@ +name: Go Tests + +on: + pull_request: + +jobs: + test: + name: Run Go Tests + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.22" + + - name: Install dependencies + run: go mod download + + - name: Test rpc package + run: go test -v ./pkg/rpc + + - name: Test solana_exporter + run: go test -v ./cmd/solana_exporter + + - name: Run all tests with coverage + run: go test -v -coverprofile=coverage.out ./... + + - name: Upload coverage report + uses: actions/upload-artifact@v3 + with: + name: coverage-report + path: coverage.out \ No newline at end of file diff --git a/.github/workflows/fmt.yaml b/.github/workflows/gofmt.yaml similarity index 100% rename from .github/workflows/fmt.yaml rename to .github/workflows/gofmt.yaml From a8667b68dfe20aa898eed1b808889d7734e505f6 Mon Sep 17 00:00:00 2001 From: Matt Johnstone Date: Fri, 4 Oct 2024 07:45:45 +0200 Subject: [PATCH 3/3] updated test workflow to run on merge to main as well --- .github/workflows/go-test.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/go-test.yaml b/.github/workflows/go-test.yaml index 97c775b..5ba6c53 100644 --- a/.github/workflows/go-test.yaml +++ b/.github/workflows/go-test.yaml @@ -1,6 +1,9 @@ name: Go Tests on: + push: + branches: + - main pull_request: jobs: