Skip to content

Latest commit

 

History

History
155 lines (113 loc) · 4.79 KB

README.dev.md

File metadata and controls

155 lines (113 loc) · 4.79 KB

Developer documentation

This action is written in Typescript and makes use of the Github @actions packages

The underlining design can be found in DESIGN.md.

Requirements

This tool relies on the availability of Node.js and Docker.

Please verify that you have Node.js and the related package manager npm, and docker available on your system. Make sure that the version of Node.js is at least 12.

$ node --version
v14.17.0
$ npm --version
6.14.13
$ docker --version
Docker version 20.10.6, build 370c289

Node.js and npm can be downloaded in one package from nodejs.org. And here are instructions for upgrading Node.js.

Install the dependencies

$ npm install

Build

Build the typescript and package it for distribution

$ npm run build && npm run package

Run unit test

The tests are stored in the directory __tests__ and are written using jestjs.

Run the tests ✔️

$ npm test

 PASS  ./index.test.js
  ✓ throws invalid number (3ms)
  ✓ wait 500 ms (504ms)
  ✓ test runs (95ms)

...

To get information about the test coverage, run the tests with coverage npm test -- --coverage and examine the file coverage/lcov-report/index.html

Linting

The code in the src directory can be linted with:

npm run lint

Formatting

Some of the linting error can be fixed with formatting:

npm run format

Run the analysis

On the current repository

The tool will analyze the license dependencies in current Github repository and store reports of the analyses in the .tortellini/out/ directory.

export INPUT_REPOSITORIES=
export INPUT_CURATIONS=''
export INPUT_CLASSIFICATIONS=https://github.com/NLeSC/tortellini-on-rsd/raw/main/config/license-classifications.yml
export INPUT_RULES=https://github.com/NLeSC/tortellini-on-rsd/raw/main/config/rules.kts
npm install
npm run build
npm run package
node dist/index.js

On other repositories

You can also analyze other repositories on Github by storing their addresses in a file and running node on the file, e.g.:

echo 'https://github.com/tortellini-tools/action' > urls.txt
echo 'https://github.com/fair-software/howfairis' >> urls.txt

The analysis expects a few environment variables. Here are their names and suggested values:

export INPUT_REPOSITORIES=urls.txt
export INPUT_CURATIONS=''
export INPUT_CLASSIFICATIONS=https://github.com/NLeSC/tortellini-on-rsd/raw/main/config/license-classifications.yml
export INPUT_RULES=https://github.com/NLeSC/tortellini-on-rsd/raw/main/config/rules.kts
sudo rm -r .tortellini
mkdir .tortellini
node dist/index.js

The analyses will be stored in the directories .tortellini/out/<owner>/<repository>/ .

How to create a release

  1. Update the citation metadata in CITATION.cff. Afterwards, follow the instructions from the cffconvert workfow to sync the information in .zenodo.json with that in CITATION.cff

  2. Actions are run from GitHub repos so we need to generate the Javascript files in the dist folder and push the results:

    $ cd $(mktemp --directory --tmpdir tortellini-prep-release.XXXXXX)
    $ git clone https://github.com/tortellini-tools/action .
    $ npm install
    $ npm run all
    $ git add dist
    $ git commit --message "prod dependencies"
    $ git push origin main
  3. Next, check if the workflows of the lastest commit on the main branch are green on the action page.

  4. Create a release on the Github page via Create a new release.

  5. On the new release page, for Tag version use v and the next version number, for example v3. See the versioning documentation for more information.

  6. Make sure that usage workflows are using the new version tag and the examples in README.md are updated.

Your action is now published! 🚀

Check if the new version has been published on the Github Marketplace.

You can now validate the action by going to this workflow and this workflow and then clicking on the button Run workflow.