Skip to content

Commit

Permalink
Publish libms to GitHub package registry (#239)
Browse files Browse the repository at this point in the history
  - Adds github actions to publish library microservice to github packages
  - Updates READMEs for library microservice

---------
Co-authored-by: Mads Kelberg <[email protected]>
Co-authored-by: prasadtalasila <[email protected]>
Co-authored-by: lindot09 <[email protected]>
  • Loading branch information
lindot11 authored Nov 9, 2023
1 parent a70a726 commit eabea7f
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 44 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/lib-ms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,42 @@ jobs:
with:
files: servers/lib/coverage/clover.xml
flags: lib-microservice-tests

publish-package:

if: |
github.event_name == 'push' &&
(startsWith(github.ref, 'refs/heads/feature/') || startsWith(github.ref, 'refs/heads/release-v'))
name: Publish to GitHub Packages
runs-on: ubuntu-latest
needs: test-lib-ms
permissions:
packages: write
contents: read

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
cache: "yarn"
cache-dependency-path: "**/yarn.lock"
always-auth: true
registry-url: 'https://npm.pkg.github.com/'

- name: Publish package
run: |
cd servers/lib
yarn install
yarn build
yarn publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}




52 changes: 52 additions & 0 deletions servers/lib/DEVELOPER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Developer Instructions

## :gear: Configuration

This microservice needs library assets and configuration
file. Please see [README](./README.md) for this information.

## :hammer_and_wrench: Developer Commands

```bash
yarn install # Install dependencies for the microservice
yarn syntax # analyzes source code for potential errors, style violations, and other issues,
yarn graph # generate dependency graphs in the code
yarn build # compile ES6 files into ES5 javascript files and copy them into dist/ directory
yarn test -a # run all tests
yarn test -e # run end-to-end tests
yarn test -i # run integration tests
yarn test -u # run unit tests
yarn start # start the application
yarn start -h # list of all the CLI commands
yarn clean # deletes directories "build", "coverage", and "dist"
```

## :package: :ship: NPM package

Use the instructions in
[publish npm package](../../docs/developer/npm-packages.md) for help
with publishing **libms npm package**.

Application of the advice given on that page for **libms** will require
running the following commands.

### Publish

```bash
yarn install
yarn build #the dist/ directory is needed for publishing step
yarn publish --no-git-tag-version #increments version in package.json, publishes to registry
yarn publish #increments version in package.json, publishes to registry and adds a git tag
```

### Unpublish

```bash
npm unpublish --registry http://localhost:4873/ @dtaas/[email protected]
```

## Service Endpoint

The URL endpoint for this microservice is located at: `localhost:PORT/lib`

The [API](./API.md) page shows sample queries and responses.
66 changes: 25 additions & 41 deletions servers/lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,31 @@ It has three features:

For this microserivce to be functional,
a certain directory or gitlab project structure is expected.
The microservice expects that the gitlab consisting of one group, DTaaS,
The microservice expects that the gitlab consisting of one group, dtaas (by convention),
and within that group, all of the projects be located,
**user1**, **user2**, ... , as well as a **commons** project.
**user1**, **user2**, ... , as well as a **commons** projects.
Each project corresponds to files of one user.
A sample file structure can be seen in [gitlab dtaas group](https://gitlab.com/dtaas).
You can visit the gitlab documentation on
[groups](https://docs.gitlab.com/ee/user/group/)
for help on the management of gitlab groups.

You can clone the git repositories from the `dtaas` group
You can clone the git repositories from the [gitlab dtaas](https://gitlab.com/dtaas) group
to get a sample file system structure for the lib microservice.

## Configuration setup
## :arrow_down: Install

The microservices uses `.env` environment files to receive configuration.
The package is available in github packages registry.

In order to create this environment, you need to create a `.env` file,
wherein you create the following environment variables,
and insert with the correct-information relevant for your setup:
Set the registry and install the package with the following commands
```bash
sudo npm config set @into-cps-association:registry https://npm.pkg.github.com
sudo npm install -g @into-cps-association/libms
```

## :gear: Configure

The microservices requires config specified in INI format. The template configuration file is:

```env
PORT='4001'
Expand All @@ -53,7 +59,7 @@ For more information on how to create and use your access token,
[gitlab page](https://docs.gitlab.com/ee/user/group/settings/group_access_tokens.html).

Once you've generated a token, copy it and replace
the value of `TOKEN` with your token for the gitlab group, can be found.
the value of `TOKEN` with your token for the gitlab group,

Replace the default values the appropriate values for your setup.

Expand All @@ -66,11 +72,7 @@ Replace the default values the appropriate values for your setup.

## User Commands

```bash
yarn install # Install dependencies for the microservice
yarn build # build the application
yarn start # start the application
```
This config is saved `.env` file by convention. The __libms__ looks for `.env` file in the working directory from which it is run.

If the environment file is named something other than `.env`,
the filename must be specifed with the command `-c, --config <path>`,
Expand All @@ -83,24 +85,12 @@ yarn start -c ".env.development"
You can press `Ctl+C` to halt the application.
If you wish to run the microservice in the background, use

```bash
nohup yarn start & disown
```
## :rocket: Use

## Developer Commands
Display help.

```bash
yarn install # Install dependencies for the microservice
yarn syntax # analyzes source code for potential errors, style violations, and other issues,
yarn graph # generate dependency graphs in the code
yarn build # compile ES6 files into ES5 javascript files and copy them into dist/ directory
yarn test -a # run all tests
yarn test -e # run end-to-end tests
yarn test -i # run integration tests
yarn test -u # run unit tests
yarn start # start the application
yarn start -h # list of all the CLI commands
yarn clean # deletes directories "build", "coverage", and "dist"
libms -h
```

## :package: :ship: NPM package
Expand All @@ -112,23 +102,17 @@ with publishing and using **libms npm package**.
Application of the advice given on that page for **libms** will require
running the following commands.

### Publish

```bash
yarn install
yarn build #the dist/ directory is needed for publishing step
yarn publish --no-git-tag-version #increments version in package.json, publishes to registry
yarn publish #increments version in package.json, publishes to registry and adds a git tag
libms
```

### Unpublish
Run __libms__ with a custom config file.

```bash
npm unpublish --registry http://localhost:4873/ @dtaas/[email protected]
libms -c FILE-PATH
libms --config FILE-PATH
```

## Service Endpoint

The URL endpoint for this microservice is located at: `localhost:PORT/lib`
The microservice is available at: http://localhost:PORT/lib

The [API](./API.md) page shows sample queries and responses.
The [API](https://into-cps-association.github.io/DTaaS/development/user/servers/lib/LIB-MS.html) page shows sample queries and responses.
8 changes: 5 additions & 3 deletions servers/lib/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"name": "@dtaas/libms",
"version": "0.2.0",
"name": "@into-cps-association/libms",
"version": "0.3.1",
"description": "microservices that handles request by fetching and returning the file-names and folders of given directory",
"author": "[email protected]",
"contributors": [
"Prasad Talasila"
"Prasad Talasila",
"Mads Kelberg",
"Linda Nguyen"
],
"private": false,
"license": "SEE LICENSE IN <LICENSE.md>",
Expand Down

0 comments on commit eabea7f

Please sign in to comment.