Skip to content

Commit

Permalink
Merge pull request #474 from nimblehq/release/5.9.0
Browse files Browse the repository at this point in the history
Release 5.9.0
  • Loading branch information
malparty authored Oct 2, 2023
2 parents c4b47a1 + 2affbce commit 1a3c0a0
Show file tree
Hide file tree
Showing 40 changed files with 525 additions and 31 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# See https://git-scm.com/docs/gitattributes for more about git attribute files.

# Mark any vendored files as having been vendored.
vendor/* linguist-vendored
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ on:
workflows:
- Test
branches:
- master
- main
- development
- develop
types:
- completed
workflow_dispatch:
Expand Down
6 changes: 6 additions & 0 deletions .template/addons/github/.github/workflows/test.yml.tt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ env:
DOCKER_REGISTRY_USERNAME: ${{ github.repository_owner }}
DOCKER_REGISTRY_TOKEN: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
DOCKER_IMAGE: ${{ github.repository }}
<%- if WEB_VARIANT -%>
NODE_VERSION: 16
<%- end -%>

# Set the default docker-compose file
COMPOSE_FILE: docker-compose.test.yml
Expand Down Expand Up @@ -106,6 +108,7 @@ jobs:
name: coverage
path: coverage

<%- if WEB_VARIANT -%>
system_tests:
name: System tests
runs-on: ubuntu-latest
Expand Down Expand Up @@ -139,6 +142,7 @@ jobs:
name: system_tests_screenshots
path: tmp/screenshots/

<%- end -%>
automated_code_review:
name: Run Danger
needs: unit_tests
Expand All @@ -161,6 +165,7 @@ jobs:
with:
bundler-cache: true

<%- if WEB_VARIANT -%>
- name: Setup Node
uses: actions/setup-node@v3
with:
Expand All @@ -180,6 +185,7 @@ jobs:
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: yarn

<%- end -%>
- name: Run Undercover
run: bundle exec undercover-report

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ name: Test production build
on:
push:
branches-ignore:
- master
- main
- development
- develop

env:
DOCKER_REGISTRY_HOST: ${{ secrets.DOCKER_REGISTRY_HOST }}
Expand Down
22 changes: 22 additions & 0 deletions .template/addons/openapi/.github/workflows/deploy_mock_server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Deploy Mock Server

on:
push:
branches:
- develop

jobs:
deploy:
name: Deploy mock server
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up flyctl
uses: superfly/flyctl-actions/setup-flyctl@master

- name: Deploy to fly
run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: {{ "${{ secrets.FLY_API_TOKEN }}" }}
31 changes: 31 additions & 0 deletions .template/addons/openapi/.github/workflows/lint_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Lint OpenAPI docs

on: pull_request

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
docs_lint:
name: Run lint for API docs
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up node and restore cached dependencies
uses: actions/setup-node@v3
with:
node-version: "18.x"
cache: npm
cache-dependency-path: package-lock.json

- name: Install dependencies
run: npm install

- name: Generate API docs
run: npm run build:docs

- name: Run API docs linters
run: npm run lint:docs:public
9 changes: 9 additions & 0 deletions .template/addons/openapi/.gitignore.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

append_to_file '.gitignore' do
<<~IGNORE
# Ignore generated OpenAPI file
/public/openapi.yml
IGNORE
end
6 changes: 6 additions & 0 deletions .template/addons/openapi/.spectral.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extends: ["spectral:oas"]

rules:
oas3-unused-component: false
operation-operationId: false
info-contact: false
7 changes: 7 additions & 0 deletions .template/addons/openapi/Dockerfile.mock
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM stoplight/prism:latest

COPY /docs /usr/src/prism/packages/cli/docs/

EXPOSE 80

CMD ["mock", "-h", "0.0.0.0", "-p", "80", "docs/openapi/openapi.yml"]
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"ok": {
"value": {
"data": {
"id": "1",
"type": "health",
"attributes": {
"message": "OK"
}
}
}
},
"error": {
"value": {
"errors": [
{
"status": "500",
"title": "Internal Server Error",
"detail": "Something went wrong."
}
]
}
}
}
31 changes: 31 additions & 0 deletions .template/addons/openapi/docs/openapi/openapi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
openapi: 3.0.0
info:
title: API Documentation
description: This is the API documentation for the mock server.
version: 1.0.0

servers:
- url: http://localhost:8080/api/v1
description: Development Base URL

security:
- BearerAuth: []

components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer
schemas:
$ref: "schemas.yml"
responses:
$ref: "responses.yml"

paths:
/health:
$ref: "paths/health.yml"

tags:
- name: Status
description: Status APIs of the project
20 changes: 20 additions & 0 deletions .template/addons/openapi/docs/openapi/paths/health.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
get:
tags:
- Status
security: []
summary: Get the status of the application.
description: Call this API to get the status of the application.

responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '../schemas.yml#/responses_health'
examples:
$ref: '../examples/responses/health.json'

default:
$ref: '../responses.yml#/responses_default_error'
Empty file.
3 changes: 3 additions & 0 deletions .template/addons/openapi/docs/openapi/responses.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
responses_default_error:
$ref: "responses/default_error.yml"
11 changes: 11 additions & 0 deletions .template/addons/openapi/docs/openapi/responses/default_error.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
description: Default Error

content:
application/json:
schema:
$ref: '../schemas.yml#/error'
example:
errors:
- code: 'invalid_request'
detail: 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.'
12 changes: 12 additions & 0 deletions .template/addons/openapi/docs/openapi/schemas.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
#### REQUESTS ####

#### RESPONSES ####

responses_health:
$ref: "schemas/responses/health.yml"

#### REUSABLE SCHEMAS ####

error:
$ref: "schemas/shared/error.yml"
Empty file.
24 changes: 24 additions & 0 deletions .template/addons/openapi/docs/openapi/schemas/responses/health.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
type: object

description: A response body for the health API

properties:
data:
type: object
description: The data object
properties:
id:
type: string
description: The identifier of the health
example: "123"
type:
type: string
description: The type of the health
example: 'health'
attributes:
type: object
properties:
message:
type: string
description: The message description of the status
15 changes: 15 additions & 0 deletions .template/addons/openapi/docs/openapi/schemas/shared/error.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
type: object

properties:
errors:
type: array
maxItems: 10
items:
type: object
properties:
code:
type: string
description: an application-specific error code
detail:
type: string
description: "a human-readable explanation specific to this occurrence of the problem. Like title, this field's value can be localized."
13 changes: 13 additions & 0 deletions .template/addons/openapi/fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
app = "api-mock-server"
primary_region = "sin"

[build]
dockerfile = "Dockerfile.mock"

[http_service]
internal_port = 80
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]
27 changes: 27 additions & 0 deletions .template/addons/openapi/package.json.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# frozen_string_literal: true

# Create package.json file
unless File.exist?('package.json')
create_file 'package.json',
<<~JSON
{
"name": "#{APP_NAME}",
"private": "true"
}
JSON
end

run 'yarn add --dev eslint'
run 'yarn add --dev @nimblehq/[email protected]'
run 'yarn add --dev @apidevtools/[email protected]'
run 'yarn add --dev @stoplight/[email protected]'
run 'yarn add --dev [email protected]'

# Setup scripts
run 'npm pkg set scripts.lint:docs:yml="eslint docs/openapi --ext .yml --color"'
run 'npm pkg set scripts.lint:docs:openapi="spectral lint docs/openapi/openapi.yml -F error"'
run 'npm pkg set scripts.lint:docs:dev="yarn lint:docs:yml && yarn lint:docs:openapi"'
run 'npm pkg set scripts.lint:docs:public="yarn build:docs && eslint public/openapi.yml --color --no-ignore\
&& spectral lint public/openapi.yml -F error"'
run 'npm pkg set scripts.build:docs="swagger-cli bundle docs/openapi/openapi.yml --outfile public/openapi.yml --type\
yaml"'
15 changes: 15 additions & 0 deletions .template/addons/openapi/public/openapi.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>API documentation</title>
<!-- Embed Elements via Web Component -->
<script src="https://unpkg.com/@stoplight/elements/web-components.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/@stoplight/elements/styles.min.css">
</head>

<body>
<elements-api apiDescriptionUrl="/openapi.yml" router="hash" layout="sidebar" />
</body>
</html>
20 changes: 20 additions & 0 deletions .template/addons/openapi/template.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

use_source_path __dir__

directory 'docs'
directory '.github' if @install_github_action
apply '.gitignore.rb'
apply 'package.json.rb'
copy_file '.spectral.yml'
copy_file 'public/openapi.html'

if yes?(install_addon_prompt('Mock Server'))
@install_mock_server = true
copy_file 'fly.toml'
copy_file 'Dockerfile.mock'
end

after_bundle do
run 'yarn build:docs'
end
2 changes: 1 addition & 1 deletion .template/hooks/before_complete/fix_rubocop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def fixing_rubocop
Layout/EmptyLineAfterMagicComment
].join(',')

run "rubocop --only #{cops} --auto-correct-all --out tmp/template_rubocop.txt"
run "rubocop --only #{cops} --autocorrect-all --out tmp/template_rubocop.txt"
end
end

Expand Down
Loading

0 comments on commit 1a3c0a0

Please sign in to comment.