Skip to content

Commit 1527af4

Browse files
committed
chore: add basics for openapi extractor
Signed-off-by: Christian Hartmann <chris-hartmann@gmx.de>
1 parent bdc0df9 commit 1527af4

4 files changed

Lines changed: 343 additions & 0 deletions

File tree

.github/workflows/openapi.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# This workflow is provided via the organization template repository
2+
#
3+
# https://github.com/nextcloud/.github
4+
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5+
#
6+
# SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
7+
# SPDX-FileCopyrightText: 2024 Arthur Schiwon <blizzz@arthur-schiwon.de>
8+
# SPDX-License-Identifier: MIT
9+
10+
name: OpenAPI
11+
12+
on: pull_request
13+
14+
permissions:
15+
contents: read
16+
17+
concurrency:
18+
group: openapi-${{ github.head_ref || github.run_id }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
openapi:
23+
runs-on: ubuntu-latest
24+
25+
if: ${{ github.repository_owner != 'nextcloud-gmbh' }}
26+
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
30+
31+
- name: Get php version
32+
id: php_versions
33+
uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1
34+
35+
- name: Set up php
36+
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
37+
with:
38+
php-version: ${{ steps.php_versions.outputs.php-available }}
39+
extensions: xml
40+
coverage: none
41+
ini-file: development
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
45+
- name: Check Typescript OpenApi types
46+
id: check_typescript_openapi
47+
uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0
48+
with:
49+
files: "src/types/openapi/openapi*.ts"
50+
51+
- name: Read package.json node and npm engines version
52+
if: steps.check_typescript_openapi.outputs.files_exists == 'true'
53+
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
54+
id: node_versions
55+
# Continue if no package.json
56+
continue-on-error: true
57+
with:
58+
fallbackNode: '^20'
59+
fallbackNpm: '^10'
60+
61+
- name: Set up node ${{ steps.node_versions.outputs.nodeVersion }}
62+
if: ${{ steps.node_versions.outputs.nodeVersion }}
63+
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
64+
with:
65+
node-version: ${{ steps.node_versions.outputs.nodeVersion }}
66+
67+
- name: Set up npm ${{ steps.node_versions.outputs.npmVersion }}
68+
if: ${{ steps.node_versions.outputs.nodeVersion }}
69+
run: npm i -g 'npm@${{ steps.node_versions.outputs.npmVersion }}'
70+
71+
- name: Install dependencies & build
72+
if: ${{ steps.node_versions.outputs.nodeVersion }}
73+
env:
74+
CYPRESS_INSTALL_BINARY: 0
75+
PUPPETEER_SKIP_DOWNLOAD: true
76+
run: |
77+
npm ci
78+
79+
- name: Set up dependencies
80+
run: composer i
81+
82+
- name: Regenerate OpenAPI
83+
run: composer run openapi
84+
85+
- name: Check openapi*.json and typescript changes
86+
run: |
87+
bash -c "[[ ! \"`git status --porcelain `\" ]] || (echo 'Please run \"composer run openapi\" and commit the openapi*.json files and (if applicable) src/types/openapi/openapi*.ts, see the section \"Show changes on failure\" for details' && exit 1)"
88+
89+
- name: Show changes on failure
90+
if: failure()
91+
run: |
92+
git status
93+
git --no-pager diff
94+
exit 1 # make it red to grab attention

psalm.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
</ignoreFiles>
2323
</extraFiles>
2424
<issueHandlers>
25+
<LessSpecificReturnStatement errorLevel="error"/>
26+
<LessSpecificReturnType errorLevel="error"/>
27+
<LessSpecificImplementedReturnType errorLevel="error"/>
28+
<MoreSpecificReturnType errorLevel="error"/>
2529
<UndefinedClass>
2630
<errorLevel type="suppress">
2731
<referencedClass name="OCA\Circles\CirclesManager" />
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"require-dev": {
3+
"nextcloud/openapi-extractor": "^1.0"
4+
}
5+
}

vendor-bin/openapi-extractor/composer.lock

Lines changed: 240 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)