Skip to content

Commit

Permalink
feat: serve Gazelle user metrics formatted for prometheus
Browse files Browse the repository at this point in the history
  • Loading branch information
RogueOneEcho committed Nov 2, 2024
1 parent aaa9b7f commit 05805e4
Show file tree
Hide file tree
Showing 16 changed files with 2,981 additions and 1 deletion.
18 changes: 18 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/.git
/.github
/.idea
/content
/markdown_help
/output
/samples
/target
/torrents
.editorconfig
config.json
config.*.json
config.yaml
config.*.yaml
config.yml
config.*.yml
Dockerfile
*.md
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4

[*.json]
indent_size = 2

[*.rs]
max_line_length = 100

[{*.{yaml,yml}}]
indent_size = 2
179 changes: 179 additions & 0 deletions .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
name: On Push
on:
push:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:

release:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.release.outputs.version }}
steps:

- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- id: release
env:
GH_TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: ${{ secrets.RELEASE_SCRIPT }}

- run: echo "# ${{ steps.release.outputs.version}}" >> $GITHUB_STEP_SUMMARY

- run: cat /tmp/RELEASE-NOTES.md >> $GITHUB_STEP_SUMMARY

- uses: actions/upload-artifact@v4
with:
name: RELEASE-NOTES.md
path: /tmp/RELEASE-NOTES.md

- run: /home/linuxbrew/.linuxbrew/bin/brew install cargo-edit
if: ${{ steps.release.outputs.version != ''}}

- run: /home/linuxbrew/.linuxbrew/bin/cargo-set-version set-version ${{ steps.release.outputs.version }}
if: ${{ steps.release.outputs.version != ''}}

- run: git --no-pager diff --color

- uses: actions/upload-artifact@v4
with:
name: Cargo.toml
path: Cargo.toml


cargo-build:
runs-on: ubuntu-latest
needs:
- release
steps:

- uses: actions/checkout@v4

- name: Restore cargo cache
id: cache-cargo
uses: actions/cache/restore@v4
with:
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/

- uses: actions/download-artifact@v4
with:
name: Cargo.toml

- run: git --no-pager diff --color

- run: cargo build --release

- name: Save cargo cache
id: cargo-cache-save
uses: actions/cache/save@v4
with:
key: ${{ steps.cache-cargo.outputs.cache-primary-key }}
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/

- run: |
tee config.yml <<EOF
${{ secrets.CONFIG }}
EOF

- run: cargo test --release --no-fail-fast

- name: Run cargo check
run: |
if ! cargo check --quiet --all-targets --message-format short
then
echo "::warning title=Cargo Check Failed::Please review the output for details."
fi

- name: Run cargo clippy
run: |
if ! cargo clippy --quiet --all-targets --message-format short
then
echo "::warning title=Clippy Check Failed::Please review the output for details."
fi

- name: Run cargo fmt
run: |
if ! cargo fmt --check
then
echo "::warning title=Format Check Failed::Please review the output for details."
fi

- run: git --no-pager diff --color


cargo-publish:
runs-on: ubuntu-latest
if: ${{ needs.release.outputs.version != '' && ! contains(needs.release.outputs.version, '-') }}
needs:
- release
- cargo-build
steps:

- uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
name: Cargo.toml

- run: git --no-pager diff --color

- run: cargo publish --allow-dirty --no-verify
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}


github-release:
runs-on: ubuntu-latest
if: ${{ needs.release.outputs.version != ''}}
needs:
- release
- cargo-build
steps:

- uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
name: RELEASE-NOTES.md

- name: gh release create
if: ${{ ! contains(needs.release.outputs.version, '-') }}
env:
GH_TOKEN: ${{ github.token }}
run: >
gh release create
"v${{ needs.release.outputs.version }}"
--title "v${{ needs.release.outputs.version }}"
--notes-file RELEASE-NOTES.md
--target ${{ github.ref_name }}

- name: gh release create --prerelease
if: ${{ contains(needs.release.outputs.version, '-') }}
env:
GH_TOKEN: ${{ github.token }}
run: >
gh release create
"v${{ needs.release.outputs.version }}"
--title "v${{ needs.release.outputs.version }}"
--notes-file RELEASE-NOTES.md
--target ${{ github.ref_name }}
--prerelease
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/.github
/.idea
/target
config.json
Expand All @@ -9,3 +8,4 @@ config.yml
config.*.yml
**/*.rs.bk
*.pdb
.envrc
Loading

0 comments on commit 05805e4

Please sign in to comment.