-
Notifications
You must be signed in to change notification settings - Fork 108
138 lines (115 loc) · 3.87 KB
/
paig-server-ci.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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: paig-server-ci
on:
push:
branches: [ "main" ]
paths:
- 'paig-server/**'
pull_request:
branches: [ "main" ]
paths:
- 'paig-server/**'
workflow_dispatch: # Allows manual trigger
permissions:
contents: read
jobs:
build_and_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4 # Ensure the repo is checked out
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Set sanitized branch name
run: |
# Get branch name and sanitize it
BRANCH_NAME="${GITHUB_REF_NAME//[^a-zA-Z0-9-]/-}" # Replace invalid characters with '-'
# Remove leading and trailing hyphens
BRANCH_NAME="${BRANCH_NAME##-}" # Trim leading hyphens
BRANCH_NAME="${BRANCH_NAME%%-}" # Trim trailing hyphens
echo "SANITIZED_BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
- name: Prepare venv
run: |
python3 -m pip install virtualenv
virtualenv -p python3 venv
. venv/bin/activate
pip install twine build pytest pytest-cov
- name: Build and Install paig-common wheel
run: |
. venv/bin/activate
cd paig-common
python3 -m build -w
pip install dist/*.whl
cd ..
- name: Build and Install paig-authorizer-core wheel
run: |
. venv/bin/activate
cd paig-authorizer-core
python3 -m build -w
pip install dist/*.whl
cd ..
- name: Build and Install paig-evaluation wheel
run: |
. venv/bin/activate
cd paig-evaluation
python3 -m build -w
pip install dist/*.whl
cd ..
- name: Build and Install paig-evaluation wheel
run: |
. venv/bin/activate
cd paig-evaluation
python3 -m build -w
pip install dist/*.whl
cd ..
- name: Install PAIG-Server dependencies
run: |
. venv/bin/activate
pip install -r paig-server/backend/requirements.txt
- name: Test with pytest
run: |
filepath=$PWD
. venv/bin/activate && cd paig-server/backend/paig
python3 -m pytest --cov="." --cov-report term --cov-report xml:$filepath/coverage-${{ env.SANITIZED_BRANCH_NAME }}.xml --junitxml=$filepath/junit-${{ env.SANITIZED_BRANCH_NAME }}.xml tests
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report-${{ env.SANITIZED_BRANCH_NAME }}
path: coverage-${{ env.SANITIZED_BRANCH_NAME }}.xml
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: junit-results-${{ env.SANITIZED_BRANCH_NAME }}
path: junit-${{ env.SANITIZED_BRANCH_NAME }}.xml
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- name: Install Node.js dependencies and build UI
run: |
cd paig-server/scripts
sh build_ui.sh
- name: Set build version to dev
id: version
run: |
FILE=paig-server/backend/paig/VERSION
VERSION=$(awk -F= '{gsub(/^[ \t]+|[ \t]+$/, "", $2); gsub(/^['\''"]+|['\''"]+$/, "", $2); print $2}' $FILE)
DEV_VERSION="${VERSION}+${SANITIZED_BRANCH_NAME}$(date +%Y%m%d%H%M%S)"
echo "__version__ = '${DEV_VERSION}'" > $FILE
- name: Build the wheel
run: |
. venv/bin/activate
cd paig-server
python3 -m build -w
- name: Install created package
run: |
rm -rf venv
virtualenv -p python3 venv && . venv/bin/activate
cd paig-server
pip install dist/*.whl
- name: Upload python package
uses: actions/upload-artifact@v4
with:
name: paig-server-${{ env.SANITIZED_BRANCH_NAME }}-build
path: paig-server/dist/*.whl