-
Notifications
You must be signed in to change notification settings - Fork 78
81 lines (71 loc) · 2.6 KB
/
validate-client-generation.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Validate Client Generation
on:
workflow_run:
workflows:
- 'Spec PR'
types:
- completed
jobs:
validate-client-gen:
name: Validate Client Generation
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
steps:
- name: Check out openapi
uses: actions/checkout@v2.5.0
- name: Add check to PR
run: |
gh api --method POST -H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/statuses/${{ github.event.workflow_run.head_sha }} \
-f state='pending' \
-f target_url='${{ env.target_url }}' \
-f description='Starting pydo validation' \
-f context='${{ github.workflow }}'
- name: Check out pydo repo
uses: actions/checkout@v2.5.0
with:
repository: digitalocean/pydo
path: pydo
- name: Install Poetry
uses: snok/install-poetry@v1.3.1
with:
version: 1.1.13
virtualenvs-path: .venv
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: false
- name: Download PR spec
run: |
gh run download ${{ github.event.workflow_run.id }} -n openapi-bundled
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Test Python client generation
id: test-client
working-directory: pydo
run: |
SPEC_FILE=../openapi-bundled.yaml make generate
make test-mocked
- name: Results
if: always()
run: |
if [[ ${{ steps.test-client.outcome }} == 'success' ]]; then
echo "test_result=success" >> $GITHUB_ENV
echo "check_description=Successfully validated generated client" >> $GITHUB_ENV
else
echo "test_result=failure" >> $GITHUB_ENV
echo "check_description=Failed to validate generated client" >> $GITHUB_ENV
fi
- name: Update check on PR
if: always()
run: |
gh api --method POST -H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/statuses/${{ github.event.workflow_run.head_sha }} \
-f state='${{ env.test_result }}' \
-f target_url='${{ env.target_url }}' \
-f description='${{ env.check_description }}' \
-f context='${{ github.workflow }}'