change to sonarqube #41
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: Django CI | |
on: | |
push: | |
branches: [ "main", "staging" ] | |
pull_request: | |
branches: [ "main", "staging" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
max-parallel: 4 | |
matrix: | |
python-version: [3.11] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Run Tests | |
run: | | |
python manage.py test | |
sonarqube: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.11 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install coverage | |
- name: Run tests and generate coverage | |
run: | | |
coverage run --source='.' manage.py test | |
coverage xml -o ./coverage.xml | |
- name: List Directories | |
run: | | |
echo "Directories in GitHub workflow:" | |
find "$GITHUB_WORKSPACE" -type d -print | |
- name: Install SonarQube Scanner | |
run: | | |
wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.2.2472-linux.zip | |
unzip sonar-scanner-cli-4.6.2.2472-linux.zip | |
sudo mv sonar-scanner-4.6.2.2472-linux /opt/sonar-scanner | |
echo "SONAR_SCANNER_HOME=/opt/sonar-scanner" >> $GITHUB_ENV | |
echo "/opt/sonar-scanner/bin" >> $GITHUB_PATH | |
- name: Run SonarQube Scanner | |
run: sonar-scanner -D"sonar.projectKey=revelio" -D"sonar.sources=." -D"sonar.host.url=https://sonarqube.cs.ui.ac.id" -D"sonar.login=$SONAR_TOKEN" | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |