dollar signs everywhere #102
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: bench-test | |
on: [push] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
project: | |
[ | |
commonlibrary_rust_ylong_http, | |
commonlibrary_rust_ylong_json, | |
commonlibrary_rust_ylong_runtime, | |
communication_ipc, | |
hiviewdfx_hilog, | |
hiviewdfx_hisysevent, | |
hiviewdfx_hitrace, | |
request_request, | |
systemabilitymgr_safwk, | |
systemabilitymgr_samgr, | |
] | |
steps: | |
- name: clone repo | |
uses: nick-fields/retry@v3 | |
with: | |
timeout_minutes: 5 | |
max_attempts: 3 | |
retry_on: error | |
command: git clone https://gitee.com/openharmony/${{ matrix.project }}.git | |
- name: initialize counters | |
working-directory: ./${{ matrix.project }} | |
run: | | |
echo "for_loop_count_after=0" >> $GITHUB_ENV | |
echo "for_loop_count_after_in_file=0" >> $GITHUB_ENV | |
echo "iter_count=0" >> $GITHUB_ENV | |
echo "iter_count_after=0" >> $GITHUB_ENV | |
echo "iter_count_in_file=0" >> $GITHUB_ENV | |
echo "iter_count_after_in_file=0" >> $GITHUB_ENV | |
echo "iter_mut_count=0" >> $GITHUB_ENV | |
echo "iter_mut_count_after=0" >> $GITHUB_ENV | |
echo "iter_mut_count_in_file=0" >> $GITHUB_ENV | |
echo "iter_mut_count_after_in_file=0" >> $GITHUB_ENV | |
echo "into_iter_count=0" >> $GITHUB_ENV | |
echo "into_iter_count_after=0" >> $GITHUB_ENV | |
echo "into_iter_count_in_file=0" >> $GITHUB_ENV | |
echo "into_iter_count_after_in_file=0" >> $GITHUB_ENV | |
echo "par_iter_count=0" >> $GITHUB_ENV | |
echo "into_par_iter_count=0" >> $GITHUB_ENV | |
echo "par_iter_mut_count=0" >> $GITHUB_ENV | |
echo "par_iter_count_in_file=0" >> $GITHUB_ENV | |
echo "into_par_iter_count_in_file=0" >> $GITHUB_ENV | |
echo "par_iter_mut_count_in_file=0" >> $GITHUB_ENV | |
- name: count for loops | |
working-directory: ./${{ matrix.project }} | |
shell: bash | |
run: | | |
echo "for_loop_count=0" >> $GITHUB_ENV | |
echo "for_loop_count_in_file=0" >> $GITHUB_ENV | |
find . -type f -name '*.rs' | while read -r file; do | |
echo "Checking $file" | |
$for_loop_count_in_file=$(grep -oE 'for\s+(\([^)]+\)|\w+)\s+in\s+[^{]+' "$file" | wc -l) | |
echo "Count in file: $for_loop_count_in_file" | |
((for_loop_count += $for_loop_count_in_file)) | |
done | |
echo "for loop occurrences: $for_loop_count" | |
- name: count iterator methods | |
working-directory: ./${{ matrix.project }} | |
shell: bash | |
run: | | |
# Initialize counters | |
iter_count=0 | |
iter_mut_count=0 | |
into_iter_count=0 | |
# Iterate over all .rs files in the current directory and subdirectories | |
while read -r file; do | |
echo checking $file | |
# Count occurrences of iterator methods in the current file | |
iter_count_in_file=$(grep -o '\.iter()' "$file" | wc -l) | |
iter_mut_count_in_file=$(grep -o '\.iter_mut()' "$file" | wc -l) | |
into_iter_count_in_file=$(grep -o '\.into_iter()' "$file" | wc -l) | |
# Update total counters | |
((iter_count += iter_count_in_file)) | |
((iter_mut_count += iter_mut_count_in_file)) | |
((into_iter_count += into_iter_count_in_file)) | |
done < <(find . -type f -name '*.rs') | |
# Print results | |
echo ".iter() occurrences: $iter_count" | |
echo ".iter_mut() occurrences: $iter_mut_count" | |
echo ".into_iter() occurrences: $into_iter_count" | |
- name: add Cargo.toml dylint lib link | |
working-directory: ./${{ matrix.project }} | |
run: echo -e "\n[workspace.metadata.dylint]\nlibraries = [\n { git = \"https://github.com/trusted-programming/cargo-mate\"},\n]" >> Cargo.toml | |
- name: add rayon | |
working-directory: ./${{ matrix.project }} | |
shell: bash | |
run: | | |
find . -type f -name "Cargo.toml" | while read -r file; do | |
# Check if there is a [package] section in the file | |
if grep -qE "^\[package\]" "$file"; then | |
# Check if rayon is already in the dependencies | |
if ! grep -qE "^rayon =" "$file"; then | |
# Check if [dependencies] section exists | |
if ! grep -qE "^\[dependencies\]" "$file"; then | |
# Add [dependencies] section at the end of the file | |
echo -e "\n[dependencies]" >> "$file" | |
fi | |
# Add rayon under the [dependencies] line | |
sed -i '/\[dependencies\]/a rayon = "1.8.1"' "$file" | |
fi | |
fi | |
done | |
- name: install dylint | |
run: cargo install cargo-dylint dylint-link | |
- name: lint fix | |
working-directory: ./${{ matrix.project }} | |
continue-on-error: true | |
run: cargo dylint --all --workspace --fix -- --allow-dirty --allow-no-vcs --broken-code --lib | |
- name: cargo check | |
working-directory: ./${{ matrix.project }} | |
continue-on-error: true | |
run: cargo check | |
- name: git diff for .rs files | |
working-directory: ./${{ matrix.project }} | |
run: git diff -- '*.rs' | |
- name: count for loops after tool | |
working-directory: ./${{ matrix.project }} | |
shell: bash | |
run: | | |
while read -r file; do | |
echo "Checking $file" | |
for_loop_count_after_in_file=$(grep -oE 'for\s+(\([^)]+\)|\w+)\s+in\s+[^{]+' "$file" | wc -l) | |
echo "Count in file: $for_loop_count_after_in_file" | |
((for_loop_count_after += for_loop_count_after_in_file)) | |
done < <(find . -type f -name '*.rs') | |
echo "for loop occurrences: $for_loop_count_after" | |
- name: count iterator methods after tool | |
working-directory: ./${{ matrix.project }} | |
shell: bash | |
run: | | |
# Initialize counters | |
iter_count_after=0 | |
iter_mut_count_after=0 | |
into_iter_count_after=0 | |
# Iterate over all .rs files in the current directory and subdirectories | |
while read -r file; do | |
echo checking $file | |
# Count occurrences of iterator methods in the current file | |
iter_count_after_in_file=$(grep -o '\.iter()' "$file" | wc -l) | |
iter_mut_count_after_in_file=$(grep -o '\.iter_mut()' "$file" | wc -l) | |
into_iter_count_after_in_file=$(grep -o '\.into_iter()' "$file" | wc -l) | |
# Update total counters | |
((iter_count_after += iter_count_after_in_file)) | |
((iter_mut_count_after += iter_mut_count_after_in_file)) | |
((into_iter_count_after += into_iter_count_after_in_file)) | |
done < <(find . -type f -name '*.rs') | |
# Print results | |
echo ".iter() occurrences: $iter_count_after" | |
echo ".iter_mut() occurrences: $iter_mut_count_after" | |
echo ".into_iter() occurrences: $into_iter_count_after" | |
- name: par iter count | |
working-directory: ./${{ matrix.project }} | |
shell: bash | |
run: | | |
# Initialize counters | |
par_iter_count=0 | |
into_par_iter_count=0 | |
par_iter_mut_count=0 | |
# Iterate over all .rs files in the current directory and subdirectories | |
while read -r file; do | |
echo checking $file | |
# Count occurrences in the current file | |
par_iter_count_in_file=$(grep -o '\.par_iter()' "$file" | wc -l) | |
into_par_iter_count_in_file=$(grep -o '\.into_par_iter()' "$file" | wc -l) | |
par_iter_mut_count_in_file=$(grep -o '\.par_iter_mut()' "$file" | wc -l) | |
# Update total counters | |
((par_iter_count += par_iter_count_in_file)) | |
((into_par_iter_count += into_par_iter_count_in_file)) | |
((par_iter_mut_count += par_iter_mut_count_in_file)) | |
done < <(find . -type f -name '*.rs') | |
# Print results | |
echo ".par_iter() occurrences: $par_iter_count" | |
echo ".into_par_iter() occurrences: $into_par_iter_count" | |
echo ".par_iter_mut() occurrences: $par_iter_mut_count" |