Commit 6cea99b0 authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Adding SOL002-SOL003 scripts and gitlab-ci.yml

parent 1196ab99
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -16,3 +16,12 @@ Build api-tests docker image:
    - changes:
        - api-tests/Dockerfile
        - api-tests/*
        
Build SOL002-SOL003 docker image:
  stage: build
  before_script: cd SOL002-SOL003
  script: docker build -t openapivalidator . #docker build --build-arg http_proxy=$proxy --build-arg https_proxy=$proxy -t openapivalidator .
  rules:
    - changes:
        - SOL002-SOL003/Dockerfile
        - SOL002-SOL003/scripts/*
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
#  - docker:dind

variables:
  GIT_DEPTH: "3"
  PIPELINE_SCRIPTS_PROJECT_ID: 680

stages:
  - build
+32 −0
Original line number Diff line number Diff line
# CI/CD:
#
# VALIDATION triggered by:
#  - any (branch commit)
#  
# GENERATION triggered by:
#  - merge request
#   

workflow:
  rules:
    - if: $CI_COMMIT_BRANCH
    - if: $CI_COMMIT_TAG
    
variables:
  PIPELINE_SCRIPTS_PROJECT_ID: 680

stages:
  - validation
  - generation
  - trigger
        
Validate OpenAPIs:
  stage: validation
  script:
    - echo 'Validate OpenAPIs'
    - docker run -v "$(pwd)":/work -u $(id -u):$(id -g) openapivalidator "/work" "/storage" "$filter"
  artifacts:
    when: on_success
    paths:
      - build/*
  
 No newline at end of file
+34 −0
Original line number Diff line number Diff line
# Copyright ETSI 2017
# See: https://forge.etsi.org/etsi-forge-copyright-statement.txt

FROM alpine:3.10.0

RUN env
RUN apk update
RUN apk add bash
RUN apk add nodejs
RUN apk add nodejs-npm
RUN apk add asciidoctor
RUN apk add openjdk8
RUN apk add ca-certificates wget && update-ca-certificates 
RUN apk add openssl
RUN gem install rdoc -v 6.3.3 || gem install rdoc -v 6.3.3
RUN gem install public_suffix -v 4.0.7
RUN gem install css_parser -v 1.12.0
RUN gem install asciidoctor-pdf-cjk
RUN wget https://forge.etsi.org/swagger2markup-cli-1.3.2.jar
RUN npm install -g swagger-cli
RUN npm install -g json-refs
RUN npm install -g yamljs

ADD scripts/validate-in-docker.sh /validate-in-docker.sh
RUN chmod +x /validate-in-docker.sh

ADD scripts/swg2mrkup /bin/swg2mrkup
RUN chmod +x /bin/swg2mrkup

ADD scripts/oas2pdf /bin/oas2pdf
RUN chmod +x /bin/oas2pdf

ENTRYPOINT ["/validate-in-docker.sh"]
+61 −0
Original line number Diff line number Diff line
#!/bin/bash
#Copyright (c) ETSI 2017.

# This software is subject to copyrights owned by ETSI. Non-exclusive permission 
# is hereby granted, free of charge, to copy, reproduce and amend this file 
# under the following conditions: It is provided "as is", without warranty of any 
# kind, expressed or implied. 

# ETSI shall never be liable for any claim, damages, or other liability arising 
# from its use or inability of use.This permission does not apply to any documentation 
# associated with this file for which ETSI keeps all rights reserved. The present 
# copyright notice shall be included in all copies of whole or part of this 
# software and shall not imply any sub-license right.
#
# Author: michele.carignani@etsi.org
#
# This script takes an OpenAPI file in input and creates
# a PDF file with the content.
#
# Prerequisites: 
#  - https://github.com/Swagger2Markup/swagger2markup-cli
#  - Asciidoctor (sudo apt-get install asciidoctor)
#  - Asciidoctor-pdf (sudo gem install asciidoctor-pdf)
#
# Usage:
#    oas2pdf <oasfile> (e.g. myapi.json)
#
# Result:
#    A new pdf file is created in the working directory (e.g. myapi.pdf)
#
#
#
#

# Configuration

# Change this if needed
SWG2MRKUP=swg2mrkup
ASCIIDOCPDF=asciidoctor-pdf

# Setup
WD=$(pwd)
TWD=$(mktemp -d)

INFILE=$(basename ${1?"Error: missing input file name"} )
OUTFILE="${INFILE%.*}"

echo "$INFILE, $OUTFILE"

echo "Converting to asciidoc.."
${SWG2MRKUP} convert -i "$1" -f "$TWD/$OUTFILE"
echo

echo "Converting to PDF.."
"${ASCIIDOCPDF}" "$TWD/${OUTFILE}.adoc" -o "$WD/${OUTFILE}.pdf"
echo

echo "Done."
# Clean up
rm -r $TWD
Loading