From c7baed6d3b69ef0cafc0824b33c6203046304dc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= <20689156+shortcuts@users.noreply.github.com> Date: Tue, 30 Nov 2021 11:37:36 +0100 Subject: [PATCH] chore(tooling): setup GitHub actions, add CODEOWNERS and PR template (#20) --- .github/CODEOWNERS.md | 3 ++ .github/PULL_REQUEST_TEMPLATE.md | 9 +++++ .github/workflows/client_javascript.yml | 50 +++++++++++++++++++++++++ .github/workflows/specs.yml | 32 ++++++++++++++++ package.json | 27 +++++++------ 5 files changed, 109 insertions(+), 12 deletions(-) create mode 100644 .github/CODEOWNERS.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/client_javascript.yml create mode 100644 .github/workflows/specs.yml diff --git a/.github/CODEOWNERS.md b/.github/CODEOWNERS.md new file mode 100644 index 0000000000..e447251d3d --- /dev/null +++ b/.github/CODEOWNERS.md @@ -0,0 +1,3 @@ +# Default owners + +- @algolia/data-ingestion diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000000..2be07162e9 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,9 @@ +## ๐Ÿงญ What and Why + +๐ŸŽŸ JIRA Ticket: + +### Changes included: + +- List changes + +## ๐Ÿงช Test diff --git a/.github/workflows/client_javascript.yml b/.github/workflows/client_javascript.yml new file mode 100644 index 0000000000..4a1dffd13c --- /dev/null +++ b/.github/workflows/client_javascript.yml @@ -0,0 +1,50 @@ +name: client_javascript + +on: + workflow_run: + workflows: ['specs'] + types: + - completed + +jobs: + build: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: '11' + + - uses: actions/setup-node@v2 + with: + node-version-file: '.nvmrc' + cache: 'yarn' + cache-dependency-path: 'yarn.lock' + + - name: Install Dependencies + run: yarn install + + - name: Generate search client + run: yarn generate:js:search + + - name: Build search client + run: yarn client:build-js:search + + - name: Generate recommend client + run: yarn generate:js:recommend + + - name: Build recommend client + run: yarn client:build-js:recommend + + - name: Lint + run: yarn prettier --check clients/algoliasearch-client-javascript + + build-failure: + if: ${{ github.event.workflow_run.conclusion == 'failure' }} + runs-on: ubuntu-latest + steps: + - name: Error on `specs` workflow + run: exit 1 diff --git a/.github/workflows/specs.yml b/.github/workflows/specs.yml new file mode 100644 index 0000000000..88840a75ec --- /dev/null +++ b/.github/workflows/specs.yml @@ -0,0 +1,32 @@ +name: specs + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: '11' + + - uses: actions/setup-node@v2 + with: + node-version-file: '.nvmrc' + cache: 'yarn' + cache-dependency-path: 'yarn.lock' + + - name: Install Dependencies + run: yarn install + + - name: Build + run: yarn build:spec + + - name: Validate + run: yarn validate + + - name: Lint + run: yarn prettier --check specs diff --git a/package.json b/package.json index 51005b186a..9c09bcb381 100644 --- a/package.json +++ b/package.json @@ -6,27 +6,30 @@ "playground/javascript/" ], "scripts": { - "build:spec:recommend:json": "yarn swagger-cli bundle specs/recommend/spec.yml --outfile dist/openapi.json --type json", - "build:spec:search:json": "yarn swagger-cli bundle specs/search/spec.yml --outfile dist/openapi.json --type json", - "build:spec:recommend": "yarn swagger-cli bundle specs/recommend/spec.yml --outfile dist/recommend.yml --type yaml", - "build:spec:search": "yarn swagger-cli bundle specs/search/spec.yml --outfile dist/search.yml --type yaml", - "build:spec:json": "yarn build:spec:search:json", + "build:spec:recommend:json": "yarn swagger-cli bundle specs/recommend/spec.yml --outfile specs/dist/recommend.json --type json", + "build:spec:search:json": "yarn swagger-cli bundle specs/search/spec.yml --outfile specs/dist/search.json --type json", + "build:spec:recommend": "yarn swagger-cli bundle specs/recommend/spec.yml --outfile specs/dist/recommend.yml --type yaml", + "build:spec:search": "yarn swagger-cli bundle specs/search/spec.yml --outfile specs/dist/search.yml --type yaml", + "build:spec:json": "yarn build:spec:search:json && yarn build:spec:recommend:json", "build:spec": "yarn build:spec:search && yarn build:spec:recommend", "clean": "rm -rf **/dist **/build **/node_modules", - "client:build-js": "yarn workspace @algolia/recommend build && yarn workspace @algolia/client-search build", + "client:build-js:search": "yarn workspace @algolia/client-search build", + "client:build-js:recommend": "yarn workspace @algolia/client-search build", + "client:build-js": "yarn client:build-js:search && yarn client:build-js:recommend", "client:build": "yarn client:build-js", - "lint:js": "yarn prettier --write clients/algoliasearch-client-javascript", + "lint:js": "yarn prettier --write clients/algoliasearch-client-javascript/${CLIENT}", "lint:specs": "yarn prettier --write specs", "lint": "yarn lint:specs && yarn lint:js", - "generate:js:recommend": "yarn openapi-generator-cli generate --generator-key javascript-recommend && CLIENT=recommend yarn utils:import-js", - "generate:js:search": "yarn openapi-generator-cli generate --generator-key javascript-client-search && CLIENT=client-search yarn utils:import-js", - "generate:js": "yarn generate:js:search && yarn generate:js:recommend && yarn install", + "generate:js:recommend": "yarn openapi-generator-cli generate --generator-key javascript-recommend && CLIENT=recommend yarn utils:import-js && CLIENT=recommend yarn lint:js", + "generate:js:search": "yarn openapi-generator-cli generate --generator-key javascript-client-search && CLIENT=client-search yarn utils:import-js && CLIENT=client-search yarn lint:js", + "generate:js": "yarn generate:js:search && yarn generate:js:recommend", "generate:recommend": "yarn generate:js:recommend", "generate:search": "yarn generate:js:search", - "generate": "yarn generate:js && yarn lint", + "generate": "yarn generate:js && yarn lint:specs", "playground:js:search": "yarn workspace javascript-playground start:search", "playground:js:recommend": "yarn workspace javascript-playground start:recommend", - "utils:import-js": "mkdir -p -- clients/algoliasearch-client-javascript/${CLIENT}/utils && cp -R clients/algoliasearch-client-javascript/utils/ clients/algoliasearch-client-javascript/${CLIENT}/utils" + "utils:import-js": "mkdir -p -- clients/algoliasearch-client-javascript/${CLIENT}/utils && cp -R clients/algoliasearch-client-javascript/utils/ clients/algoliasearch-client-javascript/${CLIENT}/utils", + "validate": "yarn swagger-cli validate specs/dist/search.yml && yarn swagger-cli validate specs/dist/recommend.yml" }, "devDependencies": { "@openapitools/openapi-generator-cli": "^2.4.13",