From a830d5ddb54284002794e52ccafd7a3e2ec45603 Mon Sep 17 00:00:00 2001 From: Mark Joshwel Date: Mon, 29 Jul 2024 22:08:56 +0800 Subject: [PATCH] tooling: linux fixes, add nix flake and workflow --- .github/workflows/sync.yml | 28 +++++++++++++++++ flake.lock | 61 ++++++++++++++++++++++++++++++++++++++ flake.nix | 28 +++++++++++++++++ sidestepper.py | 2 +- sync.py | 4 +-- 5 files changed, 120 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/sync.yml create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml new file mode 100644 index 0000000..1e79d9f --- /dev/null +++ b/.github/workflows/sync.yml @@ -0,0 +1,28 @@ +name: "sync from forge.joshwel.co" +on: + workflow_dispatch: + schedule: + - cron: "0 */6 * * *" +permissions: + contents: write + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v27 + with: + nix_path: nixpkgs=channel:nixos-unstable + github_access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: DeterminateSystems/magic-nix-cache-action@main + + - name: get the forge's repo + run: | + mkdir -p ${{ runner.temp }}/sota + git clone https://forge.joshwel.co/mark/sota ${{ runner.temp }}/sota + + - name: restep + run: | + cd ${{ runner.temp }}/sota + nix develop --command python sync.py diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..240098e --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1722062969, + "narHash": "sha256-QOS0ykELUmPbrrUGmegAUlpmUFznDQeR4q7rFhl8eQg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b73c2221a46c13557b1b3be9c2070cc42cf01eb3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..fdc37f2 --- /dev/null +++ b/flake.nix @@ -0,0 +1,28 @@ +{ + description = "flake for running the sota staircase ReStepper"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + with pkgs; { + devShells.default = mkShellNoCC { + buildInputs = [ + git + git-lfs + git-filter-repo + (python312.withPackages (python-pkgs: [ + python-pkgs.tqdm + python-pkgs.gitignore-parser + ])) + ]; + }; + } + ); +} diff --git a/sidestepper.py b/sidestepper.py index 12ce67c..43baf61 100644 --- a/sidestepper.py +++ b/sidestepper.py @@ -92,7 +92,7 @@ def run( try: cp = _run( command, - shell=True if isinstance(command, list) else False, + shell=False if isinstance(command, list) else True, cwd=cwd, capture_output=capture_output, input=give_input.encode() if give_input else None, diff --git a/sync.py b/sync.py index 7f45975..3505ece 100644 --- a/sync.py +++ b/sync.py @@ -215,7 +215,7 @@ def post_filter_repo_check(cp: CompletedProcess) -> CompletedProcess: # install git-filter-repo pip_invocation: list[str] = ["pipx"] if use_pipx else [executable, "-m", "pip"] print( - f"running '{' '.join([*pip_invocation, "install", "git-filter-repo"])}'... ", + f"running '{' '.join([*pip_invocation, 'install', 'git-filter-repo'])}'... ", end="", flush=True, ) @@ -571,7 +571,7 @@ def main() -> None: ) def add_and_commit() -> CompletedProcess: - cp = cmd("git add *")() + cp = cmd("git add -A")() if cp.returncode != 0: return cp return cmd(