forked from SolaceLabs/solace-ai-connector
-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (131 loc) · 3.81 KB
/
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
138
139
140
141
142
143
144
name: CI
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize]
permissions:
id-token: write
checks: write
issues: read
pull-requests: write
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: |
3.9
3.10
3.12
- name: Set up pip cache
if: runner.os == 'Linux'
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
restore-keys: ${{ runner.os }}-pip-
- name: Install Hatch
run: pipx install hatch
- name: Set up Docker Buildx
id: builder
uses: docker/setup-buildx-action@v3
- name: Prepare env file
run: |
cp .env_template .env
shell: bash
- name: Build Docker Image
uses: docker/build-push-action@v6
with:
push: false
tags: solace/solace-ai-connector:local
platforms: linux/amd64
builder: ${{ steps.builder.outputs.name }}
cache-from: type=gha
cache-to: type=gha,mode=max
load: true
- name: Run Structured Tests
run: |
hatch run test:make structure-test
shell: bash
- name: Run Unit Tests
env:
HATCH_TEST_ARGS: --junitxml=junit.xml
run: |
hatch test --cover --parallel
- name: Report coverage
run: |
hatch run test:coverage xml
shell: bash
- name: SonarQube Scan
uses: sonarsource/[email protected]
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ vars.SONAR_HOST_URL }}
with:
args: >
-Dsonar.tests=tests/
-Dsonar.verbose=true
-Dsonar.sources=src/
-Dsonar.projectKey=${{github.event.repository.name}}
-Dsonar.python.coverage.reportPaths=coverage.xml
# - name: Github login
# id: get_workflow_token
# uses: peter-murray/workflow-application-token-action@v3
# with:
# application_id: ${{secrets.APP_ID }}
# application_private_key: ${{ secrets.APP_PRIVATE_KEY }}
# - name: Publish Pre Deploy Test Report
# uses: mikepenz/action-junit-report@v4
# if: always()
# with:
# report_paths: junit.xml
# fail_on_failure: false
# require_passed_tests: true
# check_annotations: false
# detailed_summary: true
# check_name: "Test Results (Linux)"
# token: ${{ steps.get_workflow_token.outputs.token }}
- name: SonarQube Quality Gate check
id: sonarqube-quality-gate-check
uses: sonarsource/sonarqube-quality-gate-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ vars.SONAR_HOST_URL }}
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Hatch
uses: pypa/hatch@install
- name: Lint
run: |
hatch fmt --check
shell: bash
package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: python -m pip install twine
- name: Install Hatch
uses: pypa/hatch@install
- name: Build
run: hatch build
- name: Verify Packages
run: |
ls dist/*.tar.gz | xargs -n1 twine check
ls dist/*.whl | xargs -n1 twine check
shell: bash