make project work and improve on features #792
This file contains hidden or 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 | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| services: | |
| #Start a postgres container for test runs | |
| postgres: | |
| image: postgres:latest | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: github_actions | |
| ports: | |
| - 5432:5432 | |
| options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python 3.10 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.10' | |
| - name: Install Poetry | |
| working-directory: ./backend | |
| run: pip install poetry | |
| - name: Install dependencies | |
| run: | | |
| cd backend | |
| poetry install --no-root | |
| cd ../frontend | |
| npm install | |
| - name: Set Django Secret Key | |
| id: set-secret-key | |
| run: | | |
| echo "DJANGO_SECRET_KEY=$(openssl rand -base64 32)" >> $GITHUB_ENV | |
| echo "::set-output name=secret_key::$(openssl rand -base64 32)" | |
| - name: Pylint | |
| working-directory: ./backend | |
| run: poetry run pylint --fail-under=8 backend ilotalo scheduler tests | |
| - name: Make migrations | |
| working-directory: ./backend | |
| run: poetry run python manage.py makemigrations | |
| - name: Migrate | |
| working-directory: ./backend | |
| run: poetry run python manage.py migrate | |
| - name: Run backend tests | |
| working-directory: ./backend | |
| run: | | |
| poetry run coverage run --source='.' manage.py test tests | |
| poetry run coverage xml -o coverage.xml | |
| - name: Run frontend tests | |
| if: success() || failure() | |
| working-directory: ./frontend | |
| run: npm run test | |
| # Cypress tests are disabled for now | |
| # - name: Start backend | |
| # run: | | |
| # cd backend | |
| # poetry run python manage.py runserver & | |
| # - name: Run Cypress tests | |
| # uses: cypress-io/github-action@v3 | |
| # with: | |
| # working-directory: ./frontend | |
| # project: ./ | |
| # browser: chrome | |
| # build: npm run build | |
| # start: npm run dev | |
| - name: Upload coverage reports to Codecov | |
| if: always() | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| files: ./backend/coverage.xml,./frontend/coverage/clover.xml | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Upload Test Coverage Artifacts | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-reports | |
| path: | | |
| backend/coverage.xml | |
| frontend/coverage/ |