Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: move to self-hosted #17

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
292 changes: 146 additions & 146 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,69 +7,69 @@ 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
# 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
swarnim-deepsource marked this conversation as resolved.
Show resolved Hide resolved

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
# 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
swarnim-deepsource marked this conversation as resolved.
Show resolved Hide resolved

linux:
runs-on: ubuntu-latest
runs-on: [self-hosted, charmander]
strategy:
matrix:
target: [x86_64, i686]
Expand All @@ -96,44 +96,44 @@ 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
# linux-cross:
# runs-on: [self-hosted, charmander]
# 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
swarnim-deepsource marked this conversation as resolved.
Show resolved Hide resolved

musllinux:
runs-on: ubuntu-latest
runs-on: [self-hosted, charmander]
strategy:
matrix:
target:
Expand Down Expand Up @@ -168,48 +168,48 @@ 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
# musllinux-cross:
# runs-on: [self-hosted, charmander]
# 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
swarnim-deepsource marked this conversation as resolved.
Show resolved Hide resolved

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
Expand All @@ -221,20 +221,20 @@ 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-cross
# twine upload --skip-existing *
# popd
swarnim-deepsource marked this conversation as resolved.
Show resolved Hide resolved
pushd wheels-musllinux
twine upload --skip-existing *
popd
pushd wheels-linux-cross
twine upload --skip-existing *
popd
# pushd wheels-linux-cross
# twine upload --skip-existing *
# popd
swarnim-deepsource marked this conversation as resolved.
Show resolved Hide resolved
pushd wheels-linux
twine upload --skip-existing *
popd
pushd wheels-windows
twine upload --skip-existing *
popd
pushd wheels-macos
twine upload --skip-existing **/*
# pushd wheels-windows
# twine upload --skip-existing *
# popd
# pushd wheels-macos
# twine upload --skip-existing **/*
swarnim-deepsource marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <swarnim@deepsource.io>"]
license-file = "LICENSE"
documentation = "https://docs.rs/dracula"
Expand Down
6 changes: 4 additions & 2 deletions pydracula/src/lib.rs
swarnim-deepsource marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ enum Language {
Python,
Rust,
C,
Go,
Cpp,
Java,
Typescript,
Expand Down Expand Up @@ -104,8 +105,8 @@ fn get_lines_with_executable_code(lang: Language, src: &str) -> Option<Vec<usize
Language::Go => 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]
Expand All @@ -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::<Language>()?;
m.add_class::<Lang>()?;
Ok(())
}