-
Notifications
You must be signed in to change notification settings - Fork 4
101 lines (89 loc) · 2.75 KB
/
api-client.yaml
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# A lot of this was inspired by https://brunoscheufler.com/blog/2022-04-24-required-github-actions-jobs-in-a-monorepo
name: API-Client
on:
pull_request:
paths:
- 'api-client/**'
- '.github/workflows/api-client.yaml'
jobs:
change-detection:
runs-on: ubuntu-latest
outputs:
api-client: ${{ steps.changes.outputs.api-client }}
steps:
- uses: dorny/paths-filter@v2
id: changes
with:
list-files: shell
filters: |
api-client:
- 'api-client/**'
tests:
needs: change-detection
if: needs.change-detection.outputs.api-client == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install NPM packages
working-directory: ./api-client
run: yarn install
- name: Setting up .environment variables
working-directory: ./api-client
run: cp .env.sample .env
- name: Download a openapi_spec
uses: dawidd6/action-download-artifact@v2
with:
name: openapi_spec_artifact
workflow: openapi.yaml
workflow_conclusion: success
check_artifacts: true
path: ./docs/generated
- name: Generating Typescript API
working-directory: ./api-client
run: yarn run generate-api
- name: Lint
working-directory: ./api-client
run: yarn run lint
shell: bash
- name: Unit tests
working-directory: ./api-client
run: yarn run test
shell: bash
after-tests:
needs: tests # run after tests
runs-on: ubuntu-latest
if: success() # only run when all test have passed
# store success output flag for ci job
outputs:
success: ${{ steps.setoutput.outputs.success }}
steps:
- id: setoutput
run: echo "::set-output name=success::true"
dummy-step:
runs-on: ubuntu-latest
needs: change-detection
# runs if API-Client was not changed
if: needs.change-detection.outputs.api-client == 'false'
outputs:
success: ${{ steps.setoutput.outputs.success }}
steps:
- id: setoutput
run: echo "::set-output name=success::true"
# step that will be used for required status check
# make sure it has a unique name! this will always run, but
# after the tests & after-tests steps or the dummy step in case
# the API was not modified
ci_api_client:
runs-on: ubuntu-20.04
if: always()
needs: [tests, after-tests, dummy-step]
steps:
- run: |
passed="${{ needs.after-tests.outputs.success || needs.dummy-step.outputs.success }}"
if [[ $passed == "true" ]]; then
echo "Tests passed"
exit 0
else
echo "Tests failed"
exit 1
fi