Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
thor314 committed Oct 29, 2024
0 parents commit 3f5cc49
Show file tree
Hide file tree
Showing 14 changed files with 406 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# List of lints:
# https://rust-lang.github.io/rust-clippy/master/index.html

# Don't warn for functions with too many arguments. Default: 7
too-many-arguments-threshold = 10
43 changes: 43 additions & 0 deletions .github/settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# These settings are synced to GitHub by https://probot.github.io/apps/settings/
# Requires sign up, and allowing Probot to manage your repos.

repository:
# name: how-many-sxg-sites # sets the repo name
description: how many of the top million sites use cloudflare sxg
# homepage: docs.rs/how-many-sxg-sites
private: false
has_issues: true
has_projects: false
has_wiki: false
has_downloads: false
default_branch: main
allow_squash_merge: true
allow_merge_commit: false
allow_rebase_merge: false

# # Labels: define labels for Issues and Pull Requests
# labels:
# - name: bug
# color: CC0000
# - name: feature
# color: 336699
# - name: first-timers-only
# # include the old name to rename and existing label
# oldname: Help Wanted

# # Collaborators: give specific users access to this repository.
# collaborators:
# - username: bkeepers
# # Note: Only valid on organization-owned repositories.
# # The permission to grant the collaborator. Can be one of:
# # * `pull` - can pull, but not push to or administer this repository.
# # * `push` - can pull and push, but not administer this repository.
# # * `admin` - can pull, push and administer this repository.
# permission: push

# - username: hubot
# permission: pull
# - username:
# permission: pull


53 changes: 53 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Rust template: https://github.com/actions/starter-workflows/blob/main/ci/rust.yml
# Resources: https://docs.github.com/en/actions
# Examples: https://github.com/actions/starter-workflows
# Process: make small changes, push them, check the Actions tab on github
# also see templates https://github.com/rust-github/template/tree/main/.github/workflows
name: Rust
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always # pretty colors

jobs:
lint:
name: lint project
runs-on: ubuntu-latest
strategy:
matrix:
toolchain:
- nightly
steps:
- uses: actions/checkout@v4
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- run: rustup component add clippy
- run: cargo clippy -- -Dwarnings
test:
name: test project
runs-on: ubuntu-latest
strategy:
matrix:
toolchain:
- nightly
steps:
- uses: actions/checkout@v4
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- run: cargo test --all-features --verbose

fmt:
name: fmt project
runs-on: ubuntu-latest
strategy:
matrix:
toolchain:
- nightly
steps:
- uses: actions/checkout@v4
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- run: rustup component add rustfmt
- run: cargo fmt --all -- --check

27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
### Rust ###
# ref: https://github.com/github/gitignore/blob/main/Rust.gitignore
cgt* # ignore instatiations of my test template

# don't leak secret env vars
.env

# exclude compiled files and binaries
debug/
target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
Cargo.lock

.vscode
.viscode

# These are backup files generated by rustfmt
**/*.rs.bk
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

dump

### VIM ###
*.swp
*.swo
50 changes: 50 additions & 0 deletions .justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# A configuration file for `just`, a command runner and successor to `make`
# https://github.com/casey/just/tree/master
#
# examples:
# https://github.com/casey/just/blob/master/examples/pre-commit.just
# https://github.com/casey/just/blob/master/examples/kitchen-sink.just

# use fish shell
# set shell := ["fish", "-c"]

# ignore comments in the command area
set ignore-comments := true

# load .env vars
# set dotenv-load := true

# set custom env vars
export RUST_LOG := "info"
# export RUST_BACKTRACE := "1"


@just:
just --list

build:
cargo build -r

check:
cargo check --all --tests
cargo fmt --all --check

format:
cargo fmt --all

fix:
cargo clippy --all --tests --fix

lint:
cargo clippy --all --tests -- -D warnings

run:
cargo run -r

test:
cargo test --all -- --nocapture

@versions:
rustc --version
cargo fmt -- --version
cargo clippy -- --version
44 changes: 44 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Opinionated whitespace and tabs. The most important of these are imports and width settings.
# Others may want to borrow or change these to their own liking.
# https://rust-lang.github.io/rustfmt

# version-related
edition = "2021" # redundant, fmt will read Cargo.toml for editor edition year
unstable_features = true
use_try_shorthand = true # replace any `try!` (2015 Rust) with `?`

# misc formatting
condense_wildcard_suffixes = true # replace: (a,b,_,_)=(1, 2, 3, 4); -> (a,b,..)=(1, 2, 3, 4);
format_code_in_doc_comments = true # format code blocks in doc comments
format_macro_matchers = true # $a: ident -> $a:ident
format_strings = true # break and insert newlines for long string literals
match_block_trailing_comma = true # include comma in match blocks after '}'
normalize_comments = true # convert /*..*/ to //.. where possible
reorder_impl_items = true # move `type` and `const` declarations to top of impl block
struct_field_align_threshold = 20 # align struct arguments' types vertically
use_field_init_shorthand = true # struct initialization short {x: x} -> {x}

# reduce whitespace
blank_lines_upper_bound = 1 # default: 1. Sometimes useful to change to 0 to condense a file.
brace_style = "PreferSameLine" # prefer starting `{` without inserting extra \n
fn_single_line = true # if it's a short 1-liner, let it be a short 1-liner
match_arm_blocks = false # remove unnecessary {} in match arms
newline_style = "Unix" # not auto, we won the culture war. \n over \r\n
overflow_delimited_expr = true # prefer ]); to ]\n);
where_single_line = true # put where on a single line if possible

