Merge pull request #31 from infn-datacloud/fix-nginx-usage #83
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: Test and analysis | |
on: | |
push: | |
branches: | |
- main | |
- devel | |
- ci | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
jobs: | |
test-analysis: | |
name: Python tests | |
runs-on: ubuntu-latest | |
services: | |
neo4j-db: | |
# Set up neo4j DB with APOC extension for UUIDs. | |
image: neo4j:5.18 | |
ports: | |
- 7687 | |
- 7474 | |
env: | |
NEO4J_AUTH: none | |
NEO4J_PLUGINS: "apoc" | |
options: >- | |
--health-cmd "wget http://localhost:7474 || exit 1" | |
--health-interval 1s | |
--health-timeout 10s | |
--health-retries 20 | |
--health-start-period 3s | |
strategy: | |
fail-fast: true | |
matrix: | |
python-version: ["3.9", "3.10", "3.11"] | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# Install and configure poetry | |
- name: Install Poetry | |
id: install-poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
# Set up python versions to use | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: poetry | |
cache-dependency-path: ${{ steps.install-poetry.cache-dir }} | |
# Install dependencies if cache does not exist | |
- name: Install dependencies | |
run: poetry install --no-interaction | |
# Run tests | |
- name: Run tests | |
run: poetry run pytest --cov --cov-report=xml --cov-report=html | |
env: | |
NEO4J_TEST_URL: "bolt://neo4j:password@localhost:${{ job.services.neo4j-db.ports[7687] }}" | |
# Upload coverage as artifacts | |
- name: Upload HTML coverage as artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: code-coverage-${{ matrix.python-version }}-html | |
path: htmlcov | |
- name: Upload XML coverage as artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: code-coverage-${{ matrix.python-version }}-xml | |
path: coverage.xml | |
# Upload coverage to SonarCloud for code analysis | |
- name: SonarCloud analysis | |
uses: SonarSource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
with: | |
args: > | |
-Dsonar.organization=${{ github.repository_owner }} | |
-Dsonar.projectKey=${{ github.repository_owner }}_federation-registry | |
-Dsonar.sources=fed_reg | |
-Dsonar.tests=tests | |
-Dsonar.python.version=${{ matrix.python-version }} | |
-Dsonar.python.coverage.reportPaths=coverage.xml |