Skip to content

Commit 21918ba

Browse files
authored
Beheer: vervang Spectral met Openlint (#371)
Hiermee vervangen we Spectral door Openlint voor zowel onze eigen test cases als in de documentatie. Openlint is feature-equivalent, dus we hoeven voor de rest geen aanpassingen te maken aan onze linter configuratie.
1 parent 73065f8 commit 21918ba

10 files changed

Lines changed: 21 additions & 32 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ jobs:
1919
name: Publish (Logius)
2020
uses: Logius-standaarden/Automatisering/.github/workflows/publish.yml@main
2121
secrets: inherit
22-
spectral_linter:
22+
linter_testcases:
2323
name: Linter test cases
2424
runs-on: ubuntu-22.04
2525
steps:
2626
- uses: actions/checkout@v4
2727
- uses: actions/setup-node@v4
2828
with:
29-
node-version: 20
29+
node-version: 22
3030
- name: Run test suite
3131
run: |
32-
npm install -g @stoplight/spectral-cli
32+
npm install -g openlint
3333
node linter/run-linter-tests.mjs
3434
examples_linter:
35-
needs: spectral_linter
35+
needs: linter_testcases
3636
name: Examples linter tests
3737
runs-on: ubuntu-22.04
3838
strategy:
@@ -42,7 +42,7 @@ jobs:
4242
- uses: actions/checkout@v4
4343
- uses: actions/setup-node@v4
4444
with:
45-
node-version: 20
45+
node-version: 22
4646
- uses: actions/setup-java@v4
4747
with:
4848
distribution: 'zulu'
@@ -57,7 +57,7 @@ jobs:
5757
cache: 'pip'
5858
- name: Install dependencies
5959
run: pip install fastapi uvicorn
60-
- name: Install Spectral
61-
run: npm install -g @stoplight/spectral-cli
60+
- name: Install Openlint
61+
run: npm install -g openlint
6262
- name: Run linter on ${{ matrix.example }} example
6363
run: ./examples/${{ matrix.example }}/build-and-check-project.sh

‎examples/aspnet/build-and-check-project.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ done
3939
kill $SERVER_PID
4040
wait $SERVER_PID 2>/dev/null
4141

42-
../run-spectral-linter.sh $(realpath generated/openapi.json)
42+
../run-openlint-linter.sh $(realpath generated/openapi.json)

‎examples/express/build-and-check-project.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ done
3939
kill $SERVER_PID
4040
wait $SERVER_PID 2>/dev/null
4141

42-
../run-spectral-linter.sh $(realpath generated/openapi.json)
42+
../run-openlint-linter.sh $(realpath generated/openapi.json)

‎examples/golang/build-and-check-project.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ kill $SERVER_PID
4242
wait $SERVER_PID 2>/dev/null
4343

4444
# Run linter
45-
../run-spectral-linter.sh "$(realpath generated/openapi.json)"
45+
../run-openlint-linter.sh "$(realpath generated/openapi.json)"

‎examples/python/build-and-check-project.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ kill $SERVER_PID
4141
wait $SERVER_PID 2>/dev/null
4242

4343
# Run linter
44-
../run-spectral-linter.sh "$(realpath generated/openapi.json)"
44+
../run-openlint-linter.sh "$(realpath generated/openapi.json)"

‎examples/quarkus/build-and-check-project.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ cd $CURRENT_DIRECTORY
55

66
./mvnw --no-transfer-progress package
77

8-
../run-spectral-linter.sh $(realpath target/generated/openapi/openapi.json)
8+
../run-openlint-linter.sh $(realpath target/generated/openapi/openapi.json)

‎examples/run-openlint-linter.sh‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
CURRENT_DIRECTORY=$(dirname "$0")
3+
4+
openlint lint --ruleset $CURRENT_DIRECTORY/../media/linter.yaml $1

‎examples/run-spectral-linter.sh‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎linter/run-linter-tests.mjs‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const writeFile = utils.promisify(fs.writeFile);
1414
const LINTER_RULESET_LOCATION = path.join(__dirname, '..', 'media', 'linter.yaml');
1515

1616
function computeTestCommand(apiLocation) {
17-
return `spectral lint -r ${LINTER_RULESET_LOCATION} ${apiLocation}/*.json || true`
17+
return `openlint lint --ruleset ${LINTER_RULESET_LOCATION} ${apiLocation}/*.json || true`
1818
}
1919

2020
function removeProcessDir(output) {
@@ -59,9 +59,6 @@ async function obtainAllTestcases() {
5959

6060
const shouldRefreshOutput = argv.includes('--refresh');
6161

62-
// Installeer spectral als die nog niet er is
63-
await execute(`which spectral || npm install --yes -g @stoplight/spectral-cli`);
64-
6562
for (const apiLocation of await obtainAllTestcases()) {
6663
const actualOutput = await runCommand(apiLocation);
6764

‎media/linter.yaml‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Deze linter configuratie is geschreven voor Spectral. Voor meer informatie over
2-
# die tool, zie https://stoplight.io/open-source/spectral
1+
# Deze linter configuratie is geschreven voor Openlint. Voor meer informatie over
2+
# die tool, zie https://docs.openlint.org/
33
#
44
# De linter configuratie wordt tevens gehost op https://developer.overheid.nl (DON).
55
# Deze kan worden gebruikt in onder andere CI systemen voor live updates van de
@@ -12,13 +12,11 @@
1212
# te draaien:
1313
#
1414
# ```
15-
# npm install -g @stoplight/spectral-cli
16-
# curl -L https://static.developer.overheid.nl/adr/ruleset.yaml > .linter.yaml
17-
# spectral lint -r .linter.yaml $OAS_URL_OR_FILE
15+
# npx @developer-overheid-nl/don-checker@latest validate --standard adr --input $OAS_URL_OR_FILE
1816
# ```
1917

2018
extends:
21-
- ["spectral:oas", "off"] # extend spectral:oas maar zet standaard alle regels uit
19+
- ["openlint:openapi", "off"] # extend openlint:openapi maar zet standaard alle regels uit
2220

2321
formats:
2422
- oas3

0 commit comments

Comments
 (0)