Skip to content

Commit

Permalink
add ci & lint
Browse files Browse the repository at this point in the history
  • Loading branch information
0xbe7a committed Jun 2, 2024
1 parent 193174f commit 113bf46
Show file tree
Hide file tree
Showing 11 changed files with 3,650 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# GitHub syntax highlighting
pixi.lock linguist-language=YAML
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @pavelzw @delsner @0xbe7a
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI
on: [push]

# Automatically stop old builds on the same branch/PR
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
pre-commit-checks:
name: Pre-commit Checks
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Set up pixi
uses: prefix-dev/setup-pixi@ba3bb36eb2066252b2363392b7739741bb777659
with:
environments: default lint
- name: pre-commit
run: pixi run pre-commit-run --color=always --show-diff-on-failure

unit-tests:
name: test
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Set up pixi
uses: prefix-dev/setup-pixi@ba3bb36eb2066252b2363392b7739741bb777659
- name: Install repository
run: pixi run postinstall
- name: Run test
run: pixi run test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,6 @@ env/
unpack/
cache/
activate.*
# pixi environments
.pixi
*.egg-info
55 changes: 55 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
repos:
- repo: local
hooks:
# prettier
- id: prettier
name: prettier
entry: pixi run -e lint prettier --write --list-different --ignore-unknown
language: system
types: [text]
files: \.(md|yml|yaml)$
# pre-commit-hooks
- id: trailing-whitespace-fixer
name: trailing-whitespace-fixer
entry: pixi run -e lint trailing-whitespace-fixer
language: system
types: [text]
- id: end-of-file-fixer
name: end-of-file-fixer
entry: pixi run -e lint end-of-file-fixer
language: system
types: [text]
- id: check-merge-conflict
name: check-merge-conflict
entry: pixi run -e lint check-merge-conflict --assume-in-merge
language: system
types: [text]
# typos
- id: typos
name: typos
entry: pixi run -e lint typos --force-exclude
language: system
types: [text]
require_serial: true
# cargo fmt and clippy
- id: cargo-fmt-conda
name: cargo-fmt-conda
description: "Run `cargo fmt` for formatting rust sources."
entry: cargo fmt --
language: system
require_serial: false
types: [rust]
- id: clippy-conda
name: clippy-conda
description: "Run `clippy` to lint rust sources."
entry: cargo clippy --all-targets --all-features --workspace -- -D warnings
pass_filenames: false
language: system
require_serial: false
types: [rust]
# taplo
- id: taplo
name: taplo
entry: pixi run -e lint taplo format
language: system
types: [toml]
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@
"cwd": "${workspaceFolder}"
}
]
}
}
9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ serde_json = "1.0.117"
serde_yaml = "0.9.34"
tokio-tar = "0.3.1"
tokio = "1.37.0"
tokio-stream = { version = "0.1.15", features = ["fs"]}
tokio-stream = { version = "0.1.15", features = ["fs"] }
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["default", "env-filter"] }
tracing-subscriber = { version = "0.3.18", features = [
"default",
"env-filter",
] }
tracing-log = "0.2"
url = "2.5.0"
async-compression = { version = "0.4.11", features = ["tokio", "zstd"] }
fxhash = "0.2.1"
tempfile = "3.10.1"
tempfile = "3.10.1"
3,513 changes: 3,513 additions & 0 deletions pixi.lock

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[project]
name = "pixi-pack"
version = "0.1.0"
description = "A command line tool to pack and unpack conda environments for easy sharing."
channels = ["conda-forge"]
platforms = ["osx-arm64", "osx-64", "linux-64", "linux-aarch64", "win-64"]

[tasks]
build = "cargo build --release"
test = "cargo test"

[dependencies]
rust = "1.77.2"

[feature.lint.dependencies]
pre-commit = "*"
prettier = "*"
taplo = "*"
pre-commit-hooks = "*"
typos = "*"
[feature.lint.tasks]
pre-commit-install = "pre-commit install"
pre-commit-run = "pre-commit run -a"

[environments]
default = ["lint"]
lint = ["lint"]
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
pub use unpack::{unpack, UnpackOptions};

pub const CHANNEL_DIRECTORY_NAME: &str = "channel";
pub const PIXI_PACK_METADATA_PATH : &str = "pixi-pack.json";
pub const PIXI_PACK_METADATA_PATH: &str = "pixi-pack.json";
pub const DEFAULT_PIXI_PACK_VERSION: &str = "1";

/// The metadata for a "pixi-pack".
Expand Down
4 changes: 2 additions & 2 deletions src/unpack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ async fn unarchive(archive_path: &Path, target_dir: &Path) -> Result<()> {

let reader = tokio::io::BufReader::new(file);

let decocder = ZstdDecoder::new(reader);
let decoder = ZstdDecoder::new(reader);

let mut archive = Archive::new(decocder);
let mut archive = Archive::new(decoder);

archive
.unpack(target_dir)
Expand Down

0 comments on commit 113bf46

Please sign in to comment.