diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml index 86a6210..10989e1 100644 --- a/.github/workflows/build_release.yml +++ b/.github/workflows/build_release.yml @@ -7,69 +7,10 @@ on: workflow_dispatch: jobs: # credits for workflow from https://github.com/messense/crfs-rs/blob/main/.github/workflows/Python.yml - macos: - runs-on: macos-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: 3.9 - architecture: x64 - - uses: dtolnay/rust-toolchain@stable - - name: Build wheels - x86_64 - uses: PyO3/maturin-action@v1 - with: - target: x86_64 - args: --release --out dist-x86-64 -m pydracula/Cargo.toml - - name: Install built wheel - x86_64 - run: | - pip install ./dist-x86-64/pydracula-*.whl --force-reinstall - python -c "import pydracula; pydracula.Lang" - - name: Build wheels - universal2 - uses: PyO3/maturin-action@v1 - with: - args: --release --universal2 --out dist-universal2 -m pydracula/Cargo.toml - - name: Install built wheel - universal2 - run: | - pip install ./dist-universal2/pydracula-*.whl --force-reinstall - python -c "import pydracula; pydracula.Lang" - - name: Upload wheels - uses: actions/upload-artifact@v3 - with: - name: wheels-macos - path: | - dist-x86-64 - dist-universal2 - windows: - runs-on: windows-latest - strategy: - matrix: - target: [x64, x86] - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: 3.9 - architecture: ${{ matrix.target }} - - uses: dtolnay/rust-toolchain@stable - - name: Build wheels - uses: PyO3/maturin-action@v1 - with: - target: ${{ matrix.target }} - args: --release --out dist -m pydracula/Cargo.toml - - name: Install built wheel - run: | - pip install pydracula --no-index --find-links dist --force-reinstall - python -c "import pydracula; pydracula.Lang" - - name: Upload wheels - uses: actions/upload-artifact@v3 - with: - name: wheels-windows - path: dist linux: - runs-on: ubuntu-latest + runs-on: [self-hosted, charmander] strategy: matrix: target: [x86_64, i686] @@ -96,44 +37,9 @@ jobs: # credits for workflow from https://github.com/messense/crfs-rs/blob/main/ name: wheels-linux path: dist - linux-cross: - runs-on: ubuntu-latest - strategy: - matrix: - target: [aarch64, armv7, s390x, ppc64le, ppc64] - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: 3.9 - - name: Build wheels - uses: PyO3/maturin-action@v1 - with: - target: ${{ matrix.target }} - manylinux: auto - args: --release --out dist -m pydracula/Cargo.toml - - uses: uraimo/run-on-arch-action@v2.5.0 - if: matrix.target != 'ppc64' - name: Install built wheel - with: - arch: ${{ matrix.target }} - distro: ubuntu20.04 - githubToken: ${{ github.token }} - install: | - apt-get update - apt-get install -y --no-install-recommends python3 python3-pip - pip3 install -U pip - run: | - pip3 install ./dist/pydracula-*.whl --force-reinstall - python3 -c "import pydracula; pydracula.Lang" - - name: Upload wheels - uses: actions/upload-artifact@v3 - with: - name: wheels-linux-cross - path: dist musllinux: - runs-on: ubuntu-latest + runs-on: [self-hosted, charmander] strategy: matrix: target: @@ -168,48 +74,11 @@ jobs: # credits for workflow from https://github.com/messense/crfs-rs/blob/main/ name: wheels-musllinux path: dist - musllinux-cross: - runs-on: ubuntu-latest - strategy: - matrix: - platform: - - target: aarch64-unknown-linux-musl - arch: aarch64 - - target: armv7-unknown-linux-musleabihf - arch: armv7 - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: 3.9 - - name: Build wheels - uses: PyO3/maturin-action@v1 - with: - target: ${{ matrix.platform.target }} - manylinux: musllinux_1_2 - args: --release --out dist -m pydracula/Cargo.toml - - uses: uraimo/run-on-arch-action@v2.5.0 - name: Install built wheel - with: - arch: ${{ matrix.platform.arch }} - distro: alpine_latest - githubToken: ${{ github.token }} - install: | - apk add py3-pip - pip3 install -U pip - run: | - pip install ./dist/pydracula-*.whl --force-reinstall - python -c "import pydracula; pydracula.Lang" - - name: Upload wheels - uses: actions/upload-artifact@v3 - with: - name: wheels-musllinux-cross - path: dist release: name: Release - runs-on: ubuntu-latest - needs: [ macos, windows, linux, linux-cross, musllinux, musllinux-cross ] + runs-on: [self-hosted, charmander] + needs: [ linux, musllinux ] steps: - uses: actions/download-artifact@v3 # download all artifacts - uses: actions/setup-python@v4 @@ -221,20 +90,9 @@ jobs: # credits for workflow from https://github.com/messense/crfs-rs/blob/main/ TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | pip install --upgrade twine - pushd wheels-musllinux-cross - twine upload --skip-existing * - popd pushd wheels-musllinux twine upload --skip-existing * popd - pushd wheels-linux-cross - twine upload --skip-existing * - popd pushd wheels-linux twine upload --skip-existing * popd - pushd wheels-windows - twine upload --skip-existing * - popd - pushd wheels-macos - twine upload --skip-existing **/* diff --git a/Cargo.lock b/Cargo.lock index 8292089..a77a162 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,7 +40,7 @@ checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" [[package]] name = "cdracula" -version = "0.1.3" +version = "0.2.0-1" dependencies = [ "dracula", ] @@ -99,7 +99,7 @@ checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" [[package]] name = "dracula" -version = "0.1.3" +version = "0.2.0-1" dependencies = [ "letr", "log", @@ -307,7 +307,7 @@ dependencies = [ [[package]] name = "pydracula" -version = "0.1.3" +version = "0.2.0-1" dependencies = [ "dracula", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index b6027ba..e52f650 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = ["cdracula", "pydracula"] [workspace.package] edition = "2021" description = "🧛 Count-ing lines, AH AH AHH!" -version = "0.2.0" +version = "0.2.0-1" authors = ["Swarnim Arun "] license-file = "LICENSE" documentation = "https://docs.rs/dracula" diff --git a/pydracula/src/lib.rs b/pydracula/src/lib.rs index bc02aff..9b1ba2c 100644 --- a/pydracula/src/lib.rs +++ b/pydracula/src/lib.rs @@ -15,6 +15,7 @@ enum Language { Python, Rust, C, + Go, Cpp, Java, Typescript, @@ -104,8 +105,8 @@ fn get_lines_with_executable_code(lang: Language, src: &str) -> Option TreeSitterLanguage::Go, }; Parser::new(treesitter_lang) - .and_then(|parser| parser.non_executable_src_spans(src)) - .map(|spans| get_lines_without_ranges(src, &spans)) + .and_then(|mut parser| parser.non_executable_src_spans(src)) + .map(|spans| get_lines_without_ranges(src, spans)) } #[pyfunction] @@ -125,6 +126,7 @@ fn pydracula(_py: Python<'_>, m: &types::PyModule) -> PyResult<()> { m.add_function(wrap_pyfunction!(get_cleaned_source_code, m)?)?; m.add_function(wrap_pyfunction!(get_count_of_meaningful_lines, m)?)?; m.add_function(wrap_pyfunction!(get_lines_with_executable_code, m)?)?; + m.add_class::()?; m.add_class::()?; Ok(()) } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 271800c..d0b271d 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "nightly" \ No newline at end of file +channel = "nightly-2023-06-28" \ No newline at end of file