Merge pull request #70 from fan9704/feat_channel_mqtt #191
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: Pet Monitoring Backend Development CI Pipeline | |
on: | |
workflow_call: | |
workflow_dispatch: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
DJANGO_SECRET_KEY: "erqwer23" | |
PYTHON_VERSION: "3.10" | |
DOCKER_REPO: "pet-monitoring-system-backend" | |
FIREBASE_PRIVATE_KEY: ${{ secrets.FIREBASE_PRIVATE_KEY }} | |
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Create env file | |
run: | | |
echo "${{ env.ENV_FILE }}" > .env | |
source .env | |
- name: Docker Compose Action | |
uses: isbang/compose-action@v1.4.1 | |
with: | |
compose-file: "./docker-compose.yml" | |
# - name: Enable RabbitMQ Plugins | |
# run: | | |
# docker exec rabbitmq rabbitmq-plugins enable rabbitmq_mqtt rabbitmq_web_mqtt rabbitmq_web_stomp | |
- name: Setup Python ${{ env.PYTHON_VERSION }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Install pipenv | |
run: pip install pipenv | |
- name: Install Dependencies from pipenv | |
run: | | |
pipenv install | |
pipenv run pip freeze > requirements.txt | |
pip install -r requirements.txt | |
rm requirements.txt | |
- name: Install coverage | |
run: pip install coverage | |
- name: Django Make Migration Checking | |
run: | | |
pipenv run python manage.py makemigrations | |
- name: Django Migrate Database to postgresql | |
run: | | |
pipenv run python manage.py migrate | |
- name: Create Testing Database | |
run : | | |
pipenv run python manage.py create_test_db | |
- name: Run Tests | |
run: | | |
coverage run manage.py test | |
coverage xml -o coverage.xml | |
- name: Sonarqube Scanning | |
uses: sonarsource/sonarqube-scan-action@master | |
env: | |
SONAR_TOKEN: ${{ env.SONAR_TOKEN }} | |
SONAR_HOST_URL: ${{ env.SONAR_HOST_URL }} | |
EXTRA_ARGS: -Dsonar.coverageReportPaths=coverage.xml | |
# - name: DockerHub Login | |
# uses: docker/login-action@v2.1.0 | |
# with: | |
# username: ${{ secrets.DOCKERHUB_USERNAME }} | |
# password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
# | |
# - name: Build the Docker image | |
# run: docker build . --file Dockerfile --tag ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKER_REPO }} | |
# | |
# - name: Docker Push | |
# run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKER_REPO }} |