From 6ef6b323256220a5a84b6bc3ad7d089ea4654af4 Mon Sep 17 00:00:00 2001 From: neon_arch Date: Mon, 29 May 2023 19:45:00 +0300 Subject: [PATCH 1/8] ci: add CI to automate the generation of contributors list --- .github/workflows/contributors.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/workflows/contributors.yml diff --git a/.github/workflows/contributors.yml b/.github/workflows/contributors.yml new file mode 100644 index 0000000..bed59af --- /dev/null +++ b/.github/workflows/contributors.yml @@ -0,0 +1,16 @@ +name: Contributors +on: + schedule: + - cron: '0 1 * * *' # At 01:00 on every day. + push: + branches: + - rolling +jobs: + contributors: + runs-on: ubuntu-latest + steps: + - uses: wow-actions/contributors-list@v1 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + round: true + svgPath: ../../images/contributors_list.svg From d4df90160d276b50a7b9ebf2728407574ae5d639 Mon Sep 17 00:00:00 2001 From: neon_arch Date: Mon, 29 May 2023 21:09:07 +0300 Subject: [PATCH 2/8] feat: add an option to enable/disable debug mode --- src/bin/websurfx.rs | 2 +- src/config_parser/parser.rs | 2 ++ websurfx/config.lua | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bin/websurfx.rs b/src/bin/websurfx.rs index ca05713..91708aa 100644 --- a/src/bin/websurfx.rs +++ b/src/bin/websurfx.rs @@ -19,7 +19,7 @@ async fn main() -> std::io::Result<()> { let config = Config::parse().unwrap(); // Initializing logging middleware with level set to default or info. - if config.logging { + if config.logging || config.debug{ use env_logger::Env; env_logger::Builder::from_env(Env::default().default_filter_or("info")).init(); } diff --git a/src/config_parser/parser.rs b/src/config_parser/parser.rs index dd92f1b..ac200cd 100644 --- a/src/config_parser/parser.rs +++ b/src/config_parser/parser.rs @@ -26,6 +26,7 @@ pub struct Config { pub redis_connection_url: String, pub aggregator: AggreatorConfig, pub logging: bool, + pub debug: bool, } /// Configuration options for the aggregator. @@ -73,6 +74,7 @@ impl Config { redis_connection_url: globals.get::<_, String>("redis_connection_url")?, aggregator: aggregator_config, logging: globals.get::<_, bool>("logging")?, + debug: globals.get::<_, bool>("debug")?, }) }) } diff --git a/websurfx/config.lua b/websurfx/config.lua index 29c4fff..3daaa91 100644 --- a/websurfx/config.lua +++ b/websurfx/config.lua @@ -1,5 +1,6 @@ -- ### General ### logging = true -- an option to enable or disable logs. +debug = false -- an option to enable or disable debug mode. -- ### Server ### port = "8080" -- port on which server should be launched From 60317a3b75cbd256d3dd2b1723a31aa82bd051ef Mon Sep 17 00:00:00 2001 From: neon_arch Date: Mon, 29 May 2023 21:13:07 +0300 Subject: [PATCH 3/8] chore: make format ci happy --- src/bin/websurfx.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/websurfx.rs b/src/bin/websurfx.rs index 91708aa..8661725 100644 --- a/src/bin/websurfx.rs +++ b/src/bin/websurfx.rs @@ -19,7 +19,7 @@ async fn main() -> std::io::Result<()> { let config = Config::parse().unwrap(); // Initializing logging middleware with level set to default or info. - if config.logging || config.debug{ + if config.logging || config.debug { use env_logger::Env; env_logger::Builder::from_env(Env::default().default_filter_or("info")).init(); } From eb44ff7cfa3a2736720052c64cd2f8fd2baca40c Mon Sep 17 00:00:00 2001 From: neon_arch Date: Mon, 29 May 2023 21:17:00 +0300 Subject: [PATCH 4/8] chore: Bump version to v0.11.0 --- Cargo.lock | 16 ++++++++-------- Cargo.toml | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e35e94c..9af7c18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -125,7 +125,7 @@ dependencies = [ "actix-utils", "futures-core", "futures-util", - "mio 0.8.6", + "mio 0.8.7", "num_cpus", "socket2", "tokio 1.28.2", @@ -1510,14 +1510,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" +checksum = "eebffdb73fe72e917997fad08bdbf31ac50b0fa91cec93e69a0662e4264d454c" dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -1603,9 +1603,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.1" +version = "1.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b" [[package]] name = "openssl" @@ -2879,7 +2879,7 @@ dependencies = [ "autocfg 1.1.0", "bytes 1.4.0", "libc", - "mio 0.8.6", + "mio 0.8.7", "num_cpus", "parking_lot 0.12.1", "pin-project-lite", @@ -3316,7 +3316,7 @@ dependencies = [ [[package]] name = "websurfx" -version = "0.10.0" +version = "0.11.0" dependencies = [ "actix-files", "actix-web", diff --git a/Cargo.toml b/Cargo.toml index 8d8d452..17aa0a0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "websurfx" -version = "0.10.0" +version = "0.11.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 13632f1f99bbabdbff503729a3238798d000c2bd Mon Sep 17 00:00:00 2001 From: neon_arch Date: Mon, 29 May 2023 21:28:09 +0300 Subject: [PATCH 5/8] feat: remove random delays when debug is set to true --- src/search_results_handler/aggregator.rs | 3 ++- src/server/routes.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/search_results_handler/aggregator.rs b/src/search_results_handler/aggregator.rs index 8b86972..8b6bae3 100644 --- a/src/search_results_handler/aggregator.rs +++ b/src/search_results_handler/aggregator.rs @@ -40,12 +40,13 @@ pub async fn aggregate( query: &str, page: u32, random_delay: bool, + debug: bool, ) -> Result> { let user_agent: String = random_user_agent(); let mut result_map: HashMap = HashMap::new(); // Add a random delay before making the request. - if random_delay { + if random_delay || !debug { let mut rng = rand::thread_rng(); let delay_secs = rng.gen_range(1..10); std::thread::sleep(Duration::from_secs(delay_secs)); diff --git a/src/server/routes.rs b/src/server/routes.rs index ead1612..9234d8d 100644 --- a/src/server/routes.rs +++ b/src/server/routes.rs @@ -128,7 +128,7 @@ pub async fn search( } Err(_) => { let mut results_json: crate::search_results_handler::aggregation_models::SearchResults = - aggregate(query, page, config.aggregator.random_delay).await?; + aggregate(query, page, config.aggregator.random_delay, config.debug).await?; results_json.add_style(config.style.clone()); redis_cache .cache_results(serde_json::to_string(&results_json)?, &page_url)?; From af8b3ce71b0b5d3388fe0ca009f22271aff19877 Mon Sep 17 00:00:00 2001 From: XFFXFF <1247714429@qq.com> Date: Tue, 30 May 2023 09:23:42 +0000 Subject: [PATCH 6/8] fix the contributor list action --- .github/workflows/contributors.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/contributors.yml b/.github/workflows/contributors.yml index bed59af..3d8580e 100644 --- a/.github/workflows/contributors.yml +++ b/.github/workflows/contributors.yml @@ -13,4 +13,4 @@ jobs: with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} round: true - svgPath: ../../images/contributors_list.svg + svgPath: images/contributors_list.svg From aeb2510de8c07f46ef09c09eb9f3ec8dfebc6806 Mon Sep 17 00:00:00 2001 From: neon_arch Date: Tue, 30 May 2023 13:00:08 +0300 Subject: [PATCH 7/8] ci: fix contributors list autogeneration by appropriate permissions --- .github/workflows/contributors.yml | 45 +++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/.github/workflows/contributors.yml b/.github/workflows/contributors.yml index bed59af..7d990f5 100644 --- a/.github/workflows/contributors.yml +++ b/.github/workflows/contributors.yml @@ -1,16 +1,47 @@ -name: Contributors +name: Contributors List + on: + workflow_dispatch: + schedule: - - cron: '0 1 * * *' # At 01:00 on every day. - push: - branches: - - rolling + - cron: "0 1 * * *" + jobs: contributors: + permissions: + contents: write + pull-requests: write + runs-on: ubuntu-latest + steps: - - uses: wow-actions/contributors-list@v1 + - name: Checkout code + uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 + with: + fetch-depth: 0 + ref: ${{ github.event.repository.default_branch }} + + - name: Update contributors list + uses: wow-actions/contributors-list@b9e91f91a51a55460fdcae64daad0cb8122cdd53 # v1.1.0 with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + svgPath: images/contributors_list.svg round: true - svgPath: ../../images/contributors_list.svg + includeBots: false + noCommit: true + + - name: Commit & PR + uses: peter-evans/create-pull-request@38e0b6e68b4c852a5500a94740f0e535e0d7ba54 # v4.2.4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + add-paths: .github/assets/CONTRIBUTORS.svg + commit-message: 'chore: update contributors-list' + committer: GitHub + author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> + signoff: false + branch: workflow/update-contributors-list + base: main + delete-branch: true + title: 'chore: update contributors-list' + body: | + Automated update to `images/contributors_list.svg` From af145e9d85249df3f89f76dd48f4b6a6255f8c24 Mon Sep 17 00:00:00 2001 From: neon_arch Date: Tue, 30 May 2023 14:55:11 +0300 Subject: [PATCH 8/8] docs: update docs to explain about the new option debug --- docs/configuration.md | 1 + docs/installation.md | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/configuration.md b/docs/configuration.md index a5391a3..0d54fd9 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -21,6 +21,7 @@ Some of the configuration options provided in the file are stated below. These a # General - **logging:** An option to enable or disable logs. +- **debug:** An option to enable or disable debug mode. ## Server diff --git a/docs/installation.md b/docs/installation.md index 1a04254..fbb0d16 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -78,6 +78,7 @@ After that edit the config.lua file located under `websurfx` directory. In the c ```lua -- ### General ### logging = true -- an option to enable or disable logs. +debug = false -- an option to enable or disable debug mode. -- ### Server ### port = "8080" -- port on which server should be launched