Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenAPI + CI #86

Merged
merged 26 commits into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a8df40a
initial openapi publishing
matthewhanson Dec 4, 2020
e254cdb
ci: make working directory
matthewhanson Dec 7, 2020
df575f1
Merge branch 'master' of github.com:radiantearth/stac-api-spec into b…
matthewhanson Dec 7, 2020
db49d7d
use publish script just for publishing
matthewhanson Dec 8, 2020
f014ec8
ci: build openapi
matthewhanson Dec 8, 2020
2604492
ci: setup scripts for build and publish openapi
matthewhanson Dec 8, 2020
1ed0bcc
ci: add openapi build script
matthewhanson Dec 8, 2020
367024e
ci: updated config
matthewhanson Dec 8, 2020
c95c1c3
ci: update fingerprint
matthewhanson Dec 8, 2020
fa8762e
publish to specific directory
matthewhanson Dec 8, 2020
1e80444
ci: add caching between jobs
matthewhanson Dec 8, 2020
adf1a66
ci: add yaml reference anchors
matthewhanson Dec 8, 2020
4dc6627
ci: fix cache paths
matthewhanson Dec 8, 2020
08637a7
ci: explicit paths
matthewhanson Dec 8, 2020
795fbb4
ci: specify paths with working directory
matthewhanson Dec 8, 2020
4560867
ci: rename caches
matthewhanson Dec 8, 2020
d52097b
ci: add fingerprint
matthewhanson Dec 8, 2020
fdc35c4
ci: reset fingerprint
matthewhanson Dec 8, 2020
c5611cd
ci: move add fingerprints
matthewhanson Dec 8, 2020
caff37a
ci: revert fingerprint
matthewhanson Dec 8, 2020
aefb3c8
ci: remove fingerprints
matthewhanson Dec 8, 2020
c49ef87
ci: add github as known host
matthewhanson Dec 8, 2020
d94ddae
ci: change ssh-keyscan cmd for publish
matthewhanson Dec 8, 2020
60b2f01
ci: remove version from local build, only in publish
matthewhanson Dec 8, 2020
98aedd4
ci: enable builds and publish with tags
matthewhanson Dec 8, 2020
eba3979
Merge branch 'master' into dev
matthewhanson Dec 8, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .circleci/build-openapi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

PATH=./node_modules/.bin:$PATH

# find all OpenAPI docs that are not fragments
FNAMES=`find . -name "openapi.yaml" -not -path "./fragments/*" -not -path "./node_modules/*"`

# use speccy to resolve
for fin in $FNAMES; do
fout=./build/$fin
mkdir -p ${fout%/*}
speccy resolve $fin > $fout
done
85 changes: 83 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
version: 2.1

references:
restore_repo: &restore_repo
restore_cache:
keys:
- v0-repo-{{ .Branch }}-{{ .Revision }}
- v0-repo-{{ .Branch }}
- v0-repo

restore_dependencies: &restore_dependencies
restore_cache:
keys:
- v0-dependencies-{{ checksum "package.json"}}
- v0-dependencies

restore_build: &restore_build
restore_cache:
keys:
- v0-build-{{ .Branch }}-{{ .Revision }}


jobs:
build:
validate:
working_directory: ~/stac
docker:
- image: circleci/node:12
Expand All @@ -9,9 +30,69 @@ jobs:
- run:
name: init_submodules
command: git submodule update --init --recursive
- save_cache:
key: v0-repo-{{ .Branch }}-{{ .Revision }}
paths:
- ~/stac
- run:
name: install
command: npm install
- save_cache:
key: v0-dependencies-{{ checksum "package.json"}}
paths:
- ~/stac/node_modules
- run:
name: validate
command: npm run check
command: npm run check
build:
working_directory: ~/stac
docker:
- image: circleci/node:12
steps:
- *restore_repo
- *restore_dependencies
- run:
name: build openapi
command: npm run build-openapi
- save_cache:
key: v0-build-{{ .Branch }}-{{ .Revision }}
paths:
- ~/stac/build
publish:
working_directory: ~/stac
docker:
- image: circleci/node:12
steps:
- *restore_repo
- *restore_dependencies
- *restore_build
- add_ssh_keys
- run:
name: publish
command: |
ssh-keyscan github.com >> ~/.ssh/known_hosts
npm run publish-openapi -- $CIRCLE_TAG

workflows:
version: 2
ci:
jobs:
- validate:
filters:
tags:
only: /^v.*/
- build:
requires:
- validate
filters:
tags:
only: /^v.*/
- publish:
requires:
- build
filters:
tags:
only: /^v.*/
branches:
# Only dev branch, not PRs
only: dev
20 changes: 20 additions & 0 deletions .circleci/publish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const ghpages = require('gh-pages');

let args = process.argv.slice(2);
let tag = 'dev';
if (args.length && args[0].trim().length > 0) {
tag = args[0];
}

ghpages.publish('build/', {
src: '**',
dest: tag,
message: 'Publish JSON Schemas [ci skip]',
user: {
name: 'STAC CI',
email: '[email protected]'
}
}, error => {
console.error(error ? error : 'Deployed to gh-pages');
process.exit(error ? 1 : 0);
});
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
"check-openapi-commons": "spectral lint core/commons.yaml --ruleset .circleci/.spectral-fragments.yml",
"check-openapi-ogcapi-features": "spectral lint ogcapi-features/openapi.yaml ogcapi-features/extensions/*/openapi.yaml --ruleset .circleci/.spectral.yml",
"check-openapi-item-search": "spectral lint item-search/openapi.yaml --ruleset .circleci/.spectral.yml",
"check-openapi-fragments": "spectral lint fragments/*/openapi.yaml --ruleset .circleci/.spectral-fragments.yml"
"check-openapi-fragments": "spectral lint fragments/*/openapi.yaml --ruleset .circleci/.spectral-fragments.yml",
"build-openapi": ".circleci/build-openapi.sh",
"publish-openapi": "node .circleci/publish.js"
},
"dependencies": {
"@stoplight/spectral": "^5.7.1",
"gh-pages": "^3.1.0",
"klaw-sync": "^6.0.0",
"redoc-cli": "^0.10.2",
"remark-cli": "^8.0.1",
"remark-lint": "^7.0.1",
Expand All @@ -25,6 +29,7 @@
"remark-preset-lint-markdown-style-guide": "^3.0.1",
"remark-preset-lint-recommended": "^4.0.1",
"remark-validate-links": "^10.0.2",
"speccy": "^0.11.0",
"yaml-files": "^1.1.0"
}
}