# imports preferences
group_imports = "StdExternalCrate" # create import groupings for std, external libs, and internal deps
imports_granularity = "Crate" # aggressively group imports

# width settings: everything to 100
comment_width = 100 # default: 80
inline_attribute_width = 60 # inlines #[cfg(test)]\nmod test -> #[cfg(test)] mod test
max_width = 100 # default: 100
use_small_heuristics = "Max" # don't ever newline short of `max_width`.
wrap_comments = true # wrap comments at `comment_width`
# format_strings = true # wrap strings at `max_length`

# tabs and spaces
hard_tabs = false # (def: false) use spaces over tabs
# tab_spaces = 2 # 2 > 4, it's just math.
29 changes: 29 additions & 0 deletions .taplo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# .toml file formatting settings for `taplo`
# https://taplo.tamasfe.dev/configuration/formatter-options.html

[formatting]
# align entries vertically
align_entries = true

# allow up to 1 consecutive empty line (default: 2)
allowed_blank_lines = 1

# collapse arrays into one line if they fit
array_auto_collapse = true

# default: 80
column_width = 100

# expand arrays into multiple lines (default: true)
array_auto_expand = false

## other options
# remove whitespace around '='
# compact_entries = true

# alphabetically sort entries not separated by line breaks
# reorder_keys = true

# align entries vertically (default: true)
# align_comments = false

19 changes: 19 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
authors =["Thor Kampefner <[email protected]>"]
description="""how many of the top million sites use cloudflare sxg"""
edition ="2021"
name ="how-many-sxg-sites"
repository ="https://github.com/thor314/how-many-sxg-sites"
version ="0.1.0"

[dependencies]
anyhow ="1.0"
cute = "0.3.0"
log ="0.4"
thiserror="1.0"
env_logger = "0.11"
dotenvy = "0.15"


[dev-dependencies]
rstest ="0.18" # testing convenience proc-macros
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<h1 align="center">
how-many-sxg-sites
</h1>

<p align="center">
how many of the top million sites use cloudflare sxg
</p>

<div align="center">
<a href="https://x.com/cryptograthor">
<img src="https://img.shields.io/badge/made_by_cryptograthor-black?style=flat&logo=undertale&logoColor=hotpink" />
<!-- ![](https://img.shields.io/badge/made_by_cryptograthor-black?style=flat&logo=undertale&logoColor=hotpink) -->
</a>
</div>

<!-- This project was generated with [Thor's cargo generate template](https://github.com/thor314/tk-cargo-generate/) with features: -->
<!-- - project-name: how-many-sxg-sites -->
<!-- - description: how many of the top million sites use cloudflare sxg -->
<!-- - authors: Thor Kampefner <[email protected]> -->
<!-- - crate_name: how_many_sxg_sites -->
<!-- - crate_type: bin -->
<!-- - os-arch: linux-x86_64 -->
<!-- - username: Thor Kampefner -->
<!-- - within_cargo: false -->
<!-- - is_init: false -->
<!-- - now: 2024-10-29 -->
<!-- - bin or lib: bin -->
<!-- - advanced: -->
<!-- - cli: -->
<!-- - license: -->
<!-- - ci: -->
<!-- - itests: -->
<!-- - benches: -->
<!-- - async: -->
<!-- - server: -->
24 changes: 24 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# rustup toolchain config. We typically use nightly to enable better formatting and async support.
# https://rust-lang.github.io/rustup/overrides.html

[toolchain]
# what toolchain to use.
channel="nightly"

# option to specify a date to pin to a particular release
# date = "2024-03-19"

# profiles are groups of components to download when installing a toolchain.
# https://rust-lang.github.io/rustup/concepts/profiles.html
# "minimal" includes only the compiler, package manager, and standard lib.
# "default" further includes the formatter, linter, and documentation generator.
profile="default"

# Components are additional toolchain utilities. Typically not used unless working with low-level unsafe or compiler-related code.
# List: https://rust-lang.github.io/rustup/concepts/components.html
# components=["miri"]

# targets are additional platforms to support. Most commonly used for WASM or cross-compiling.
# cross compilation docs: https://rust-lang.github.io/rustup/cross-compilation.html
# list of platforms: https://doc.rust-lang.org/nightly/rustc/platform-support.html
# targets = [ "wasm32-unknown-unknown"]
20 changes: 20 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//! how-many-sxg-sites error types
// https://docs.rs/thiserror/latest/thiserror/

use thiserror::Error;

#[derive(Debug, Error)]
pub enum MyError {
// Derive Into<MyError> for io errors
#[error("My Io error: {0}")]
Io(#[from] std::io::Error),
#[error("My dotenv error: {0}")]
Dotenv(#[from] dotenvy::Error),
// Derive Into<MyError> for anyhow errors
#[error(transparent)]
Anyhow(#[from] anyhow::Error),
// Some other error type
#[allow(dead_code)]
#[error("an unhandled error")]
Unhandled,
}
22 changes: 22 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(dead_code)]
#![allow(unreachable_code)]
#![allow(non_snake_case)]
#![allow(clippy::clone_on_copy)]
#![allow(unused_mut)]

mod error;
#[cfg(test)] mod tests;
mod utils;

use error::MyError;
use log::info;

fn main() -> Result<(), MyError> {
utils::setup()?;

info!("hello thor");

Ok(())
}
Loading

0 comments on commit 3f5cc49

Please sign in to comment.