Skip to content

Commit f190e95

Browse files
authored
Merge pull request #162 from php-api-clients/add-tests
Add tests
2 parents 777e4db + 9825d86 commit f190e95

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2204
-110
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Continuous Integration
2+
on:
3+
push:
4+
branches:
5+
- 'main'
6+
- 'master'
7+
- 'refs/heads/v[0-9]+.[0-9]+.[0-9]+'
8+
pull_request:
9+
## This workflow needs the `pull-request` permissions to work for the package diffing
10+
## Refs: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#permissions
11+
permissions:
12+
pull-requests: write
13+
contents: read
14+
jobs:
15+
ci:
16+
name: Continuous Integration
17+
uses: WyriHaximus/github-workflows/.github/workflows/package.yaml@package
18+
with:
19+
jsonPattern: "composer.json"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Generate and Test Clients
2+
on:
3+
push:
4+
branches:
5+
- 'main'
6+
- 'master'
7+
- 'refs/heads/v[0-9]+.[0-9]+.[0-9]+'
8+
pull_request:
9+
jobs:
10+
generate-and-test-client:
11+
name: Continuous Integration
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
client: ["miele", "one"]
16+
uses: ./.github/workflows/test-client.yaml
17+
with:
18+
name: ${{ matrix.client }}

.github/workflows/single-client.yaml renamed to .github/workflows/test-client.yaml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
name: Continuous Integration (Single Client)
1+
name: Generate and test client
22
on:
3-
push:
4-
branches:
5-
- 'main'
6-
- 'master'
7-
- 'refs/heads/v[0-9]+.[0-9]+.[0-9]+'
8-
pull_request:
3+
workflow_call:
4+
inputs:
5+
name:
6+
description: Name of the client to test
7+
required: true
8+
type: string
99
jobs:
1010
generate-and-test-client:
1111
runs-on: ubuntu-latest
@@ -18,13 +18,13 @@ jobs:
1818
fetch-depth: '0'
1919
persist-credentials: 'false'
2020
- uses: "ramsey/composer-install@v2"
21-
- run: make generate-example-client-one
21+
- run: make generate-example-client-${{ inputs.name }}
2222
- name: Tar example files
2323
run: tar -czf example.tar ./example
2424
- name: Upload Generated Client
2525
uses: actions/upload-artifact@v3
2626
with:
27-
name: example-single-client
27+
name: example-${{ inputs.name }}-client
2828
path: ./example.tar
2929
supported-versions-matrix:
3030
name: Supported Versions Matrix
@@ -50,14 +50,14 @@ jobs:
5050
- name: Download Generated Client
5151
uses: actions/download-artifact@v3
5252
with:
53-
name: example-single-client
53+
name: example-${{ inputs.name }}-client
5454
path: ./
5555
- name: UnTar example files
56-
run: tar -xzf example.tar
56+
run: tar -xzf example.tar
5757
- id: supported-checks-matrix
5858
name: Generate check
5959
run: |
60-
cd example/generated
60+
cd example/generated-${{ inputs.name }}
6161
printf "Checks found: %s\r\n" $(make task-list-ci)
6262
printf "::set-output name=check::%s" $(make task-list-ci)
6363
qa:
@@ -83,23 +83,23 @@ jobs:
8383
- name: Download Generated Client
8484
uses: actions/download-artifact@v3
8585
with:
86-
name: example-single-client
86+
name: example-${{ inputs.name }}-client
8787
path: ./
8888
- name: UnTar example files
89-
run: tar -xzf example.tar
89+
run: tar -xzf example.tar
9090
- uses: ramsey/composer-install@v2
9191
with:
92-
working-directory: "example/generated/"
92+
working-directory: "example/generated-${{ inputs.name }}/"
9393
ignore-cache: "yes"
9494
- run: |
95-
cd example/generated
95+
cd example/generated-${{ inputs.name }}
9696
make ${{ matrix.check }} || true
9797
if: needs.supported-versions-matrix.outputs.upcoming == matrix.php
9898
env:
9999
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
100100
COVERALLS_RUN_LOCALLY: ${{ secrets.COVERALLS_RUN_LOCALLY }}
101101
- run: |
102-
cd example/generated
102+
cd example/generated-${{ inputs.name }}
103103
make ${{ matrix.check }}
104104
if: needs.supported-versions-matrix.outputs.upcoming != matrix.php
105105
env:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ example/etc
44
example/generated-github
55
example/generated-github-subsplit
66
example/generated-miele
7+
tests/test-app
78
vendor

etc/ci/markdown-link-checker.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"ignorePatterns": [
3+
{
4+
"pattern": "^(.*){{[^}]+([^{])*}}(.*)$"
5+
}
6+
],
7+
"httpHeaders": [
8+
{
9+
"urls": ["https://docs.github.com/"],
10+
"headers": {
11+
"Accept-Encoding": "zstd, br, gzip, deflate"
12+
}
13+
}
14+
]
15+
}

etc/qa/phpcs.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
<file>../../src</file>
1010
<file>../../tests</file>
11+
<exclude-pattern type="relative-root">*/tests/app/*</exclude-pattern>
12+
<exclude-pattern type="relative-root">*/tests/test-app/*</exclude-pattern>
1113

1214
<rule ref="WyriHaximus-OSS" />
1315
</ruleset>

etc/qa/phpstan.neon

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
parameters:
2+
excludePaths:
3+
- ../../tests/app/*
4+
- ../../tests/test-app/*
25
ignoreErrors:
36
- '#cebe\\openapi\\spec\\Reference#'
47
- '#Call to function in_array\(\) requires parameter \#3 to be true.#'

etc/qa/phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<phpunit bootstrap="../../vendor/autoload.php" colors="true">
33
<testsuites>
44
<testsuite name="Test Suite">
5-
<directory>../../tests/</directory>
5+
<file>../../tests/GenerateTest.php</file>
66
</testsuite>
77
</testsuites>
88
<filter>

example/openapi-client-miele.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,3 @@ voter:
3232
- ApiClients\Tools\OpenApiClientGenerator\Voter\ListOperation\PageAndPerPageInQuery
3333
streamOperation:
3434
- ApiClients\Tools\OpenApiClientGenerator\Voter\StreamOperation\DownloadInOperationId
35-

src/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct(
2525
public string $spec,
2626
#[MapFrom('entryPoints')]
2727
public EntryPoints $entryPoints,
28-
public Templates $templates,
28+
public ?Templates $templates,
2929
public Namespace_ $namespace,
3030
public Destination $destination,
3131
#[MapFrom('contentType')]

0 commit comments

Comments
 (0)