From b9490dbfd132a6103577663eadb4b79d56766e04 Mon Sep 17 00:00:00 2001 From: Gedeon Sainrival Date: Mon, 14 Nov 2022 11:18:04 -0500 Subject: [PATCH 01/14] feat: add Rust workflow to build.yml --- .github/workflows/build.yml | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dd86f8a..a2269c7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,7 @@ jobs: compile_exec: name: Compile to executables runs-on: ${{ matrix.config.os }} - if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/rewrite' # just to see if it works strategy: matrix: config: @@ -13,14 +13,20 @@ jobs: - os: windows-latest steps: - uses: actions/checkout@v3 - - name: Setup python - uses: actions/setup-python@v3 + - name: Setup Rust + - uses: actions-rs/toolchain@v1 with: - python-version: '3.9' - - name: Install dependencies for ${{ matrix.config.os }} - run: | - python -m pip install --upgrade pip wheel setuptools - pip install -r requirements.txt - pip install pyinstaller - - name: Build with pyinstaller for ${{ matrix.config.os }} - run: pyinstaller popcorn.spec \ No newline at end of file + toolchain: stable + + - name: Install dependencies on Ubuntu + if: startsWith(matrix.config.os, 'ubuntu') + run: sudo apt-get update && sudo apt-get install cmake pkg-config libgtk-3-dev + + - name: Update toolchain + run: rustup update + + - name: Cache dependencies + uses: Swatinem/rust-cache@v2 + + - name: Build with Cargo + run: cargo build \ No newline at end of file From 797a4e52b6b7b3d39851b3af4c2e01cfb9cff95c Mon Sep 17 00:00:00 2001 From: Gedeon Sainrival Date: Mon, 14 Nov 2022 11:38:05 -0500 Subject: [PATCH 02/14] feat: I think I did this workflow right --- .github/workflows/compile_and_release.yml | 40 +++++++++++++++++------ 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/.github/workflows/compile_and_release.yml b/.github/workflows/compile_and_release.yml index d745fc7..2be8bf0 100644 --- a/.github/workflows/compile_and_release.yml +++ b/.github/workflows/compile_and_release.yml @@ -54,17 +54,37 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 # [!] we need to checkout with tags and commit history - - name: Setup python - uses: actions/setup-python@v3 + - uses: actions/checkout@v3 + - name: Setup Rust + - uses: actions-rs/toolchain@v1 with: - python-version: '3.9' - - name: Install dependencies for ${{ matrix.config.os }} - run: | - python -m pip install --upgrade pip wheel setuptools - pip install -r requirements.txt - pip install pyinstaller - - name: Build with pyinstaller for ${{ matrix.config.os }} - run: pyinstaller popcorn.spec + toolchain: stable + + - name: Install dependencies on Ubuntu + if: startsWith(matrix.config.os, 'ubuntu') + run: sudo apt-get update && sudo apt-get install cmake pkg-config libgtk-3-dev + + - name: Build with Cargo for ${{ matrix.config.os }} + if: startsWith(matrix.config.os, 'ubuntu') + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: x86_64-unknown-linux-gnu + run: cargo build --release --target $TARGET + + if: startsWith(matrix.config.os, 'macos') + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: x86_64-apple-darwin # will probably have to change this around to accomodate for M1 & M2 + run: cargo build --release --target $TARGET + + if: startsWith(matrix.config.os, 'windows') # not sure if a target is needed here + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + run: cargo build --release + - name: Copy files to be compressed run: | cp README.md ./dist From 7db06afa0f4d15967d509271d657b823019c8ca9 Mon Sep 17 00:00:00 2001 From: Gedeon Sainrival Date: Mon, 14 Nov 2022 12:20:08 -0500 Subject: [PATCH 03/14] this might fix it tbh --- .github/workflows/compile_and_release.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/compile_and_release.yml b/.github/workflows/compile_and_release.yml index 2be8bf0..96d6419 100644 --- a/.github/workflows/compile_and_release.yml +++ b/.github/workflows/compile_and_release.yml @@ -54,9 +54,8 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 # [!] we need to checkout with tags and commit history - - uses: actions/checkout@v3 - name: Setup Rust - - uses: actions-rs/toolchain@v1 + uses: actions-rs/toolchain@v1 with: toolchain: stable From d0e746ad7f38960898282468c4b2682be9d9b7b1 Mon Sep 17 00:00:00 2001 From: Gedeon Sainrival Date: Mon, 14 Nov 2022 12:20:25 -0500 Subject: [PATCH 04/14] feat: linting should work --- .github/workflows/main.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d7ed1c9..9745350 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,13 +5,13 @@ jobs: runs-on: ubuntu-latest name: CI workflow steps: - - name: checkout source repo - uses: actions/checkout@v2 + - name: checkout source repo + uses: actions/checkout@v2 - - name: linting - uses: programmingwithalex/pylinters@v1.4.2 - with: - python-root: '.' - flake8-flags: '--max-line-length 120' - mypy-flags: '--ignore-missing-imports --install-types --non-interactive' - fail-on-isort: true \ No newline at end of file + - name: linting + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + components: rustfmt, clippy + command: clean From 4f3b55c932a910f86013be3be5746e44084a7e04 Mon Sep 17 00:00:00 2001 From: Gedeon Sainrival Date: Mon, 14 Nov 2022 12:23:09 -0500 Subject: [PATCH 05/14] command doesn't exist in toolchain action --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9745350..cee04e4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,4 +14,4 @@ jobs: toolchain: stable override: true components: rustfmt, clippy - command: clean + run: cargo clean From 79d1db3b4def87e0a7c3a6daf0cde2b1f8ca829a Mon Sep 17 00:00:00 2001 From: Gedeon Sainrival Date: Mon, 14 Nov 2022 12:26:23 -0500 Subject: [PATCH 06/14] fix: should clean now --- .github/workflows/main.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cee04e4..2eb96bd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,10 +8,14 @@ jobs: - name: checkout source repo uses: actions/checkout@v2 - - name: linting + - name: setup Rust uses: actions-rs/toolchain@v1 with: toolchain: stable override: true components: rustfmt, clippy - run: cargo clean + + - name: Run cargo clean + uses: actions-rs/cargo@v1 + with: + command: clean From 8db20c7a16acd9632f39a293f2b11afa98419c4b Mon Sep 17 00:00:00 2001 From: Gedeon Sainrival Date: Mon, 14 Nov 2022 12:31:07 -0500 Subject: [PATCH 07/14] fix: Should build now --- .github/workflows/compile_and_release.yml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/compile_and_release.yml b/.github/workflows/compile_and_release.yml index 96d6419..72e7746 100644 --- a/.github/workflows/compile_and_release.yml +++ b/.github/workflows/compile_and_release.yml @@ -69,21 +69,34 @@ jobs: with: toolchain: stable target: x86_64-unknown-linux-gnu - run: cargo build --release --target $TARGET + + uses: actions-rs/cargo@v1 + with: + command: build + args: --release --target ${{with.target}} + if: startsWith(matrix.config.os, 'macos') uses: actions-rs/toolchain@v1 with: toolchain: stable target: x86_64-apple-darwin # will probably have to change this around to accomodate for M1 & M2 - run: cargo build --release --target $TARGET + + uses: actions-rs/cargo@v1 + with: + command: build + args: --release --target ${{with.target}} if: startsWith(matrix.config.os, 'windows') # not sure if a target is needed here uses: actions-rs/toolchain@v1 with: toolchain: stable - run: cargo build --release - + + uses: actions-rs/cargo@v1 + with: + command: build + args: --release + - name: Copy files to be compressed run: | cp README.md ./dist From 39cd2bb166c82936d1bda03158e5a7bacabe07ca Mon Sep 17 00:00:00 2001 From: Gedeon Sainrival Date: Mon, 14 Nov 2022 12:32:53 -0500 Subject: [PATCH 08/14] fix: finally should be done --- .github/workflows/build.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a2269c7..bc1648d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -on: ['push', 'pull_request'] +on: ["push", "pull_request"] jobs: compile_exec: @@ -17,16 +17,19 @@ jobs: - uses: actions-rs/toolchain@v1 with: toolchain: stable - + - name: Install dependencies on Ubuntu if: startsWith(matrix.config.os, 'ubuntu') run: sudo apt-get update && sudo apt-get install cmake pkg-config libgtk-3-dev - name: Update toolchain - run: rustup update - + run: rustup update + - name: Cache dependencies - uses: Swatinem/rust-cache@v2 - + uses: Swatinem/rust-cache@v2 + - name: Build with Cargo - run: cargo build \ No newline at end of file + uses: actions-rs/cargo@v1 + with: + command: build + args: --release From 0121cdce0b6b1ad2bcf7811797b56c12dab07ffa Mon Sep 17 00:00:00 2001 From: Gedeon Sainrival Date: Mon, 14 Nov 2022 12:35:41 -0500 Subject: [PATCH 09/14] fix: extra hyphen removed --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bc1648d..cb7dd17 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Setup Rust - - uses: actions-rs/toolchain@v1 + uses: actions-rs/toolchain@v1 with: toolchain: stable From 32489f95eb101109effb9d1dff7f16a2dab000c3 Mon Sep 17 00:00:00 2001 From: Gedeon Sainrival Date: Mon, 14 Nov 2022 12:57:28 -0500 Subject: [PATCH 10/14] add windows target --- .github/workflows/compile_and_release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/compile_and_release.yml b/.github/workflows/compile_and_release.yml index e1e4a21..6726bd5 100644 --- a/.github/workflows/compile_and_release.yml +++ b/.github/workflows/compile_and_release.yml @@ -91,11 +91,12 @@ jobs: uses: actions-rs/toolchain@v1 with: toolchain: stable + target: x86_64-pc-windows-msvc uses: actions-rs/cargo@v1 with: command: build - args: --release + args: --release --target ${{with.target}} - name: Copy files to be compressed run: | From d3a4ea3fd8b66e40c043ff3992c8b0953d01e332 Mon Sep 17 00:00:00 2001 From: Gedeon Sainrival Date: Mon, 14 Nov 2022 13:00:24 -0500 Subject: [PATCH 11/14] attempt to add aarch64 target --- .github/workflows/compile_and_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compile_and_release.yml b/.github/workflows/compile_and_release.yml index 6726bd5..287e1b6 100644 --- a/.github/workflows/compile_and_release.yml +++ b/.github/workflows/compile_and_release.yml @@ -80,7 +80,7 @@ jobs: uses: actions-rs/toolchain@v1 with: toolchain: stable - target: x86_64-apple-darwin # will probably have to change this around to accomodate for M1 & M2 + target: [x86_64-apple-darwin, aarch64-apple-darwin] # will probably have to change this around to accomodate for M1 & M2 uses: actions-rs/cargo@v1 with: From 4d1f62db2443463829711ccfb79ae8b4e6b45a87 Mon Sep 17 00:00:00 2001 From: Gedeon Sainrival Date: Mon, 14 Nov 2022 13:07:10 -0500 Subject: [PATCH 12/14] no multiple targets --- .github/workflows/compile_and_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compile_and_release.yml b/.github/workflows/compile_and_release.yml index 287e1b6..1fcbf7c 100644 --- a/.github/workflows/compile_and_release.yml +++ b/.github/workflows/compile_and_release.yml @@ -80,7 +80,7 @@ jobs: uses: actions-rs/toolchain@v1 with: toolchain: stable - target: [x86_64-apple-darwin, aarch64-apple-darwin] # will probably have to change this around to accomodate for M1 & M2 + target: aarch64-apple-darwin # will probably have to change this around to accomodate for M1 & M2 uses: actions-rs/cargo@v1 with: From 050544cc066c9a830d440c8dea64e99826ac6651 Mon Sep 17 00:00:00 2001 From: Gedeon Sainrival Date: Wed, 16 Nov 2022 14:40:29 -0500 Subject: [PATCH 13/14] fix: file permissions fix for windows --- src/commands/build/mod.rs | 6 ++++-- src/commands/dev/mod.rs | 5 +++-- src/util.rs | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/commands/build/mod.rs b/src/commands/build/mod.rs index 249a63a..8117078 100644 --- a/src/commands/build/mod.rs +++ b/src/commands/build/mod.rs @@ -10,7 +10,9 @@ use std::process::Command; use std::thread; use std::{fs::create_dir_all, fs::remove_dir_all, path::Path}; -use crate::util::{get_config, Config, Print, DEV_DIR, PATHSEP, PROD_DIR, SEP}; +use crate::util::{ + self, get_config, set_permissions, Config, Print, DEV_DIR, PATHSEP, PROD_DIR, SEP, +}; use super::install::apply_changes; @@ -361,7 +363,7 @@ pub fn build_thread( )) .unwrap() .permissions(); - perms.set_mode(0o511); + set_permissions(&mut perms, 0o511); if perms.mode() != 0o511 { Print::error("Unable to change file permissions."); diff --git a/src/commands/dev/mod.rs b/src/commands/dev/mod.rs index b332eb3..607f42f 100644 --- a/src/commands/dev/mod.rs +++ b/src/commands/dev/mod.rs @@ -3,7 +3,7 @@ use clap::Parser; use notify::{watcher, DebouncedEvent, RecursiveMode, Watcher}; use regex::Regex; -use std::fs::{self, create_dir_all, remove_dir_all, File}; +use std::fs::{self, create_dir_all, remove_dir_all, File, Permissions}; use std::io::Write; use std::os::unix::prelude::PermissionsExt; use std::path::{Path, PathBuf}; @@ -12,6 +12,7 @@ use std::sync::mpsc::channel; use std::time::Instant; use std::{env, thread, time}; +use crate::util::set_permissions; use crate::util::{blame::BLAME, get_config, Config, Print, DEV_DIR, SEP}; use super::build::seed_cmd; @@ -117,7 +118,7 @@ fn dev_compile(config: Config) -> Result<(), ()> { )) .unwrap() .permissions(); - perms.set_mode(0o511); + set_permissions(&mut perms, 0o511); if perms.mode() != 0o511 { Print::error("Unable to change file permissions."); diff --git a/src/util.rs b/src/util.rs index 0f32702..006ea3a 100644 --- a/src/util.rs +++ b/src/util.rs @@ -4,6 +4,7 @@ use console::style; use dirs; use std::collections::hash_map::DefaultHasher; use std::env; +use std::fs::{self, File, Permissions}; use std::hash::{Hash, Hasher}; use serde_derive::{Deserialize, Serialize}; @@ -208,3 +209,22 @@ impl Print { ) } } + +#[cfg(unix)] +pub fn set_permissions(metadata_permissions: &mut Permissions, mode: u32) -> Result<(), ()> { + use std::os::unix::prelude::PermissionsExt; + + metadata_permissions.set_mode(0o511); + + if metadata_permissions.mode() != 0o511 { + Print::error("Unable to change file permissions."); + return Err(()); + } + + Ok(()) +} +#[cfg(not(unix))] +#[allow(unused)] +pub fn set_permissions(metadata_permissions: &Permissions, mode: u32) -> Result<(), ()> { + Ok(()) +} From 408757e0839e9bd48ee0786b81af64adc43d147a Mon Sep 17 00:00:00 2001 From: Gedeon Sainrival Date: Wed, 16 Nov 2022 15:18:53 -0500 Subject: [PATCH 14/14] fix: remove perms.mode if statements --- src/commands/build/mod.rs | 6 ------ src/commands/dev/mod.rs | 6 ------ 2 files changed, 12 deletions(-) diff --git a/src/commands/build/mod.rs b/src/commands/build/mod.rs index 8117078..f9a2d32 100644 --- a/src/commands/build/mod.rs +++ b/src/commands/build/mod.rs @@ -4,7 +4,6 @@ use clap::Parser; use std::env; use std::fs::{self, File, OpenOptions}; use std::io::{prelude::*, BufReader}; -use std::os::unix::prelude::PermissionsExt; use std::path::PathBuf; use std::process::Command; use std::thread; @@ -365,11 +364,6 @@ pub fn build_thread( .permissions(); set_permissions(&mut perms, 0o511); - if perms.mode() != 0o511 { - Print::error("Unable to change file permissions."); - return Err(()); - } - Print::info("Compiled successfully."); match update_path(config.kernel_type.clone(), output.clone()) { diff --git a/src/commands/dev/mod.rs b/src/commands/dev/mod.rs index 607f42f..e923d9a 100644 --- a/src/commands/dev/mod.rs +++ b/src/commands/dev/mod.rs @@ -5,7 +5,6 @@ use notify::{watcher, DebouncedEvent, RecursiveMode, Watcher}; use regex::Regex; use std::fs::{self, create_dir_all, remove_dir_all, File, Permissions}; use std::io::Write; -use std::os::unix::prelude::PermissionsExt; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; use std::sync::mpsc::channel; @@ -120,11 +119,6 @@ fn dev_compile(config: Config) -> Result<(), ()> { .permissions(); set_permissions(&mut perms, 0o511); - if perms.mode() != 0o511 { - Print::error("Unable to change file permissions."); - return Err(()); - } - Ok(()) }