Git Product home page Git Product logo

scripts's Introduction

The Algorithms Scripts

Internal scripts used across all The Algorithms repositories

build_directory_md.py

This script should be run by a workflow on every push and pr to update the DIRECTORY.md file. It takes the following arguments:

[0] - Language
[1] - Base path
[2] - Allowed filenames
[3] - Files or folders to ignore (optional)
[4] - Folders to ignore, but include children (optional)

For example, the command for the C++ repo would be:

python3 build_directory_md.py C-Plus-Plus . .cpp,.hpp,.h > DIRECTORY.md

Or more advanced, for the MATLAB / Octave repo:

python3 build_directory_md.py MATLAB-Octave . .m - algorithms > DIRECTORY.md

scripts's People

Contributors

alexpantyukhin avatar cclauss avatar maltejur avatar panquesito7 avatar tjgurwara99 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scripts's Issues

directory_md action: failing with `python: can't open file '.../build_directory_md.py': [Errno 2] No such file or directory`

We tried to introduce TheAlgorithms/scripts/directory_md into TheAlgorithms/Ruby with TheAlgorithms/Ruby#209, but after the merge it failed to run with the following error:

python: can't open file '/home/runner/work/Ruby/Ruby/build_directory_md.py': [Errno 2] No such file or directory
GitHub Action log
  • https://github.com/TheAlgorithms/Ruby/actions/runs/5337370931/jobs/9673337632
  • Excerpt:
    # Build Directory step
    Run TheAlgorithms/scripts/directory_md@main
      with:
        language: Ruby
        working-directory: .
        filetypes: .rb
        branch-name: directory-update
    Run echo "/home/runner/work/_actions/TheAlgorithms/scripts/main/directory_md" >> $GITHUB_PATH
      echo "/home/runner/work/_actions/TheAlgorithms/scripts/main/directory_md" >> $GITHUB_PATH
      shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
    Run actions/setup-python@v4
      with:
        python-version: 3.x
        check-latest: false
        token: ***
        update-environment: true
        allow-prereleases: false
    Installed versions
      Successfully set up CPython (3.11.4)
    Run git config --global user.name github-actions[bot]
      git config --global user.name github-actions[bot]
      git config --global user.email '[email protected]'
      shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
      env:
        pythonLocation: /opt/hostedtoolcache/Python/3.11.4/x64
        PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.11.4/x64/lib/pkgconfig
        Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.4/x64
        Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.4/x64
        Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.4/x64
        LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.11.4/x64/lib
    Run # If branch exists, change to that branch to prevent multiple committing/PR creation.
      # If branch exists, change to that branch to prevent multiple committing/PR creation.
      git checkout directory-update || true
      
      python build_directory_md.py Ruby . .rb   > DIRECTORY.md
      shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
      env:
        pythonLocation: /opt/hostedtoolcache/Python/3.11.4/x64
        PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.11.4/x64/lib/pkgconfig
        Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.4/x64
        Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.4/x64
        Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.4/x64
        LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.11.4/x64/lib
    error: pathspec 'directory-update' did not match any file(s) known to git
    python: can't open file '/home/runner/work/Ruby/Ruby/build_directory_md.py': [Errno 2] No such file or directory
    Error: Process completed with exit code 2.
    

After discussing this with @Panquesito7 in the PR, it seems that the GitHub Action needs to be modified, so I am reporting it here. Thanks!

Create a PR instead of pushing directly to the main branch

Description

Most of the main branches are protected, which means the scripts won't be able to push unless they unprotect the branches, which would be 100% not safe, IMO.
To prevent this, we could create a temporary branch and create a PR to perform the changes without removing branch protection.

[DOCS] Add multiple READMEs in their respective folders

Description

Currently, we have a readme where it explains the use of the directory builder.
However, that guide is outdated, and we do not have guides for the other script(s).

I suggest we add a README.md inside their respective folders explaining what it does, how it works, etc..
Let me know your thoughts about this. Thank you. ๐Ÿ™‚

[FEATURE] Add a filename formatter script

Description

There's a filename formatter that's being used already in various repositories, such as
the TypeScript repository repository, the C/C++ repositories, and soon other repositories as well.

This is not a Python script but more of a Bash script, I guess.
What do you think? Should we adjust it and add it to this repository? Thanks.

          IFS=$'\n'
          for fname in `find . -type f -name '*.cpp' -o -name '*.hpp'`
          do
            echo "${fname}"
            new_fname=`echo ${fname} | tr ' ' '_'`
            echo "      ${new_fname}"
            new_fname=`echo ${new_fname} | tr 'A-Z' 'a-z'`
            echo "      ${new_fname}"
            new_fname=`echo ${new_fname} | tr '-' '_'`
            echo "      ${new_fname}"
            if [ ${fname} != ${new_fname} ]
            then
              echo "      ${fname} --> ${new_fname}"
              git "mv" "${fname}" ${new_fname}
            fi
          done

CC: @raklaptudirm, @appgurueu, you might want to check this out as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.