Skip to content

Commit

Permalink
initialize project
Browse files Browse the repository at this point in the history
  • Loading branch information
scrayos committed Nov 21, 2024
0 parents commit 72a82e5
Show file tree
Hide file tree
Showing 21 changed files with 3,746 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*
!build.rs
!Cargo.toml
!Cargo.lock
!src
!config
96 changes: 96 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# there is only one editorconfig for our project so it is automatically the root config
root = true

[*]
# the charset helps with guaranteeing that all chars are encoded in the same way
charset = utf-8

# we solely use spaces for our formatting, so the indent needs to be fixed as well
indent_size = 4
tab_width = 4
ij_continuation_indent_size = 4
indent_style = space
ij_smart_tabs = false

# provide the visual guide and hard wrap, so we don't write overly long lines (but don't wrap automatically)
max_line_length = 120
ij_visual_guides = 100
ij_wrap_on_typing = false

# the final newline helps with old/unix tools so that they can properly print files
insert_final_newline = true

# trailing whitespaces serve absolutely no value, so we can trim them away
trim_trailing_whitespace = true

# we do not use the formatter tag at all, since all files need to be compliant
ij_formatter_tags_enabled = false
ij_formatter_off_tag = @formatter:off
ij_formatter_on_tag = @formatter:on

[.editorconfig]
# spaces after the comma are in line with our other codestyle and increase the readability
ij_editorconfig_space_after_comma = true
ij_editorconfig_space_before_comma = false

# colons are used as regular characters, so we use no spaces at all
ij_editorconfig_space_before_colon = false
ij_editorconfig_space_after_colon = false

# spaces around the assignment operator increase the readability
ij_editorconfig_spaces_around_assignment_operators = true

# since there are some very long keys, this is detrimental to the readability
ij_editorconfig_align_group_field_declarations = false

[{*.yml,*.yaml}]
# yaml structures can get nested very easily, so we reduce the indent to compensate for that
indent_size = 2
tab_width = 2

# some keys can get very long, so we don't want to align all of them together
ij_yaml_align_values_properties = do_not_align

# the indents for empty lines serve absolutely no value, so we remove them
ij_yaml_block_mapping_on_new_line = false
ij_yaml_keep_indents_on_empty_lines = false

# sequence values are already kind of indented because of the hyphen, so we don't indent additionally
ij_yaml_autoinsert_sequence_marker = true
ij_yaml_indent_sequence_value = false

# yaml files are used as configuration so line breaks are crucial for the readability
ij_yaml_keep_line_breaks = true
ij_yaml_sequence_on_new_line = false

# we don't need spaces before colons
ij_yaml_space_before_colon = false

# we don't need any spaces within brackets or braces as this is the compressed representation
ij_yaml_spaces_within_braces = false
ij_yaml_spaces_within_brackets = false

[*.md]
# we want spaces after syntactical elements so we enforce them
ij_markdown_force_one_space_after_blockquote_symbol = true
ij_markdown_force_one_space_after_header_symbol = true
ij_markdown_force_one_space_after_list_bullet = true
ij_markdown_force_one_space_between_words = true

# indents on empty lines serve no real purpose and can therefore be trimmed away
ij_markdown_keep_indents_on_empty_lines = false

# paragraphs have exactly one
ij_markdown_max_lines_between_paragraphs = 1
ij_markdown_min_lines_between_paragraphs = 1

# block elements have exactly one newline around them to increase the readability
ij_markdown_min_lines_around_block_elements = 1
ij_markdown_max_lines_around_block_elements = 1

# headers have exactly one newline around them to increase the readability
ij_markdown_min_lines_around_header = 1
ij_markdown_max_lines_around_header = 1

[{*.toml,Cargo.lock,Cargo.toml.orig,Gopkg.lock,Pipfile,poetry.lock}]
ij_toml_keep_indents_on_empty_lines = false
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "weekly"
Binary file added .github/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Docker

on:
push:
branches:
- main
tags:
- '*'
pull_request:
branches:
- main

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
actions: read
security-events: write
id-token: write
steps:

- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login into GitHub Container Registry
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
flavor: |
latest=true
labels: |
org.opencontainers.image.title=mcexport
org.opencontainers.image.description=Minecraft Server Prometheus Exporter
org.opencontainers.image.vendor=Scrayos UG (haftungsbeschränkt)
org.opencontainers.image.authors=Joshua Dean Küpper <[email protected]>
org.opencontainers.image.url=https://github.com/scrayosnet/mcexport
org.opencontainers.image.documentation=https://github.com/scrayosnet/mcexport
org.opencontainers.image.source=https://github.com/scrayosnet/mcexport
org.opencontainers.image.licenses=MIT
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6
with:
context: .
push: ${{ github.ref_type == 'tag' }}
tags: ${{ steps.meta.outputs.tags }}
annotations: ${{ steps.meta.outputs.annotations }}
labels: ${{ steps.meta.outputs.labels }}
provenance: false
sbom: false
54 changes: 54 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build and Release Binaries

on:
release:
types:
- published

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- 'ubuntu-latest'
- 'macos-latest'
- 'windows-latest'

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Apply caching
uses: swatinem/rust-cache@v2

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable

- name: Build binary
run: |
cargo build --release
env:
CARGO_BUILD_TARGET: ${{ matrix.os == 'windows-latest' && 'x86_64-pc-windows-msvc' || 'x86_64-unknown-linux-gnu' || 'x86_64-apple-darwin' }}

- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-binary
path: target/release/${{ github.event.repository.name }}${{ matrix.os == 'windows-latest' && '.exe' || '' }}

release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: binaries

- name: Upload release binaries
uses: softprops/action-gh-release@v2
with:
files: binaries/*
59 changes: 59 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Rust

on:
push:
branches:
- main
tags:
- v*
pull_request:
branches:
- main

env:
CARGO_TERM_COLOR: always

jobs:
build:
permissions:
contents: read
security-events: write
runs-on: ubuntu-latest
steps:

- name: Checkout repository
uses: actions/checkout@v4

- name: Apply caching
uses: swatinem/rust-cache@v2

- name: Install required cargo
run: cargo install clippy-sarif sarif-fmt

- name: Check OpenSSL
run: (! cargo tree -i openssl 2> /dev/null)

- name: Build with cargo
run: cargo build --verbose

- name: Run tests with cargo
run: cargo test --verbose --all-features

- name: Check format
run: cargo fmt --check

- name: Perform linting
run:
cargo clippy
--all-features
--message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
continue-on-error: true

- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: rust-clippy-results.sarif
wait-for-processing: true

- name: Perform audit
run: cargo audit
Loading

0 comments on commit 72a82e5

Please sign in to comment.