Skip to content

Commit 3d79d27

Browse files
authored
Add ci (#7)
1 parent 7701e25 commit 3d79d27

File tree

11 files changed

+209
-46
lines changed

11 files changed

+209
-46
lines changed

.github/workflows/rust.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Rust CI
2+
3+
on:
4+
push:
5+
branches: [ "*" ]
6+
7+
permissions:
8+
contents: read
9+
security-events: write
10+
11+
env:
12+
CARGO_TERM_COLOR: always
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Free up disk space
21+
run: |
22+
echo "Before cleanup:"
23+
df -h
24+
docker system prune -a -f
25+
sudo rm -rf /usr/local/lib/android
26+
sudo rm -rf /opt/ghc
27+
sudo apt-get clean
28+
sudo apt-get autoremove -y
29+
echo "After cleanup:"
30+
df -h
31+
32+
- name: Switch rust version
33+
run: rustup default stable
34+
35+
- name: Update rust
36+
run: rustup update
37+
38+
- name: Cargo update
39+
run: cargo update --verbose
40+
41+
- name: Check
42+
run: cargo check --verbose
43+
44+
- name: Add fmt
45+
run: rustup component add rustfmt
46+
47+
- name: Add cargo deny
48+
run: cargo install cargo-deny
49+
50+
- name: Check formatting
51+
run: cargo fmt -- --check
52+
53+
- name: Test
54+
run: cargo test
55+
continue-on-error: true
56+
57+
- name: Build
58+
run: cargo build --verbose
59+
60+
- name: Install required cargo
61+
run: cargo install clippy-sarif sarif-fmt
62+
63+
- name: Add clippy
64+
run: rustup component add clippy
65+
66+
- name: Clippy
67+
run:
68+
cargo clippy
69+
--all-features
70+
--message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
71+
continue-on-error: true
72+
73+
- name: Cargo deny
74+
run: cargo deny check
75+
continue-on-error: true
76+
77+
- name: Upload analysis results to GitHub
78+
uses: github/codeql-action/upload-sarif@v3
79+
with:
80+
sarif_file: rust-clippy-results.sarif
81+
wait-for-processing: true

.github/workflows/test.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Test coverage
2+
3+
on:
4+
push:
5+
branches: [ "*" ]
6+
7+
permissions:
8+
contents: read
9+
security-events: write
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
toolchain:
18+
- stable
19+
steps:
20+
- name: Check out repository
21+
uses: actions/checkout@v4
22+
23+
- name: Free up disk space
24+
run: |
25+
echo "Before cleanup:"
26+
df -h
27+
docker system prune -a -f
28+
sudo rm -rf /usr/local/lib/android
29+
sudo rm -rf /opt/ghc
30+
sudo apt-get clean
31+
sudo apt-get autoremove -y
32+
echo "After cleanup:"
33+
df -h
34+
35+
- name: Install Rust
36+
uses: dtolnay/rust-toolchain@master
37+
with:
38+
toolchain: ${{ matrix.toolchain }}
39+
components: llvm-tools-preview
40+
41+
- name: Activate cache
42+
uses: Swatinem/[email protected]
43+
44+
- name: run tests
45+
run: cargo test --verbose
46+

Cargo.lock

Lines changed: 5 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ axum-extra = { version = "0.10", features = ["form"] }
1919
axum-raw-websocket = { git = "https://github.com/tompro/axum-raw-websocket.git" }
2020
anyhow = "1"
2121
tracing = "0.1.41"
22-
tracing-subscriber = "0.3.19"
22+
tracing-subscriber = "0.3.20"
2323
tower-http = { version = "0.6.6", features = ["cors", "fs"] }
2424
clap = { version = "4.5.39", features = ["derive", "env"] }
2525
chrono = "0.4"

deny.toml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# The graph table configures how the dependency graph is constructed and thus
2+
# which crates the checks are performed against
3+
[graph]
4+
targets = []
5+
exclude = []
6+
all-features = false
7+
no-default-features = false
8+
features = []
9+
10+
[output]
11+
feature-depth = 1
12+
13+
# This section is considered when running `cargo deny check advisories`
14+
# More documentation for the advisories section can be found here:
15+
# https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html
16+
[advisories]
17+
ignore = []
18+
unmaintained = "workspace"
19+
20+
# This section is considered when running `cargo deny check licenses`
21+
# More documentation for the licenses section can be found here:
22+
# https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html
23+
[licenses]
24+
allow = ["MIT", "Apache-2.0", "Unicode-3.0", "Unlicense", "CDLA-Permissive-2.0", "ISC", "CC0-1.0",
25+
"BSD-3-Clause", "Zlib", "BSD-2-Clause",
26+
]
27+
confidence-threshold = 0.8
28+
exceptions = []
29+
30+
[licenses.private]
31+
ignore = false
32+
registries = []
33+
34+
# This section is considered when running `cargo deny check bans`.
35+
# More documentation about the 'bans' section can be found here:
36+
# https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html
37+
[bans]
38+
# Lint level for when multiple versions of the same crate are detected
39+
multiple-versions = "allow"
40+
wildcards = "allow"
41+
highlight = "all"
42+
workspace-default-features = "allow"
43+
external-default-features = "allow"
44+
allow = []
45+
deny = []
46+
skip = []
47+
skip-tree = []
48+
[bans.workspace-dependencies]
49+
duplicates = "deny"
50+
unused = "deny"
51+
52+
# This section is considered when running `cargo deny check sources`.
53+
# More documentation about the 'sources' section can be found here:
54+
# https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html
55+
[sources]
56+
unknown-registry = "warn"
57+
unknown-git = "warn"
58+
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
59+
allow-git = []
60+
61+
[sources.allow-org]
62+
github = ["BitcreditProtocol", "tompro"]
63+
gitlab = []
64+
bitbucket = []

src/blossom/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ pub mod file_store;
33
use std::io::Write;
44

55
use axum::{
6+
Json,
67
body::{Body, Bytes},
78
extract::{Path, State},
89
http::StatusCode,
910
response::{IntoResponse, Response},
10-
Json,
1111
};
1212
use nostr::{
1313
hashes::{
14-
sha256::{self, Hash as Sha256Hash},
1514
Hash,
15+
sha256::{self, Hash as Sha256Hash},
1616
},
1717
types::Url,
1818
};

src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ use std::{net::SocketAddr, sync::Arc};
99

1010
use anyhow::Result;
1111
use axum::{
12+
Router,
1213
extract::{ConnectInfo, State},
1314
http::{StatusCode, Uri},
1415
response::IntoResponse,
1516
routing::{any, delete, get, head, post, put},
16-
serve, Router,
17+
serve,
1718
};
1819
use axum_raw_websocket::RawSocketUpgrade;
1920
use blossom::file_store::FileStoreApi;
@@ -31,8 +32,8 @@ use tracing::{error, info};
3132
use crate::{
3233
notification::{
3334
email::{
34-
mailjet::{MailjetConfig, MailjetService},
3535
EmailService,
36+
mailjet::{MailjetConfig, MailjetService},
3637
},
3738
notification_store::NotificationStoreApi,
3839
},

src/notification/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use axum::{
2+
Json,
23
extract::{Path, Query, State},
34
http::StatusCode,
45
response::{Html, IntoResponse, Redirect},
5-
Json,
66
};
77
use axum_extra::extract::Form;
8-
use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine as _};
8+
use base64::{Engine as _, engine::general_purpose::URL_SAFE_NO_PAD};
99
use borsh_derive::BorshSerialize;
1010
use chrono::{DateTime, Duration, Utc};
1111
use rand::RngCore;
@@ -14,13 +14,13 @@ use tinytemplate::TinyTemplate;
1414
use tracing::{error, warn};
1515

1616
use crate::{
17+
AppState,
1718
notification::{
1819
email::{build_email_confirmation_message, build_email_notification_message},
1920
preferences::{PreferencesContextContentFlag, PreferencesFlags},
2021
},
2122
rate_limit::RealIp,
2223
util::{self, get_logo_link},
23-
AppState,
2424
};
2525

2626
pub mod email;

src/rate_limit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use axum::{
22
extract::{ConnectInfo, FromRequestParts},
3-
http::{request::Parts, StatusCode},
3+
http::{StatusCode, request::Parts},
44
};
55
use chrono::{DateTime, Duration, Utc};
66
use std::{

src/relay.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use anyhow::Result;
22
use clap::Parser;
33
use nostr::types::Url;
44
use nostr_relay_builder::{
5-
builder::{RelayBuilderNip42, RelayBuilderNip42Mode},
65
LocalRelay, RelayBuilder,
6+
builder::{RelayBuilderNip42, RelayBuilderNip42Mode},
77
};
88
use nostr_sqldb::*;
99
use tracing::info;

0 commit comments

Comments
 (0)