Skip to content

Commit

Permalink
Added Publish gem action
Browse files Browse the repository at this point in the history
  • Loading branch information
George Dias committed May 19, 2022
1 parent 0ddedab commit 1d22768
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 46 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
name: "CodeQL"

on:
# push:
# branches: [ main ]
push:
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/generate_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Generate eMASS Documentation

# Run on each push to main
on:
# push:
# branches: [ main ]
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Deploy to GitHub Pages
on:
# push:
# branches: [ main ]
push:
branches: [ main ]
pull_request:
branches: [ main ]

Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/publish-gem.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build and release gem

on:
release:
types: [published]

jobs:
release:
name: Release to gem hosts
runs-on: ubuntu-latest
steps:
- name: Setup ruby
uses: actions/setup-ruby@v1
- uses: actions/checkout@v2
with:
fetch-depth: 0
- run: git fetch origin +refs/tags/*:refs/tags/*
- name: Setup credentials and versioning
run: |
gem install keycutter
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}\n" > $HOME/.gem/credentials
printf -- ":github: Bearer ${GPR_API_KEY}\n" >> $HOME/.gem/credentials
env:
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
GPR_API_KEY: ${{secrets.GITHUB_TOKEN}}
- name: Build emass_client
run: gem build -C src/ruby_client/ emass_client.gemspec
- name: Publish to RubyGems
run: |
gem push --KEY rubygems --host https://rubygems.org src/ruby_client/*.gem
- name: Publish to GPR
run: |
gem push --KEY github --host https://rubygems.pkg.github.com/mitre src/ruby_client/*.gem
env:
OWNER: mitre
4 changes: 2 additions & 2 deletions .github/workflows/test-ruby-client.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Test Ruby Client

on:
# push:
# branches: [ main ]
push:
branches: [ main ]
pull_request:
branches: [ main ]

Expand Down
44 changes: 6 additions & 38 deletions docs/developers.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
# Developers Instructions

The documentation provided here is an OpenAPI (v3.0.3) Specification compliant describing, producing, consuming, and visualizing the eMASS RESTful API web services (endpoints) as described in the eMASS REST API (v3.2) document, dated October 21, 2021.
The documentation provided here is an OpenAPI (v3.0.3) Specification compliant describing, producing, consuming, and visualizing the eMASS RESTful API web services (endpoints) as described by the eMASS REST API (v3.3) document, dated March 26, 2022.

The API is documented in YAML and can be viewed utilizing Swagger Editor or Visual Studio Code (VSC) with swagger and yaml extensions.

The API clients are generated utilizing the [OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator) CLI.


### Viewing the API via Swagger

There are online tool options for viewing and editing OpenAPI compliant RESTfull APIs like the eMASS API documentations. Some of these tools are Swagger Editor or SwaggerHub. <strong>We discourage the utilization of any online capability for editing a controlled unclassified API document</strong>.

To install the Swagger Editor offline from its repository follow these [instructions](https://github.com/swagger-api/swagger-editor).

### Generate the API documentation (to view in a web browser-html)
eMASS API documentation can be found [here](/docs/redoc/index.html)
eMASS API documentation can be found [here](https://mitre.github.io/emass_client/docs/redoc/)

To generate the API documentation that can be viewable in a totally dependency-free (and nice looking) HTML use the `redoc-cli` command line tool.
To generate the API documentation, viewable on a dependency-free (and nice looking) HTML use the `redoc-cli` command line tool.


Install the tool via `npm`:
Expand All @@ -28,7 +25,7 @@ To generate the HTML document, use the following command:
redoc-cli bundle -o ./output/eMASS.html eMASSRestOpenApi.yaml
```

The command above assumes that the generated file is placed in a subfolder relative to the current folder called output, and that the eMASSRestApi.yaml is in the current working directory. The generated file is called eMASS.html and can be viewed in any web browser.
The command above places the generated HTML file (eMASS.html) in a subfolder called output. The command assumes that the eMASSRestApi.yaml is in the current working directory. The generated file can be viewed in any web browser.

### Setting up Visual Studio Code
Install these Extensions (Ctrl+Shift+X):
Expand Down Expand Up @@ -67,39 +64,10 @@ curl -X GET "http://localhost:4010/api/systems?policy=rmf" -H "accept: applicat
```
Note: The API expects the api-key and user-uid headers.

## Swagger Codegen
### Clone the source code
Follow these instruction to generate the eMASS client API library (software development kit - SDK):
``` git
git clone https://github.com/swagger-api/swagger-codegen
cd swagger-codegen
git checkout 3.0.0
mvn clean package
```
Alternatively, you can follow instruction listed in [Swagger Codegen](https://github.com/swagger-api/swagger-codegen/tree/3.0.0#getting-started). The eMASS API utilized the OpenAPI version 3.0 standards, ensure that the proper `Swagger Codegen` is utilized to generate the client SDK.


### Build the Client SDK
The API clients are generated utilizing the [OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator) CLI.

NOTE: The current [handlebar templates](https://github.com/swagger-api/swagger-codegen/tree/3.0.0#modifying-the-client-library-format) do not provide a configuration variable where a keypassword can be defined containing the client certificate passphrase used by libcurl wrapper Typhoeus. For this reason, we have provided [updated templates](./swagger-codegen/ruby_template) that can be utilized in the interim until the necessary fixes are integrated into the [main repository](https://github.com/swagger-api/swagger-codegen/tree/3.0.0)

After cloning the appropriate `Swagger Codegen` baseline (3.0.0) generate the SDK (make sure you are in the cloned directory, e.g; /path/to/codegen/swagger-codegen)

To generate the client SDK with provided templates use:
``` node
java -jar swagger-codegen-cli generate generate -i /path/to/yaml/eMASSRestOpenApi.yaml -l ruby -t emass_client/swagger-codegen/ruby_template -o /path/to/sdk/emass_api_client
```


To generate without specifying the templates use:
``` node
java -jar swagger-codegen-cli generate -i /path/to/yaml/eMASSRestOpenApi.yaml -l ruby -o /path/to/sdk/emass_api_client
```
Note: The command listed above is for generating a ruby client SDK. Other languages are available, see instructions [here](https://github.com/swagger-api/swagger-codegen/tree/3.0.0#to-generate-a-sample-client-library)

## Ruby Client
Information about the swagger generated ruby client SDK refer to the [ruby_client](./ruby_client) directory.

**Note:** Currently there are two (2) client SDKs (ruby, and typscript-axios) that are automatically generated utilizing the GitHub action implemented within this repository. The are generated when a push to main occurs and the API specification files has been modified.

---

Expand Down

0 comments on commit 1d22768

Please sign in to comment.