-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI for Testing and Publishing Exporter CLI / Image (#9)
* CI for Testing and Publishing Exporter CLI / Image * fixing workflow * testing cli via docker run
- Loading branch information
1 parent
c9d6674
commit 3104c92
Showing
7 changed files
with
155 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,5 @@ | |
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
**/build/_output/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters