-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (65 loc) · 2.45 KB
/
tyk-lint.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Basic Tyk API and Policies schema validation and linter triggered on development assets. The idea of this workflow is to validate specific field requirements
# or enforce governance to make sure specific custom plugins are used or formats
name: Tyk Schema Validation / Linter
# Perform the Tyk schema validation only on PR requests
on:
workflow_dispatch:
inputs:
environment:
type: choice
options:
- dev
- stg
- prod
workflow_call:
inputs:
environment:
type: string
jobs:
schema-linter-and-validation:
runs-on: ubuntu-latest
steps:
# Check out the current repo and fetch only the current commits (JTBD)
- name: 'Checkout Repository'
uses: actions/checkout@v4
# List the content that exists within the repo to validate the files
- name: 'List Repository Contents'
run: |
ls -la
pwd
# Install JQ library used to introspect the API and Policy definitions
- name: 'Install JQ Library'
uses: dcarbone/install-jq-action@v2
- name: 'Check JQ Library'
run: |
which jq
jq --version
# Determine the environment to lint run linter against
- name: 'Determine Environment'
id: determine_environment
run: |
if [[ "${{ github.event_name }}" == "workflow_call" ]]; then
# Workflow called with an input
echo "environment=${{ inputs.environment }}" >> $GITHUB_ENV
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
# Workflow called with an input
echo "environment=${{ inputs.environment }}" >> $GITHUB_ENV
else
# Pull request called with an input
echo "environment=${{ inputs.environment }}" >> $GITHUB_ENV
fi
# Tyk API Linting / Validation using Github Action Library
- name: 'Linter / validation using Spectral / Stoplight'
uses: stoplightio/spectral-action@latest
with:
file_glob: ${{ env.environment }}/apis/api-*.json
spectral_ruleset: ${{ env.environment }}/tykapi-ruleset.yaml
continue-on-error: false
# Tyk API Linting / Validation using JQ Library
- name: 'Linter / validation using JQ'
env:
DIRECTORY: "./infrastructure/${{ env.environment }}/apis/"
CURR_ENV: ${{ env.environment }}
run: |
chmod +x ./.github/scripts/validate_fields.sh
./.github/scripts/validate_fields.sh