diff --git a/.github/workflows/container.yaml b/.github/workflows/container.yaml index 27a2dc93c..2064d0ee4 100644 --- a/.github/workflows/container.yaml +++ b/.github/workflows/container.yaml @@ -2,8 +2,11 @@ name: Container on: push: - tags-ignore: - - "!v*" + branches: + - "develop" + - "main" + tags: + - "v*" pull_request: branches: - "develop" @@ -17,6 +20,10 @@ jobs: name: Test (Docker) runs-on: ubuntu-latest + strategy: + matrix: + target: [debug, release] + steps: - id: setup name: Setup Toolchain @@ -29,9 +36,10 @@ jobs: file: ./Containerfile push: false load: true + target: ${{ matrix.target }} tags: torrust-tracker:local cache-from: type=gha - cache-to: type=gha,mode=max + cache-to: type=gha - id: inspect name: Inspect @@ -122,4 +130,4 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha - cache-to: type=gha,mode=max + cache-to: type=gha diff --git a/.github/workflows/deployment.yaml b/.github/workflows/deployment.yaml new file mode 100644 index 000000000..6b6a64975 --- /dev/null +++ b/.github/workflows/deployment.yaml @@ -0,0 +1,81 @@ +name: Deployment + +on: + push: + tags: + - "v*" + +jobs: + secrets: + name: Secrets + needs: context + environment: dockerhub-torrust + if: needs.context.outputs.continue == 'true' + runs-on: ubuntu-latest + + outputs: + continue: ${{ steps.check.outputs.continue }} + + steps: + - id: check + name: Check + env: + CRATES_TOKEN: "${{ secrets.CRATES_TOKEN }}" + if: "${{ env.CRATES_TOKEN != '' }}" + run: echo "continue=true" >> $GITHUB_OUTPUT + + test: + name: Test + needs: secrets + if: needs.secrets.outputs.continue == 'true' + runs-on: ubuntu-latest + + strategy: + matrix: + toolchain: [stable, nightly] + + steps: + - id: checkout + name: Checkout Repository + uses: actions/checkout@v3 + + - id: setup + name: Setup Toolchain + uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ matrix.toolchain }} + + - id: test + name: Run Unit Tests + run: cargo test --tests --benches --examples --workspace --all-targets --all-features + + publish: + name: Publish + environment: crates-io-torrust + needs: test + if: needs.secrets.outputs.continue == 'true' + runs-on: ubuntu-latest + + steps: + - id: checkout + name: Checkout Repository + uses: actions/checkout@v3 + + - id: setup + name: Setup Toolchain + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }} + + - id: publish + name: Publish Crates + run: | + cargo publish -p torrust-tracker-contrib-bencode + cargo publish -p torrust-tracker-located-error + cargo publish -p torrust-tracker-primitives + cargo publish -p torrust-tracker-configuration + cargo publish -p torrust-tracker-test-helpers + cargo publish -p torrust-tracker diff --git a/.github/workflows/publish_crate.yml b/.github/workflows/publish_crate.yml deleted file mode 100644 index 4d5d0772e..000000000 --- a/.github/workflows/publish_crate.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: Publish crate - -on: - push: - tags: - - "v*" - -jobs: - check-secret: - runs-on: ubuntu-latest - environment: crates-io-torrust - outputs: - publish: ${{ steps.check.outputs.publish }} - steps: - - id: check - env: - CRATES_TOKEN: "${{ secrets.CRATES_TOKEN }}" - if: "${{ env.CRATES_TOKEN != '' }}" - run: echo "publish=true" >> $GITHUB_OUTPUT - - test: - needs: check-secret - if: needs.check-secret.outputs.publish == 'true' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - with: - toolchain: stable - components: llvm-tools-preview - - uses: Swatinem/rust-cache@v2 - - name: Run Tests - run: cargo test - - publish: - needs: test - if: needs.check-secret.outputs.publish == 'true' - runs-on: ubuntu-latest - environment: crates-io-torrust - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install stable toolchain - uses: dtolnay/rust-toolchain@stable - with: - toolchain: stable - - - name: Publish workspace packages - run: | - cargo publish -p torrust-tracker-located-error - cargo publish -p torrust-tracker-primitives - cargo publish -p torrust-tracker-configuration - cargo publish -p torrust-tracker-test-helpers - cargo publish -p torrust-tracker - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }} diff --git a/.github/workflows/testing.yaml b/.github/workflows/testing.yaml index c1f85a90b..2fa52f5a4 100644 --- a/.github/workflows/testing.yaml +++ b/.github/workflows/testing.yaml @@ -50,7 +50,7 @@ jobs: name: Setup Toolchain uses: dtolnay/rust-toolchain@stable with: - toolchain: nightly + toolchain: ${{ matrix.toolchain }} components: clippy - id: cache diff --git a/Cargo.lock b/Cargo.lock index 0b7c9d0d4..fae2d9dd9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -258,14 +258,6 @@ version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" -[[package]] -name = "bencode" -version = "1.0.0-alpha.1" -dependencies = [ - "criterion", - "error-chain", -] - [[package]] name = "bigdecimal" version = "0.3.1" @@ -3103,7 +3095,6 @@ dependencies = [ "axum", "axum-client-ip", "axum-server", - "bencode", "binascii", "chrono", "config", @@ -3133,6 +3124,7 @@ dependencies = [ "thiserror", "tokio", "torrust-tracker-configuration", + "torrust-tracker-contrib-bencode", "torrust-tracker-located-error", "torrust-tracker-primitives", "torrust-tracker-test-helpers", @@ -3155,6 +3147,14 @@ dependencies = [ "uuid", ] +[[package]] +name = "torrust-tracker-contrib-bencode" +version = "3.0.0-alpha.4" +dependencies = [ + "criterion", + "error-chain", +] + [[package]] name = "torrust-tracker-located-error" version = "3.0.0-alpha.4" diff --git a/Cargo.toml b/Cargo.toml index 9c94ea10d..17c1cbbb7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,21 +1,37 @@ [package] name = "torrust-tracker" -description = "A feature rich BitTorrent tracker." -license-file.workspace = true +readme = "README.md" + authors.workspace = true +description.workspace = true +documentation.workspace = true edition.workspace = true +homepage.workspace = true +keywords.workspace = true +license-file.workspace = true +publish.workspace = true repository.workspace = true +rust-version.workspace = true version.workspace = true + [workspace.package] -license-file = "COPYRIGHT" authors = [ "Nautilus Cyberneering , Mick van Dijke ", ] +categories = ["network-programming", "web-programming"] +description = "A feature rich BitTorrent tracker." +documentation = "https://docs.rs/crate/torrust-tracker/" edition = "2021" +homepage = "https://torrust.com/" +keywords = ["bittorrent", "tracker", "file-sharing", "peer-to-peer", "torrent"] +license-file = "COPYRIGHT" +publish = true repository = "https://github.com/torrust/torrust-tracker" +rust-version = "1.72" version = "3.0.0-alpha.4" + [dependencies] tokio = { version = "1.29", features = [ "rt-multi-thread", @@ -50,7 +66,7 @@ axum = "0.6.20" axum-server = { version = "0.5", features = ["tls-rustls"] } axum-client-ip = "0.4.1" tower-http = { version = "0.4.3", features = ["compression-full"] } -bencode = { version = "1.0.0-alpha.1", path = "contrib/bencode" } +torrust-tracker-contrib-bencode = { version = "3.0.0-alpha.4", path = "contrib/bencode"} torrust-tracker-primitives = { version = "3.0.0-alpha.4", path = "packages/primitives" } torrust-tracker-configuration = { version = "3.0.0-alpha.4", path = "packages/configuration" } torrust-tracker-located-error = { version = "3.0.0-alpha.4", path = "packages/located-error" } diff --git a/cSpell.json b/cSpell.json index fc9db42b7..e4ac1d90b 100644 --- a/cSpell.json +++ b/cSpell.json @@ -33,6 +33,7 @@ "curr", "Cyberneering", "datetime", + "Dijke", "distroless", "dockerhub", "downloadedi", @@ -133,4 +134,4 @@ "shellscript", "toml" ] -} \ No newline at end of file +} diff --git a/contrib/bencode/Cargo.toml b/contrib/bencode/Cargo.toml index 8334e270d..2aed18409 100644 --- a/contrib/bencode/Cargo.toml +++ b/contrib/bencode/Cargo.toml @@ -1,22 +1,21 @@ [package] -name = "bencode" -description = "Efficient decoding and encoding for bencode." -keywords = ["bencode"] +name = "torrust-tracker-contrib-bencode" +description = "(contrib) Efficient decoding and encoding for bencode." +keywords = ["library", "contrib", "bencode"] readme = "README.md" - authors = [ "Nautilus Cyberneering , Andrew ", ] -categories = ["network-programming", "web-programming"] -documentation = "https://github.com/torrust/bittorrent-infrastructure-project" -edition = "2021" -homepage = "https://github.com/torrust/bittorrent-infrastructure-project" -license = "Apache-2.0" -publish = false # until we decide where to publish. repository = "https://github.com/torrust/bittorrent-infrastructure-project" -rust-version = "1.71" -version = "1.0.0-alpha.1" +license = "Apache-2.0" + +documentation.workspace = true +edition.workspace = true +homepage.workspace = true +publish.workspace = true +rust-version.workspace = true +version.workspace = true [dependencies] @@ -31,4 +30,4 @@ path = "test/mod.rs" [[bench]] name = "bencode_benchmark" -harness = false \ No newline at end of file +harness = false diff --git a/contrib/bencode/benches/bencode_benchmark.rs b/contrib/bencode/benches/bencode_benchmark.rs index 729197d8a..b79bb0999 100644 --- a/contrib/bencode/benches/bencode_benchmark.rs +++ b/contrib/bencode/benches/bencode_benchmark.rs @@ -1,5 +1,5 @@ -use bencode::{BDecodeOpt, BencodeRef}; use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use torrust_tracker_contrib_bencode::{BDecodeOpt, BencodeRef}; const B_NESTED_LISTS: &[u8; 100] = b"lllllllllllllllllllllllllllllllllllllllllllllllllleeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"; // cspell:disable-line diff --git a/contrib/bencode/src/lib.rs b/contrib/bencode/src/lib.rs index 103a3c371..78e113b66 100644 --- a/contrib/bencode/src/lib.rs +++ b/contrib/bencode/src/lib.rs @@ -85,8 +85,8 @@ const BYTE_LEN_END: u8 = b':'; macro_rules! ben_map { ( $($key:expr => $val:expr),* ) => { { - use bencode::{BMutAccess, BencodeMut}; - use bencode::inner::BCowConvert; + use $crate::{BMutAccess, BencodeMut}; + use $crate::inner::BCowConvert; let mut bencode_map = BencodeMut::new_dict(); { @@ -106,7 +106,7 @@ macro_rules! ben_map { macro_rules! ben_list { ( $($ben:expr),* ) => { { - use bencode::{BencodeMut, BMutAccess}; + use $crate::{BencodeMut, BMutAccess}; let mut bencode_list = BencodeMut::new_list(); { @@ -125,8 +125,8 @@ macro_rules! ben_list { #[macro_export] macro_rules! ben_bytes { ( $ben:expr ) => {{ - use bencode::inner::BCowConvert; - use bencode::BencodeMut; + use $crate::inner::BCowConvert; + use $crate::BencodeMut; BencodeMut::new_bytes(BCowConvert::convert($ben)) }}; @@ -136,7 +136,7 @@ macro_rules! ben_bytes { #[macro_export] macro_rules! ben_int { ( $ben:expr ) => {{ - use bencode::BencodeMut; + use $crate::BencodeMut; BencodeMut::new_int($ben) }}; diff --git a/contrib/bencode/src/reference/decode.rs b/contrib/bencode/src/reference/decode.rs index d18dffda0..d2aa180f8 100644 --- a/contrib/bencode/src/reference/decode.rs +++ b/contrib/bencode/src/reference/decode.rs @@ -1,5 +1,3 @@ -#![allow(clippy::should_panic_without_expect)] - use std::collections::btree_map::Entry; use std::collections::BTreeMap; use std::str::{self}; diff --git a/contrib/bencode/test/mod.rs b/contrib/bencode/test/mod.rs index c1454967d..14606c175 100644 --- a/contrib/bencode/test/mod.rs +++ b/contrib/bencode/test/mod.rs @@ -1,4 +1,4 @@ -use bencode::{ben_bytes, ben_int, ben_list, ben_map}; +use torrust_tracker_contrib_bencode::{ben_bytes, ben_int, ben_list, ben_map}; #[test] fn positive_ben_map_macro() { diff --git a/packages/configuration/Cargo.toml b/packages/configuration/Cargo.toml index e3ca1d932..93b45c0a7 100644 --- a/packages/configuration/Cargo.toml +++ b/packages/configuration/Cargo.toml @@ -1,12 +1,20 @@ [package] name = "torrust-tracker-configuration" description = "A library to provide configuration to the Torrust Tracker." -license-file.workspace = true +keywords = ["library", "config", "settings"] +readme = "README.md" + authors.workspace = true +documentation.workspace = true edition.workspace = true +homepage.workspace = true +license-file.workspace = true +publish.workspace = true repository.workspace = true +rust-version.workspace = true version.workspace = true + [dependencies] serde = { version = "1.0", features = ["derive"] } serde_with = "3.2" diff --git a/packages/located-error/Cargo.toml b/packages/located-error/Cargo.toml index 19707e7e9..ea0b1639a 100644 --- a/packages/located-error/Cargo.toml +++ b/packages/located-error/Cargo.toml @@ -1,15 +1,22 @@ [package] name = "torrust-tracker-located-error" description = "A library to provide error decorator with the location and the source of the original error." -license-file.workspace = true +keywords = ["library", "helper", "errors"] +readme = "README.md" + authors.workspace = true +documentation.workspace = true edition.workspace = true +homepage.workspace = true +license-file.workspace = true +publish.workspace = true repository.workspace = true +rust-version.workspace = true version.workspace = true + [dependencies] log = { version = "0.4", features = ["release_max_level_info"] } [dev-dependencies] thiserror = "1.0" - diff --git a/packages/primitives/Cargo.toml b/packages/primitives/Cargo.toml index 7576e06d8..9eb092e1c 100644 --- a/packages/primitives/Cargo.toml +++ b/packages/primitives/Cargo.toml @@ -1,12 +1,20 @@ [package] name = "torrust-tracker-primitives" description = "A library with the primitive types shared by the Torrust tracker packages." -license-file.workspace = true +keywords = ["library", "api", "primitives"] +readme = "README.md" + authors.workspace = true +documentation.workspace = true edition.workspace = true +homepage.workspace = true +license-file.workspace = true +publish.workspace = true repository.workspace = true +rust-version.workspace = true version.workspace = true + [dependencies] serde = { version = "1.0", features = ["derive"] } derive_more = "0.99" diff --git a/packages/test-helpers/Cargo.toml b/packages/test-helpers/Cargo.toml index 4e6c70e66..91831399c 100644 --- a/packages/test-helpers/Cargo.toml +++ b/packages/test-helpers/Cargo.toml @@ -1,14 +1,21 @@ [package] name = "torrust-tracker-test-helpers" description = "A library providing helpers for testing the Torrust tracker." -license-file.workspace = true +keywords = ["library", "helper", "testing"] +readme = "README.md" + authors.workspace = true +documentation.workspace = true edition.workspace = true +homepage.workspace = true +license-file.workspace = true +publish.workspace = true repository.workspace = true +rust-version.workspace = true version.workspace = true [dependencies] lazy_static = "1.4" rand = "0.8.5" -torrust-tracker-configuration = { version = "3.0.0-alpha.4", path = "../configuration"} -torrust-tracker-primitives = { version = "3.0.0-alpha.4", path = "../primitives"} +torrust-tracker-configuration = { version = "3.0.0-alpha.4", path = "../configuration" } +torrust-tracker-primitives = { version = "3.0.0-alpha.4", path = "../primitives" } diff --git a/src/servers/http/v1/responses/announce.rs b/src/servers/http/v1/responses/announce.rs index e7b64522c..3596275f4 100644 --- a/src/servers/http/v1/responses/announce.rs +++ b/src/servers/http/v1/responses/announce.rs @@ -7,9 +7,9 @@ use std::panic::Location; use axum::http::StatusCode; use axum::response::{IntoResponse, Response}; -use bencode::{ben_bytes, ben_int, ben_list, ben_map, BMutAccess, BencodeMut}; use serde::{self, Deserialize, Serialize}; use thiserror::Error; +use torrust_tracker_contrib_bencode::{ben_bytes, ben_int, ben_list, ben_map, BMutAccess, BencodeMut}; use crate::servers::http::v1::responses; use crate::tracker::{self, AnnounceData}; diff --git a/src/servers/http/v1/responses/scrape.rs b/src/servers/http/v1/responses/scrape.rs index c2f099597..9cd88b9ab 100644 --- a/src/servers/http/v1/responses/scrape.rs +++ b/src/servers/http/v1/responses/scrape.rs @@ -5,7 +5,7 @@ use std::borrow::Cow; use axum::http::StatusCode; use axum::response::{IntoResponse, Response}; -use bencode::{ben_int, ben_map, BMutAccess}; +use torrust_tracker_contrib_bencode::{ben_int, ben_map, BMutAccess}; use crate::tracker::ScrapeData;