Add CI #34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |