Skip to content

Commit

Permalink
Preparing for 0.1.0.0 release (#129)
Browse files Browse the repository at this point in the history
* MAde project name optional

* Refined readme

* Documented the release procedure

* Updated versions

* Refined the readme some more
  • Loading branch information
ilyakooo0 authored Feb 3, 2022
1 parent db716ee commit 5e2eff7
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 35 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

`comparest` uses [PVP Versioning][1].

## 0.0.0.0
## 0.1.0.0

* Initially created.
* Initial release.

[1]: https://pvp.haskell.org
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Aleksey Uymanov
Copyright (c) 2021 Typeable

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
59 changes: 41 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
# CompaREST
# compaREST

[![Hackage](https://img.shields.io/hackage/v/comparest.svg?logo=haskell)](https://hackage.haskell.org/package/comparest)
[![Stackage Lts](http://stackage.org/package/comparest/badge/lts)](http://stackage.org/lts/package/comparest)
[![Hackage](https://img.shields.io/hackage/v/compaREST.svg?logo=haskell)](https://hackage.haskell.org/package/comparest)
[![Stackage Lts](http://stackage.org/package/compaREST/badge/lts)](http://stackage.org/lts/package/comparest)
[![Stackage Nightly](http://stackage.org/package/comparest/badge/nightly)](http://stackage.org/nightly/package/comparest)
[![MIT license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

Compatibility checker for OpenAPI
# Quick Start Guide

## Your situation
## Using compaREST in Github Actions

Add the following step to your Github Actions workflow:

```yaml
- uses: typeable/comparest
if: ${{ github.event_name == 'pull_request' }}
with:
old: old-openapi.yaml
new: new-openapi.yaml
```
The `new` and `old` values should be paths to your OpenAPI specifications you want to compare.

You will get something like this in your pull requests:

![](docs/img/github-action-report.png)

For more detail please see our [integration guide](docs/Integration_guide.md).

## An example

### Your situation

You are developing a very important server with a REST API. You have clients who use your API that you do not control. Say, you are also developing a mobile app that uses your API and you can't force someone to update to the latest version. (Or you prefer not to for UX reasons.)

Expand Down Expand Up @@ -75,7 +96,7 @@ components:
$ref: "#/components/schemas/Pet"
```

## Evolving your product
### Evolving your product

Enthused over your initial success you hurry to release a new and improved version of your API and mobile app.

Expand Down Expand Up @@ -144,7 +165,7 @@ components:

Looking at the very large and complex API description, you grow more and more concerned that your old mobile app might stop working when you update the server. But the spec is too large and too complex to reasonably assess this manually.

## Assessing compatibility automatically
### Assessing compatibility automatically

Luckily, you have access to compaREST which can programmatically analyze your APIs and determine what, if anything, breaks compatibility and what doesn't.

Expand All @@ -158,15 +179,15 @@ Running this command will output a file `report.md`, containing the compatibilit

> # Summary
>
> | [⚠️ Breaking changes](#breaking-changes) | [🙆 Non-breaking changes](#non-breaking-changes) | 🤷 Unsupported feature changes |
> |------------------------------------------|-------------------------------------------------|-------------------------------|
> | 5 | 6 | 0 |
> | [ Breaking changes](#breaking-changes) | [⚠️ Non-breaking changes](#non-breaking-changes) |
> |------------------------------------------|--------------------------------------------------|
> | 5 | 6 |
>
> # <span id="breaking-changes"></span>⚠️ Breaking changes
> # <span id="breaking-changes"></span> Breaking changes
>
> ## **GET** /pets
>
> ### 📱⬅️ JSON Response – 200
> ### ⬅️☁️ JSON Response – 200
>
> #### `$[*].name(String)`
>
Expand All @@ -176,7 +197,7 @@ Running this command will output a file `report.md`, containing the compatibilit
>
> ## **POST** /pets
>
> ### 📱➡️ JSON Request
> ### ➡️☁️ JSON Request
>
> #### `$.weight`
>
Expand All @@ -191,7 +212,7 @@ Running this command will output a file `report.md`, containing the compatibilit
>
> Value is now a multiple of 1.0.
>
> # <span id="non-breaking-changes"></span>🙆 Non-breaking changes
> # <span id="non-breaking-changes"></span>⚠️ Non-breaking changes
>
> ## **GET** /pets
>
Expand All @@ -203,7 +224,7 @@ Running this command will output a file `report.md`, containing the compatibilit
>
> Upper bound changed from 20.0 inclusive to 30.0 inclusive.
>
> ### 📱⬅️ JSON Response – 200
> ### ⬅️☁️ JSON Response – 200
>
> #### `$[*].weight`
>
Expand All @@ -220,7 +241,7 @@ Running this command will output a file `report.md`, containing the compatibilit
>
> ## **POST** /pets
>
> ### 📱➡️ JSON Request
> ### ➡️☁️ JSON Request
>
> #### `$.name(String)`
>
Expand All @@ -230,15 +251,17 @@ Running this command will output a file `report.md`, containing the compatibilit

You now know exactly in what situations and in what way your 1.0 version of the app will break if you deploy your 1.1 version of the server.

## Additional formats
### Additional formats

You can also produce a self-contained HTML report that you can open in your browser by simply omitting the file extension of the output file:

```bash
docker run --rm -v $(pwd):/data:rw typeable/comparest --client /data/api-1.0.0.yaml --server /data/api-1.1.0.yaml --output /data/report
```

# CLI docs
## CLI docs

For more detail please see our [user guide](docs/User_guide.md).

```
Usage: comparest (-c|--client ARG) (-s|--server ARG)
Expand Down
17 changes: 9 additions & 8 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,30 @@ inputs:
default: "${{ github.token }}"
required: false
repo:
description: The owner of the repo in which to post the comment.
description: The owner of the repo in which to post the results.
default: "${{ github.repository }}"
required: false
project_name:
description: The name of the project to which the API pertains.
required: true
description: The name of the project to which the API pertains. Used to name the check. Useful when you have multiple APIs in the same repo.
required: false
default: ""
footer:
description: A footer that can be appended to the comment.
description: A footer that can be appended to the check body.
required: false
default: ""
old:
description: The path to old specification of the API.
description: The path to the old (client) specification of the API.
required: true
new:
description: The path to new specification of the API.
description: The path to new (server) specification of the API.
required: true
sha:
description: The sha of the commit to post the check for.
required: false
default: "${{ github.event.pull_request.head.sha }}"
runs:
using: "docker"
image: "docker://typeable/comparest-github-action:latest"
image: "docker://typeable/comparest-github-action:0.1.0.0"
env:
GITHUB_TOKEN: "${{ inputs.GITHUB_TOKEN }}"
REPO: "${{ inputs.repo }}"
Expand All @@ -44,4 +45,4 @@ runs:

branding:
icon: crosshair
color: gray-dark
color: blue
2 changes: 1 addition & 1 deletion compaREST.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.4
name: compaREST
version: 0.0.0.0
version: 0.1.0.0
synopsis: Compatibility checker for OpenAPI
description: Compatibility checker for OpenAPI.
license: MIT
Expand Down
15 changes: 15 additions & 0 deletions docs/Releasing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# The release procedure

1. Update the version number everywhere:
1. Version in [compaREST.cabal](../compaREST.cabal)
2. Docker tag in [action.yaml](../action.yaml)
3. Set the version of unreleased changes in [CHANGELOG.md](../CHANGELOG.md)
2. Publish!
1. Create a pre-release on GitHub:
![](img/pre-release.png)
2. This will automatically start the release procedure. You can check the state of it in the "Actions" tab on GitHub:
![](img/pre-release-ci.png)
3. If everything goes as planned, the release action should pass and all assets should be added to the release:
![](img/pre-release-artifacts.png)
4. The new version should be automatically uploaded a release candidate to [Hackage](https://hackage.haskell.org/package/compaREST/candidates/). Make sure everything looks okay and publish it.
5. Go to the Releases tab on GitHub and edit the release to make it not a "pre-release".
Binary file added docs/img/pre-release-artifacts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/pre-release-ci.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/pre-release.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions github-action/CompaREST/GitHub/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ postStatusProcessing = do
repoOwner
repoName
Check
{ checkName = mkName Proxy $ "compaREST – " <> projectName
{ checkName = mkName Proxy checkName
, checkSha = sha
, checkDetailsURL = Nothing
, checkExternalId = Nothing
Expand Down Expand Up @@ -60,7 +60,7 @@ postStatus x = do
repoOwner
repoName
Check
{ checkName = mkName Proxy $ "compaREST – " <> projectName
{ checkName = mkName Proxy checkName
, checkSha = sha
, checkDetailsURL = Nothing
, checkExternalId = Nothing
Expand Down
10 changes: 7 additions & 3 deletions github-action/CompaREST/GitHub/Action/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import Data.Text (Text)
import qualified Data.Text as T
import qualified GitHub as GH

import Data.Functor
import System.Envy

data Config = Config
{ githubToken :: GH.Auth
, repoOwner :: GH.Name GH.Owner
, repoName :: GH.Name GH.Repo
, projectName :: Text
, checkName :: Text
, footerText :: Text
, root :: FilePath
, sha :: GH.Name GH.Commit
Expand All @@ -27,7 +28,10 @@ instance FromEnv Config where
T.split (== '/') <$> env "REPO" >>= \case
[owner, name] -> pure (owner, name)
_ -> fail "malformed repo"
projectName <- env "PROJECT_NAME"
checkName <-
envMaybe "PROJECT_NAME" <&> \case
Just pName | not . T.null . T.strip $ pName -> "compaREST – " <> pName
_ -> "compaREST"
footerText <- env "FOOTER"
root <- envMaybe "ROOT" .!= "."
sha <- env "SHA"
Expand All @@ -36,7 +40,7 @@ instance FromEnv Config where
{ githubToken = token
, repoOwner = GH.mkName Proxy owner
, repoName = GH.mkName Proxy repo
, projectName = projectName
, checkName = checkName
, footerText = footerText
, root = root
, sha = GH.mkName Proxy sha
Expand Down

0 comments on commit 5e2eff7

Please sign in to comment.