chore(deps): bump django from 5.0.9 to 5.0.10 (#430) #650
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: main | |
on: | |
pull_request: | |
branches: | |
- '*' | |
push: | |
branches: | |
- main | |
tags: | |
- '*' | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
- name: Install system deps | |
run: sudo apt-get update && sudo apt-get -y install gcc libkrb5-dev | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Run linter | |
run: | | |
pip install ruff | |
ruff check . | |
- name: Run safety check | |
run: | | |
pip install safety | |
safety check -i 42240,66963,70612,65213 | |
test: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:13 | |
env: | |
POSTGRES_DB: portail_test | |
POSTGRES_USER: portail_dev_limited_rw | |
POSTGRES_PASSWORD: portail_psswd | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd "pg_isready -U testuser" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Cache Python packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install system deps | |
run: | | |
sudo apt-get update && sudo apt-get -y install gcc libkrb5-dev | |
sudo locale-gen fr_FR.utf8 | |
sudo update-locale | |
- name: Install dependencies | |
run: | | |
pip install -r requirements.txt | |
- name: Set up Django environment variables and config | |
run: | | |
cp .conf/.test.env admin_cohort/.env | |
mkdir log | |
echo "DATABASE_URL=postgres://portail_dev_limited_rw:portail_psswd@localhost:5432/portail_test" >> $GITHUB_ENV | |
- name: Run Django migrations | |
run: | | |
python manage.py migrate | |
- name: Run tests | |
run: | | |
coverage run --source='.' --omit="*/test*","*/migrations/*" manage.py test | |
coverage xml --omit="*/test*","*/migrations/*" -o coverage.xml | |
- name: Upload coverage report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-report | |
path: coverage.xml | |
sonar: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- name: Download coverage report | |
uses: actions/download-artifact@v4 | |
with: | |
name: coverage-report | |
- name: Retrieve version | |
run: | | |
VERSION=$(head -n 20 ./admin_cohort/settings.py | grep VERSION | head -1 | awk -F'=' '{ print $2 }' | sed "s/[\"' ]//g") | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: SonarCloud Scan | |
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.projectVersion=${{ env.VERSION }} | |
publish: | |
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Cache Python packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install system deps | |
run: sudo apt-get update && sudo apt-get -y install gcc libkrb5-dev | |
- name: Install dependencies | |
run: | | |
pip install -r requirements.txt | |
- name: Retrieve version | |
run: | | |
VERSION=$(head -n 20 ./admin_cohort/settings.py | grep VERSION | head -1 | awk -F'=' '{ print $2 }' | sed "s/[\"' ]//g") | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: ${{ github.ref == 'refs/heads/main' && format('aphpid/cohort360-backend:{0},aphpid/cohort360-backend:latest',env.VERSION) || format('aphpid/cohort360-backend:{0}',env.VERSION) }} |