Skip to content

Commit

Permalink
Improve linting and check for compile errors (#292)
Browse files Browse the repository at this point in the history
* Improve linting and for compile errors

* Check compiled.json is updated

* Avoid duplicating runs by using only push trigger

* Change to go build
  • Loading branch information
theSoenke authored Feb 27, 2023
1 parent 2f1c570 commit 7504a1e
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 16 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
persist-credentials: false
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19.1
go-version: 1.19.6
- name: Build and Deploy 🚀
env:
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
Expand Down Expand Up @@ -43,14 +43,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
persist-credentials: false
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19.1
go-version: 1.19.6
- name: Build and Deploy 🚀
env:
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
persist-credentials: false

Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
persist-credentials: false

Expand Down Expand Up @@ -140,7 +140,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
persist-credentials: false

Expand Down Expand Up @@ -171,7 +171,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
persist-credentials: false

Expand Down Expand Up @@ -200,7 +200,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
persist-credentials: false

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
persist-credentials: false

Expand Down
59 changes: 55 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,64 @@
name: Lint
on: [push, pull_request]
name: Lint
on: [push]
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v1
with:
node-version: '10.x'
node-version: "18"
- run: npm install
- run: npm run lint

compare-output:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v1
with:
node-version: "18"
- run: npm install
- run: npx swagger-cli bundle -t json -w 300 main.yaml > doc/compiled_new.json
- run: diff doc/compiled.json doc/compiled_new.json

compile-go:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19.6
- name: Build
env:
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm install
npm run generate.go
cd clients/go && go build
compile-cli:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19.6
- name: Build
env:
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm install
npm run generate.cli
cd clients/cli && go build
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ run:
@echo Client libraries generated, check clients directory.
lint:
npx swagger-cli validate main.yaml
# make bundle
# npx openapi-generator-cli validate -i tmp/compiled.yaml
make bundle
bash ./lint.sh
bundle:
npx swagger-cli bundle -t json -w 300 main.yaml > doc/compiled.json
npx swagger-cli bundle -t yaml -w 300 main.yaml > tmp/compiled.yaml
Expand Down
10 changes: 10 additions & 0 deletions lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

output=$(npx openapi-generator-cli validate -i tmp/compiled.yaml | grep -v "inheritance without use of 'discriminator.propertyName'" | grep -v "No validation issues detected.")
if echo "$output" | grep -q -E "WARN|ERROR"; then
echo "$output"
echo "Validation errors"
exit 1
else
echo "No validation errors"
fi

0 comments on commit 7504a1e

Please sign in to comment.