diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..6959feb --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +--- +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + groups: + actions: + patterns: + - "*" +... \ No newline at end of file diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index dcd0486..9be908a 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -16,7 +16,7 @@ jobs: audit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - name: Run cargo-audit uses: rustsec/audit-check@v2 with: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 80bf1ca..cd21d4e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - name: fmt run: | @@ -51,7 +51,7 @@ jobs: output: wizo.exe steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - name: Install Rust Toolchain uses: dtolnay/rust-toolchain@stable with: @@ -91,7 +91,7 @@ jobs: pull-requests: write contents: read steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 with: fetch-depth: 0 diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index 086f25f..ee73f4e 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -23,14 +23,14 @@ jobs: issues: write steps: - - uses: googleapis/release-please-action@v4 + - uses: googleapis/release-please-action@v5 id: release with: target-branch: staging config-file: release-config.json manifest-file: .release-manifest.json - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 if: ${{ steps.release.outputs.release_created }} with: fetch-depth: 0 @@ -63,7 +63,7 @@ jobs: release: ${{ needs.release.outputs.tag_name }}-windows-x86_64.exe steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - name: Install Rust Toolchain uses: dtolnay/rust-toolchain@stable with: @@ -96,7 +96,7 @@ jobs: retention-days: 5 - name: Download Artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 with: name: ${{ matrix.platform.release }} path: ./dist @@ -115,7 +115,7 @@ jobs: environment: release steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 with: ref: ${{ needs.release.outputs.tag_name }} - uses: dtolnay/rust-toolchain@stable diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f348d3c..ef6949e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,14 +23,14 @@ jobs: issues: write steps: - - uses: googleapis/release-please-action@v4 + - uses: googleapis/release-please-action@v5 id: release with: target-branch: stable config-file: release-config.json manifest-file: .release-manifest.json - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 if: ${{ steps.release.outputs.release_created }} with: fetch-depth: 0 @@ -63,7 +63,7 @@ jobs: release: ${{ needs.release.outputs.tag_name }}-windows-x86_64.exe steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - name: Install Rust Toolchain uses: dtolnay/rust-toolchain@stable with: @@ -96,7 +96,7 @@ jobs: retention-days: 5 - name: Download Artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 with: name: ${{ matrix.platform.release }} path: ./dist @@ -115,7 +115,7 @@ jobs: environment: release steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 with: ref: ${{ needs.release.outputs.tag_name }} - uses: dtolnay/rust-toolchain@stable diff --git a/.release-manifest.json b/.release-manifest.json new file mode 100644 index 0000000..e6a4ec0 --- /dev/null +++ b/.release-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.0.1-beta" +} \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 23a9d14..a553ce1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -64,6 +64,17 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" +[[package]] +name = "chacha20" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d524456ba66e72eb8b115ff89e01e497f8e6d11d78b70b1aa13c0fbd97540a81" +dependencies = [ + "cfg-if", + "cpufeatures", + "rand_core", +] + [[package]] name = "clap" version = "4.6.6" @@ -131,6 +142,15 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "cpufeatures" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201" +dependencies = [ + "libc", +] + [[package]] name = "encode_unicode" version = "1.0.0" @@ -167,6 +187,18 @@ dependencies = [ "slab", ] +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "rand_core", +] + [[package]] name = "hashbrown" version = "0.17.1" @@ -273,6 +305,29 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rand" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80" +dependencies = [ + "chacha20", + "getrandom", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" + [[package]] name = "rustversion" version = "1.0.23" @@ -469,6 +524,7 @@ dependencies = [ "clap", "colored", "indicatif", + "rand", "serde", "serde_yaml", ] diff --git a/Cargo.toml b/Cargo.toml index 131e902..768f6b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ authors = ["lukas-sgx "] clap = { version = "4.6.6", features = ["derive"] } colored = "3.1.1" indicatif = "0.18.6" +rand = "0.10.2" serde = { version = "1.0", features = ["derive"] } serde_yaml = "0.9" diff --git a/release-config.json b/release-config.json new file mode 100644 index 0000000..10857e8 --- /dev/null +++ b/release-config.json @@ -0,0 +1,16 @@ +{ + "packages": { + ".": { + "release-type": "rust", + "prerelease": true, + "prerelease-type": "alpha", + "changelog-sections": [ + { "type": "feat", "section": "New APIs / Features" }, + { "type": "fix", "section": "Bug Fixes" }, + { "type": "feat!", "section": "Breaking Changes / Features" }, + { "type": "fix!", "section": "Breaking Changes / Bug Fixes" }, + { "type": "chore", "hidden": true } + ] + } + } +} \ No newline at end of file diff --git a/release.config.js b/release.config.js deleted file mode 100644 index 0e0d243..0000000 --- a/release.config.js +++ /dev/null @@ -1,37 +0,0 @@ -module.exports = { - branches: [ - "stable", - { name: 'staging', prerelease: 'alpha' } - ], - plugins: [ - ['@semantic-release/commit-analyzer', { - preset: 'conventionalcommits', - releaseRules: [ - { type: 'feat!', release: 'major' }, - { type: 'fix!', release: 'major' } - ] - }], - - ['@semantic-release/release-notes-generator', { - preset: 'conventionalcommits', - presetConfig: { - types: [ - { type: 'feat', section: 'New APIs / Features', hidden: false }, - { type: 'fix', section: 'Bug Fixes', hidden: false }, - { type: 'feat!', section: 'Breaking Changes / Features', hidden: false }, - { type: 'fix!', section: 'Breaking Changes / Bug Fixes', hidden: false }, - { type: 'chore', hidden: true } - ] - } - }], - - ["@semantic-release-cargo/semantic-release-cargo"], - - ['@semantic-release/git', { - assets: ['Cargo.toml', 'Cargo.lock'], - message: 'chore(release): v${nextRelease.version} [skip ci]' - }], - - '@semantic-release/github' - ] -}; diff --git a/src/commands/runner.rs b/src/commands/runner.rs index e66db9c..f8bc4d5 100644 --- a/src/commands/runner.rs +++ b/src/commands/runner.rs @@ -1,45 +1,51 @@ -use std::{fs, io, path::Path}; - -use crate::{modules, status}; - -fn get_github_workflows() -> io::Result> { - let path = Path::new(".github/workflows"); - - if !path.exists() { - return Ok(vec![]); - } - - let entries = fs::read_dir(path)?; - - let workflows = entries - .filter_map(|entry| { - let path = entry.ok()?.path(); - - if path.is_file() { - let ext = path.extension()?.to_str()?; - if ext == "yml" || ext == "yaml" { - return Some(path.display().to_string()); - } - } - None - }) - .collect(); - - Ok(workflows) +use indicatif::{MultiProgress, ProgressBar}; + +use crate::{commands::check::workflows, modules::parser::GitHubWorkflow, status}; +use core::time; +use std::{ + sync::{self, Arc}, + thread, +}; + +// fn set_time_duration(msg: String) {} + +fn launch_workflow(workflow: &Arc, pb: &ProgressBar) { + let data = sync::Mutex::from(workflow); + let _res = data.try_lock(); + + thread::sleep(time::Duration::from_secs(rand::random_range(0..13))); + let msg = format!( + "Job `{}` done...", + workflow.name.as_deref().unwrap_or_default() + ); + pb.finish_with_message(msg); } pub fn handle(dry_run: bool, _jobs: u32) { - let workflows = get_github_workflows(); - let pb = status::new_progress("Parse all workflow files"); - - for workflow in workflows.unwrap_or_default() { - let workflow_item = modules::parser::workflow_file(&workflow); - - println!("{:?}", workflow_item.unwrap().on); - } - pb.finish_and_clear(); - if dry_run { - return; + if let Some(workflows) = workflows() { + if dry_run { + return; + } + + let mb = MultiProgress::new(); + let mut handles = vec![]; + + for workflow in workflows { + let workflow = Arc::new(workflow); + let name = format!( + "Waiting `{}` ...", + workflow.name.as_deref().unwrap_or_default() + ); + let pb = status::new_progress_attach_multi(&mb, name); + let subthread = thread::spawn(move || { + launch_workflow(&workflow, &pb); + }); + + handles.push(subthread); + } + + for handle in handles { + handle.join().unwrap(); + } } - println!("next part"); }