-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
116 lines (101 loc) · 3.93 KB
/
action.yml
File metadata and controls
116 lines (101 loc) · 3.93 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Code validation and document generation
description: Run poetry tests and generate FastAPI docs
inputs:
app-name:
description: Name of the App
required: true
environment:
description: Environment this action runs on
required: false
work-dir:
description: Location of all the App-related files
required: true
python-version:
description: Version of Python app is using
required: true
portal-url:
description: Server path to store files
required: false
artifact:
description: Name of artifact
required: false
default: "xml-reports"
outputs:
REDOC_LINKS: # id of output
description: "Redoc documents links"
value: ${{ steps.redoc.outputs.REDOC_LINKS }}
COVERAGE_LINKS:
description: "Link to coverage report"
value: ${{ steps.cov_link.outputs.COVERAGE_LINKS }}
runs:
using: "composite"
steps:
## Poetry tests
- name: Check out repository
uses: actions/checkout@v4.1.1
- name: Set up Python
uses: actions/setup-python@v4.7.1
with:
python-version: ${{ inputs.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1.3.4
- name: Install dependencies
run: |
echo "<<<< --- Install dependencies --- >>>>"
cd ${{ inputs.work-dir }}
poetry env use ${{ inputs.python-version }}
poetry install --no-interaction --no-root
poetry run pip install pytest-cov ## need this for cov flag
shell: bash
- name: Run poethepoet
run: |
echo "<<<< --- Run poethepoet --- >>>>"
cd ${{ inputs.work-dir }}
source config.sh.example && poetry run poe codevalidation
shell: bash
- name: Generate XML report
run: |
echo "<<<< --- Generate XML report --- >>>>"
cd ${{ inputs.work-dir }}
source config.sh.example && poetry run pytest --cov --cov-report=xml:coverage.xml
shell: bash
- name: Upload XML reports
uses: actions/upload-artifact@v4.1.0
with:
name: ${{ inputs.artifact }}
path: ${{ inputs.work-dir }}/coverage.xml
retention-days: 5
# Doc generation
- name: Get PR branch # this only works on a PR not on a branch
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/*/})" >> $GITHUB_ENV
shell: bash
- name: Set branch name
if: ${{ github.ref != 'refs/heads/main' }}
run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF} | tr / -)" >> $GITHUB_ENV
shell: bash
- name: Get repo name
run: echo "REPO_NAME=${{ github.event.repository.name }}" >> $GITHUB_ENV
shell: bash
- name: Clean old models
if: ${{ github.ref == 'refs/heads/main' && inputs.portal-url != '' }}
run: rm /mnt/samba/${{ env.REPO_NAME }}/main_* 2> /dev/null || true
shell: bash
- name: Generate documentation links
if: ${{ inputs.portal-url != '' }}
id: redoc
run: |
echo "<<<< --- Generate documentation links --- >>>>"
cd ${{ inputs.work-dir }}
[ -d /mnt/samba/${{ env.REPO_NAME }} ] || mkdir -p /mnt/samba/${{ env.REPO_NAME }}
LINKS=(`source config.sh.example && poetry run python generate_openapi_docs.py ${{ env.BRANCH_NAME }} "/mnt/samba/${{ env.REPO_NAME }}" "${{ inputs.portal-url }}/redoc.html?repo=${{ env.REPO_NAME }}&branch="`)
echo "REDOC_LINKS=${LINKS[@]}" >> $GITHUB_OUTPUT
shell: bash
- name: Generate coverage HTML link
if: ${{ inputs.portal-url != '' }}
id: cov_link
run: |
echo "<<<< --- Generate coverage HTML link --- >>>>"
cd ${{ inputs.work-dir }}
COVERAGE=(`source config.sh.example && poetry run pytest --cov --cov-report=html:/mnt/samba/${{ env.REPO_NAME }}/${{ env.BRANCH_NAME }}/${{inputs.app-name}}/coverage`)
echo "COVERAGE_LINKS=${{ inputs.portal-url }}/coverage.html?repo=${{ env.REPO_NAME }}&branch=${{ env.BRANCH_NAME }}&app=${{inputs.app-name}}" >> $GITHUB_OUTPUT
shell: bash