Git Product home page Git Product logo

repository-package-name's Introduction

repository-package-name

image image    

bash-script-tests

Use GraphQL with Bash Script to find and store the Package name of a repository

References

This script is used to retrieve the package name from a specific repository, using the GitHub's GraphQL API. More info about GitHub's graphQL in this link: GraphQL API Documentation. Also, there is the GitHub Explorer where you can write and test your GraphQL queries to the GitHub. More information can be found at the following link: GraphQL Explorer.

Execution of the script

  1. In order to use the script, simply clone the current repo or download as zip file the code and extract the content. Inside the folder repository-package-name there is the main shell script with the name findRepoPackageName.sh, and some other files.

  2. The script takes 3 arguments in order to work properly:
    pathToFolder: which is the path to the project from the Github, from which you want to retrieve the name of package.
    owner: which is the owner of the repository. It could be an organisation or personal account.
    inputToken: a properly configured token from Github which has at least the scope of write:packages, otherwise the API call will not work.

Below there is a board of the possible outcomes for using the findRepoPackageName.sh:

arguments example outcome
none ./findRepoPackageName You should provide the path, the owner of the repo and the token with the correct access rights
pathToProject ownerName ./findRepoPackageName pathToProject username You should provide the token with the correct access rights as the third argument
All arguments provided but not correct ./findRepoPackageName pathToProject username wrongToken The script will return an empty answer, as it couldn't find any packages with those credentials (the token is wrong)
All arguments are correct ./findRepoPackageName pathToProject username correctToken The script will return the package name that it is in the repo that was provided from the path previously

Execute tests locally

In case you want to run the tests locally make sure the shunit2 tool is installed in your machine. To check if it is already installed you can open a new terminal window and execute the following command:

$ cat $(which shunit2) | grep "SHUNIT_VERSION"

If it is installed you will get the following message:

command [ -n "${SHUNIT_VERSION:-}" ] && exit 0
SHUNIT_VERSION='2.1.8'

If it is not installed you will get the following message:

shunit2 not found

In order to install it on Ubuntu or MacOS software environment, you may use the following command in a new terminal window:
Linux\Ubuntu

$ sudo apt-get update
$ sudo apt-get -y install shunit2

MacOS

$ brew install shunit2

Important

The tool brew is assumed that it is already installed in MacOS machine.

After the shunit2 tool is properly installed in your machine, to run the tests execute the following command from the root path of the current project folder:

./tests/test.sh . username githubToken com.test-package.using-java-maven

Replace the username with yours, and the githubToken with the one that you created and at least has the write:packages scope.
Also notice the ., which is preceding the username, and states from the current directory. That's why when you want to add any new scenarios, in order to test them locally you should execute the script from the current's project root folder.
The com.test-package.using-java-maven is a package that was created for testing purposes, e.g. the script runs successfully, finds and returns the proper package.
The package can be found here

repository-package-name's People

Contributors

marrinosnis avatar

Stargazers

Anastasios Melidonis avatar

Watchers

 avatar

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.