diff --git a/.github/workflows/exporter-build.yml b/.github/workflows/exporter-build.yml new file mode 100644 index 0000000..855629b --- /dev/null +++ b/.github/workflows/exporter-build.yml @@ -0,0 +1,100 @@ +name: "Ethminer Metrics Exporter" +on: + pull_request: + branches: + - '**' + paths: + - 'ethminer-exporter/*' + - 'ethminer-exporter/**/*' + - .github/workflows/exporter-build.yml + push: + branches: + - main + paths: + - 'ethminer-exporter/*' + - 'ethminer-exporter/**/*' + - .github/workflows/exporter-build.yml +jobs: + ci: + runs-on: ubuntu-18.04 + name: CI + steps: + - name: git checkout + uses: actions/checkout@v2 + + - name: extract versions + id: versions + run: | + version=$(cat VERSION) + echo "::set-output name=git-tag::ethminer-exporter-v${version}" + echo "::set-output name=version::v${version}" + echo "::set-output name=dirty-version::v${version}-$(git rev-parse --short HEAD)" + working-directory: ethminer-exporter + + - name: docker login + uses: azure/docker-login@v1 + with: + login-server: ghcr.io + username: hfuss + password: ${{ secrets.PACKAGES_TOKEN }} + + - name: test + run: | + make test + fmt=$(go fmt ./.../ | wc -l) + [[ "$fmt" -eq "0" ]] + working-directory: ethminer-exporter + + - name: build + run: | + docker build . -f build/Dockerfile -t ghcr.io/hfuss/ethminer-exporter:${{ steps.versions.outputs.dirty-version }} + docker run -i ghcr.io/hfuss/ethminer-exporter:${{ steps.versions.outputs.dirty-version }} client --help + docker push ghcr.io/hfuss/ethminer-exporter:${{ steps.versions.outputs.dirty-version }} + working-directory: ethminer-exporter + + - name: enforce new version + run: | + git ls-remote --exit-code origin --tags '${{ steps.versions.outputs.git-tag }}' && found=true + if [[ "${found}" == "true" ]]; then + echo "${{ steps.versions.outputs.git-tag }} tag already exists, please update the version and changelog" + exit 1 + fi + + - name: enforce changelog + if: ${{ github.event_name == 'pull_request' }} + uses: dangoslen/changelog-enforcer@v2 + with: + changeLogPath: 'ethminer-exporter/CHANGELOG.md' + skipLabels: 'Skip-Changelog' + expectedLatestVersion: ${{ steps.versions.outputs.version }} + + - name: extract changelog + id: changelog + uses: mindsers/changelog-reader-action@v2 + with: + validation_depth: 10 + version: ${{ steps.versions.outputs.version }} + path: ethminer-exporter/CHANGELOG.md + + - name: tag images + run: | + docker tag ghcr.io/hfuss/ethminer-exporter:${{ steps.versions.outputs.dirty-version }} ghcr.io/hfuss/ethminer-exporter:${{ steps.versions.outputs.version }} + docker tag ghcr.io/hfuss/ethminer-exporter:${{ steps.versions.outputs.dirty-version }} ghcr.io/hfuss/ethminer-exporter:latest + + - name: promote images + if: ${{ github.event_name == 'push' }} + run: | + docker push ghcr.io/hfuss/ethminer-exporter:${{ steps.versions.outputs.version }} + docker push ghcr.io/hfuss/ethminer-exporter:latest + + - name: git release + uses: actions/create-release@v1 + if: ${{ github.event_name == 'push' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: ${{ steps.versions.outputs.git-tag }} + release_name: Ethminer Metrics Exporter ${{ steps.versions.outputs.version }} Release + body: ${{ steps.changelog.outputs.changes }} + draft: false + prerelease: false diff --git a/.gitignore b/.gitignore index 66fd13c..ce6b0f8 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ # Dependency directories (remove the comment below to include it) # vendor/ + +**/build/_output/ \ No newline at end of file diff --git a/ethminer-exporter/CHANGELOG.md b/ethminer-exporter/CHANGELOG.md index e69de29..f050fdb 100644 --- a/ethminer-exporter/CHANGELOG.md +++ b/ethminer-exporter/CHANGELOG.md @@ -0,0 +1,28 @@ +# CHANGELOG + +Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) + +## Unreleased +### Added +- ... + +### Changed +- ... + +### Removed +- ... + +### Dependencies +- ... + +## [v0.1.0] +### Changed +- `ApiClient` for interacting with the Ethminer JSON RPC 2.0 API +- `MockServer` for mocking the Ethminer JSON RPC 2.0 API +- CLI utility for testing client and mock API server + +### Dependencies +- All dependencies are vendored +- Retry library `github.com/avast/retry-go@v3.0.0` +- CLI library and generator `github.com/spf13/cobra@v1.1.1` +- JSON RPC 2.0 client and server library `github.com/sourcegraph/jsonrpc2@v0.0.0` diff --git a/ethminer-exporter/Makefile b/ethminer-exporter/Makefile new file mode 100644 index 0000000..1265858 --- /dev/null +++ b/ethminer-exporter/Makefile @@ -0,0 +1,21 @@ +.PHONY: build docker-build test clean all fmt + +all: build docker-build + +fmt: + go fmt ./.../ + +test: + go test -cover -count=1 -v ./.../ + +build/_output/bin/ethxporter: + mkdir -p build/_output/bin/ + go build -a -tags netgo -mod=vendor -o build/_output/bin/ethxporter main.go + +build: build/_output/bin/ethxporter + +docker-build: + docker build . -f build/Dockerfile -t ethxporter + +clean: + rm -r build/_output/bin/ethxporter \ No newline at end of file diff --git a/ethminer-exporter/cmd/root.go b/ethminer-exporter/cmd/root.go index 2d68c75..906ad8c 100644 --- a/ethminer-exporter/cmd/root.go +++ b/ethminer-exporter/cmd/root.go @@ -17,9 +17,10 @@ package cmd import ( "fmt" - "github.com/spf13/cobra" "os" + "github.com/spf13/cobra" + homedir "github.com/mitchellh/go-homedir" "github.com/spf13/viper" ) @@ -28,7 +29,7 @@ var cfgFile string // rootCmd represents the base command when called without any subcommands var rootCmd = &cobra.Command{ - Use: "ethminer-exporter", + Use: "ethxporter", Short: "A brief description of your application", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your application. For example: diff --git a/ethminer-exporter/ethxporter b/ethminer-exporter/ethxporter deleted file mode 100755 index 1ea1b22..0000000 Binary files a/ethminer-exporter/ethxporter and /dev/null differ diff --git a/miner/CHANGELOG.md b/miner/CHANGELOG.md index c1a1229..9e33abd 100644 --- a/miner/CHANGELOG.md +++ b/miner/CHANGELOG.md @@ -26,7 +26,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Changed - Enabling API server -### Dependecies +### Dependencies - Bump `https://github.com/ethereum-mining/ethminer` to `v0.19.0` ## [v0.1.0]