Fix sonarcloud project id (#310) #965
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 | |
# Events that trigger workflow | |
on: | |
pull_request: | |
push: | |
branches: | |
- master | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
- 'v[0-9]+.[0-9]+.[0-9]+-[a-z]+.[0-9]+' | |
# Jobs can run sequentially or in parallel | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ['3.9', '3.10', '3.11', '3.12'] | |
steps: | |
- name: Checkout pull request HEAD commit instead of merge commit | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install source package and dependencies | |
run: | | |
python -m pip install -e .[dev] | |
- name: Run linting | |
run: | | |
make lint | |
- name: Run unit tests | |
run: | | |
make test/unit | |
- name: run the integration tests | |
run: make test/integration | |
- name: Inject PR number into coverage.xml | |
if: matrix.python-version == '3.11' | |
run: sed -i '2i <!-- PR ${{ github.event.number }} -->' coverage.xml | |
- name: upload coverage as artifact | |
if: matrix.python-version == '3.11' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage | |
path: coverage.xml | |
- name: SonarCloud Scan | |
uses: SonarSource/sonarcloud-github-action@master | |
if: github.event_name == 'push' && github.repository == 'ansible/galaxy-importer' && github.ref_name == 'master' && matrix.python-version == '3.11' | |
env: | |
SONAR_TOKEN: ${{ secrets.CICD_ORG_SONAR_TOKEN_CICD_BOT }} | |
publish: | |
name: Build and publish to PyPI registry | |
if: startsWith(github.ref, 'refs/tags') | |
needs: build-and-test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.10" | |
- name: pip install build | |
run: | | |
python -m pip install build --user | |
- name: Build a binary wheel and a source tarball | |
run: | | |
python -m build --sdist --wheel --outdir dist/ . | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.pypi_token }} |