diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 6cbd763..65f2425 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -4,7 +4,6 @@ on: push env: GROUP: senacor - COMMIT_SHA: ${{ github.sha }} REPO: simple-provider jobs: @@ -28,13 +27,33 @@ jobs: - name: Build + verify run: mvn -B verify + integration-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: Cache Maven packages + uses: actions/cache@v2 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + + - name: Run Integration tests + run: mvn integration-test + docker: needs: - test + - integration-test runs-on: ubuntu-latest env: PUSH_DOCKER_IMAGE: true - DOCKER_NAME: ghcr.io/${{ github.repository }} DOCKER_REGISTRY: ghcr.io steps: - uses: actions/checkout@v2 @@ -61,5 +80,23 @@ jobs: with: context: . tags: | - ${{ env.DOCKER_NAME }}:${{ env.COMMIT_SHA }} + ghcr.io/${{ github.repository }}:${{ github.sha }} push: ${{ env.PUSH_DOCKER_IMAGE }} + + postman-test: + needs: + - docker + name: postman test + runs-on: ubuntu-latest + services: + test-service: + image: ghcr.io/${{ github.repository }}:${{ github.sha }} + ports: + - 8080:8080 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 14 + - run: npm install newman -g + - run: newman run postman/postman_collection.json diff --git a/Dockerfile b/Dockerfile index 324ee4d..1634a0f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,4 +8,4 @@ COPY launch.sh /app/ EXPOSE 8080 WORKDIR /app -CMD ["bash", "launch.sh"] +CMD ["sh", "launch.sh"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..9dad940 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,6 @@ +version: "3.7" +services: + application: + build: . + ports: + - 8080:8080 \ No newline at end of file diff --git a/postman/postman_collection.json b/postman/postman_collection.json new file mode 100644 index 0000000..8288841 --- /dev/null +++ b/postman/postman_collection.json @@ -0,0 +1,71 @@ +{ + "info": { + "_postman_id": "ed004fd8-8f9e-4a01-b1a2-2bc159c5dcb8", + "name": "Simple Provider", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "Successfull call (200)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test('Status code is 200', () => {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "localhost:8080/items", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "items" + ] + } + }, + "response": [] + }, + { + "name": "Not successfull call (404)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test('Status code is 404', () => {", + " pm.response.to.have.status(404);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "localhost:8080/unknown", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "unknown" + ] + } + }, + "response": [] + } + ] +} \ No newline at end of file