Skip to content

Commit

Permalink
chore(ci): re-use workflows, use composite action, cache built client. (
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts authored Dec 7, 2021
1 parent c1ac7be commit dc39a23
Show file tree
Hide file tree
Showing 10 changed files with 193 additions and 132 deletions.
24 changes: 24 additions & 0 deletions .github/actions/cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Cache

description: Restore cached dependencies.

runs:
using: 'composite'
steps:
- name: Get yarn cache directory path
shell: bash
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Restore yarn cache
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}

- name: Restore node_modules
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
32 changes: 32 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Setup

description: Setup CI environment.

runs:
using: 'composite'
steps:
- name: Restore cache
uses: ./.github/actions/cache

- name: Update apt packages
shell: bash
run: sudo apt update

- name: Install Java
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11.0.4'

- name: Install Node
uses: actions/setup-node@v2
with:
node-version-file: '.nvmrc'

- name: Install JavaScript Dependencies
shell: bash
run: yarn install

- name: Install spec linter
shell: bash
run: sudo apt-get -y install yamllint
81 changes: 81 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Checks

on: [push]

jobs:
setup:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

- name: Setup
uses: ./.github/actions/setup

specs:
runs-on: ubuntu-20.04
needs: setup
steps:
- uses: actions/checkout@v2

- name: Restore cache
uses: ./.github/actions/cache

- name: Build
run: yarn build:spec

- name: Validate
run: yarn validate

- name: Lint
run: yamllint specs

client_javascript:
runs-on: ubuntu-20.04
needs: [setup, specs]
steps:
- uses: actions/checkout@v2

- name: Restore cache
uses: ./.github/actions/cache

- 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: Generate personalization client
run: yarn generate:js:personalization

- name: Build personalization client
run: yarn client:build-js:personalization

- name: Lint
run: yarn lint

cts:
runs-on: ubuntu-20.04
needs: [setup, specs, client_javascript]
steps:
- uses: actions/checkout@v2

- name: Restore cache
uses: ./.github/actions/cache

- name: Generate clients
run: yarn generate

- name: Build client
run: yarn client:build

- name: Generate CTS
run: yarn cts:generate

- name: Run CTS
run: yarn cts:test
43 changes: 0 additions & 43 deletions .github/workflows/client_javascript.yml

This file was deleted.

30 changes: 0 additions & 30 deletions .github/workflows/cts.yml

This file was deleted.

32 changes: 0 additions & 32 deletions .github/workflows/specs.yml

This file was deleted.

29 changes: 29 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
yaml-files:
- '*.yml'

rules:
line-length: disable
braces: enable
brackets: enable
colons: enable
commas: enable
comments:
level: warning
comments-indentation:
level: warning
document-end: disable
document-start: { present: false }
empty-lines: enable
empty-values: disable
hyphens: enable
indentation: enable
key-duplicates: enable
key-ordering: disable
new-line-at-end-of-file: enable
new-lines: enable
octal-values: disable
quoted-strings: disable
trailing-spaces: enable
truthy:
level: warning
2 changes: 1 addition & 1 deletion specs/analytics/paths/search/getTopFilterAttributes.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# handle /2/filters?search= as well
get:
# handle /2/filters?search= as well
14 changes: 7 additions & 7 deletions specs/analytics/spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ security:
- appId: []
apiKey: []
paths:
# ########################
# ### Status Endpoints ###
# ########################
/2/status:
$ref: './paths/status/getStatus.yml'
#
# ##################################
# ### Search Analytics Endpoints ###
# ##################################
Expand Down Expand Up @@ -48,7 +42,7 @@ paths:
# $ref: './paths/search/getAttributeTopFilters.yml'
# /2/countries:
# $ref: './paths/search/getTopCountries.yml'
#

# #################################
# ### Click Analytics Endpoints ###
# #################################
Expand All @@ -60,3 +54,9 @@ paths:
# $ref: './paths/click/getClickThroughRate.yml'
# /2/conversions/conversionRate:
# $ref: './paths/click/getConversionRate.yml'

# ########################
# ### Status Endpoints ###
# ########################
/2/status:
$ref: './paths/status/getStatus.yml'
Loading

0 comments on commit dc39a23

Please sign in to comment.