|
9 | 9 | description: "pact-python branch or tag" |
10 | 10 | default: main |
11 | 11 | required: false |
| 12 | + js_ref: |
| 13 | + description: "pact-js branch or tag" |
| 14 | + default: master |
| 15 | + required: false |
| 16 | + go_ref: |
| 17 | + description: "pact-go branch or tag" |
| 18 | + default: master |
| 19 | + required: false |
| 20 | + dotnet_ref: |
| 21 | + description: "pact-net branch or tag" |
| 22 | + default: master |
| 23 | + required: false |
| 24 | + php_ref: |
| 25 | + description: "pact-php branch or tag" |
| 26 | + default: master |
| 27 | + required: false |
| 28 | + jvm_ref: |
| 29 | + description: "pact-jvm branch or tag" |
| 30 | + default: master |
| 31 | + required: false |
| 32 | + swift_ref: |
| 33 | + description: "PactSwift branch or tag" |
| 34 | + default: main |
| 35 | + required: false |
12 | 36 |
|
13 | 37 | jobs: |
14 | 38 | generate: |
15 | 39 | name: Generate ${{ matrix.sdk }} DSL |
16 | 40 | runs-on: ubuntu-latest |
17 | | - permissions: |
18 | | - contents: write |
19 | 41 | strategy: |
20 | 42 | fail-fast: false |
21 | 43 | matrix: |
22 | 44 | include: |
23 | 45 | - sdk: python |
| 46 | + repo: pact-python |
24 | 47 | script: scripts/generate/dsl_python.py |
25 | | - output: plugins/swagger-contract-testing/skills/pactflow/references/dsl.python.md |
| 48 | + outputs: plugins/swagger-contract-testing/skills/pactflow/references/dsl.python.md |
26 | 49 | ref_input: python_ref |
| 50 | + - sdk: javascript |
| 51 | + repo: pact-js |
| 52 | + script: scripts/generate/dsl_js.py |
| 53 | + outputs: >- |
| 54 | + plugins/swagger-contract-testing/skills/pactflow/references/dsl.typescript.md |
| 55 | + plugins/swagger-contract-testing/skills/pactflow/references/dsl.javascript.md |
| 56 | + ref_input: js_ref |
| 57 | + - sdk: golang |
| 58 | + repo: pact-go |
| 59 | + script: scripts/generate/dsl_go.py |
| 60 | + outputs: plugins/swagger-contract-testing/skills/pactflow/references/dsl.golang.md |
| 61 | + ref_input: go_ref |
| 62 | + - sdk: dotnet |
| 63 | + repo: pact-net |
| 64 | + script: scripts/generate/dsl_dotnet.py |
| 65 | + outputs: plugins/swagger-contract-testing/skills/pactflow/references/dsl.dotnet.md |
| 66 | + ref_input: dotnet_ref |
| 67 | + - sdk: php |
| 68 | + repo: pact-php |
| 69 | + script: scripts/generate/dsl_php.py |
| 70 | + outputs: plugins/swagger-contract-testing/skills/pactflow/references/dsl.php.md |
| 71 | + ref_input: php_ref |
| 72 | + - sdk: jvm |
| 73 | + repo: pact-jvm |
| 74 | + script: scripts/generate/dsl_jvm.py |
| 75 | + outputs: >- |
| 76 | + plugins/swagger-contract-testing/skills/pactflow/references/dsl.kotlin.md |
| 77 | + plugins/swagger-contract-testing/skills/pactflow/references/dsl.java.md |
| 78 | + ref_input: jvm_ref |
| 79 | + - sdk: swift |
| 80 | + repo: PactSwift |
| 81 | + script: scripts/generate/dsl_swift.py |
| 82 | + outputs: plugins/swagger-contract-testing/skills/pactflow/references/dsl.swift.md |
| 83 | + ref_input: swift_ref |
27 | 84 |
|
28 | 85 | steps: |
29 | 86 | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
30 | 87 |
|
31 | 88 | - uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 |
32 | 89 |
|
33 | | - - name: Generate dsl.${{ matrix.sdk }}.md |
34 | | - run: uv run --no-project ${{ matrix.script }} --ref "${{ inputs[matrix.ref_input] || 'main' }}" |
35 | | - |
36 | | - - name: Format dsl.${{ matrix.sdk }}.md |
37 | | - run: uvx mdformat ${{ matrix.output }} |
| 90 | + - name: Generate DSL(s) for ${{ matrix.sdk }} |
| 91 | + run: | |
| 92 | + REF="${{ inputs[matrix.ref_input] }}" |
| 93 | + uv run --project scripts/generate ${{ matrix.script }} ${REF:+--ref "$REF"} |
38 | 94 |
|
39 | | - - name: Check for changes |
40 | | - id: diff |
| 95 | + - name: Format generated markdown |
41 | 96 | run: | |
42 | | - git status --porcelain ${{ matrix.output }} | grep -q . \ |
43 | | - && echo "changed=true" >> "$GITHUB_OUTPUT" \ |
44 | | - || echo "changed=false" >> "$GITHUB_OUTPUT" |
| 97 | + for f in ${{ matrix.outputs }}; do |
| 98 | + uvx mdformat "$f" |
| 99 | + done |
| 100 | +
|
| 101 | + - name: Upload generated files |
| 102 | + uses: actions/upload-artifact@v4 |
| 103 | + with: |
| 104 | + name: dsl-${{ matrix.sdk }} |
| 105 | + path: plugins/swagger-contract-testing/skills/pactflow/references/ |
| 106 | + |
| 107 | + commit: |
| 108 | + name: Commit updated DSLs |
| 109 | + needs: generate |
| 110 | + if: ${{ !cancelled() }} |
| 111 | + runs-on: ubuntu-latest |
| 112 | + permissions: |
| 113 | + contents: write |
| 114 | + steps: |
| 115 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 116 | + |
| 117 | + - name: Download generated DSL files |
| 118 | + uses: actions/download-artifact@v4 |
| 119 | + with: |
| 120 | + pattern: dsl-* |
| 121 | + merge-multiple: true |
| 122 | + path: plugins/swagger-contract-testing/skills/pactflow/references/ |
45 | 123 |
|
46 | | - - name: Commit updated dsl.${{ matrix.sdk }}.md |
47 | | - if: steps.diff.outputs.changed == 'true' |
| 124 | + - name: Commit and push if changed |
48 | 125 | run: | |
49 | 126 | git config user.name "github-actions[bot]" |
50 | 127 | git config user.email "github-actions[bot]@users.noreply.github.com" |
51 | | - git add ${{ matrix.output }} |
52 | | - git commit -m "chore: regenerate dsl.${{ matrix.sdk }}.md from pact-${{ matrix.sdk }}" |
53 | | - git push |
| 128 | + git add plugins/swagger-contract-testing/skills/pactflow/references/ |
| 129 | + if ! git diff --staged --quiet; then |
| 130 | + git commit -m "chore: regenerate DSL references" |
| 131 | + git push |
| 132 | + fi |
0 commit comments