mirror of
				https://github.com/cookiecutter/cookiecutter-django.git
				synced 2025-10-30 23:47:39 +03:00 
			
		
		
		
	Merge pull request #3076 from pydanny/fix/gh-actions-bare-metal
This commit is contained in:
		
						commit
						309da0b581
					
				|  | @ -231,7 +231,7 @@ def test_gitlab_invokes_flake8_and_pytest( | ||||||
|     ["use_docker", "expected_test_script"], |     ["use_docker", "expected_test_script"], | ||||||
|     [ |     [ | ||||||
|         ("n", "pytest"), |         ("n", "pytest"), | ||||||
|         ("y", "docker-compose -f local.yml exec -T django pytest"), |         ("y", "docker-compose -f local.yml run django pytest"), | ||||||
|     ], |     ], | ||||||
| ) | ) | ||||||
| def test_github_invokes_linter_and_pytest( | def test_github_invokes_linter_and_pytest( | ||||||
|  |  | ||||||
|  | @ -7,11 +7,11 @@ env: | ||||||
| 
 | 
 | ||||||
| on: | on: | ||||||
|   pull_request: |   pull_request: | ||||||
|     branches: [ "master" ] |     branches: [ "master", "main" ] | ||||||
|     paths-ignore: [ "docs/**" ] |     paths-ignore: [ "docs/**" ] | ||||||
| 
 | 
 | ||||||
|   push: |   push: | ||||||
|     branches: [ "master" ] |     branches: [ "master", "main" ] | ||||||
|     paths-ignore: [ "docs/**" ] |     paths-ignore: [ "docs/**" ] | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -34,30 +34,50 @@ jobs: | ||||||
|       - name: Install and Run Pre-commit  |       - name: Install and Run Pre-commit  | ||||||
|         uses: pre-commit/action@v2.0.0 |         uses: pre-commit/action@v2.0.0 | ||||||
| 
 | 
 | ||||||
| # With no caching at all the entire ci process takes 4m 30s to complete! |   # With no caching at all the entire ci process takes 4m 30s to complete! | ||||||
|   pytest: |   pytest: | ||||||
|     runs-on: ubuntu-latest |     runs-on: ubuntu-latest | ||||||
|  |     {%- if cookiecutter.use_docker == 'n' %} | ||||||
|  | 
 | ||||||
|  |     services: | ||||||
|  |       {%- if cookiecutter.use_celery == 'y' %} | ||||||
|  |       redis: | ||||||
|  |         image: redis:5.0 | ||||||
|  |         ports: | ||||||
|  |           - 6379:6379 | ||||||
|  |       {%- endif %} | ||||||
|  |       postgres: | ||||||
|  |         image: postgres:12 | ||||||
|  |         ports: | ||||||
|  |           - 5432:5432 | ||||||
|  |         env: | ||||||
|  |           POSTGRES_PASSWORD: postgres | ||||||
|  | 
 | ||||||
|  |     env: | ||||||
|  |       {%- if cookiecutter.use_celery == 'y' %} | ||||||
|  |       CELERY_BROKER_URL: "redis://localhost:6379/0" | ||||||
|  |       {%- endif %} | ||||||
|  |       # postgres://user:password@host:port/database | ||||||
|  |       DATABASE_URL: "postgres://postgres:postgres@localhost:5432/postgres" | ||||||
|  |     {%- endif %} | ||||||
|  | 
 | ||||||
|     steps: |     steps: | ||||||
| 
 | 
 | ||||||
|       - name: Checkout Code Repository |       - name: Checkout Code Repository | ||||||
|         uses: actions/checkout@v2 |         uses: actions/checkout@v2 | ||||||
|       {% if cookiecutter.use_docker == 'y' -%} |       {%- if cookiecutter.use_docker == 'y' %} | ||||||
| 
 | 
 | ||||||
|       - name: Build the Stack |       - name: Build the Stack | ||||||
|         run:  docker-compose -f local.yml build |         run:  docker-compose -f local.yml build | ||||||
| 
 | 
 | ||||||
|       - name: Make DB Migrations |       - name: Run DB Migrations | ||||||
|         run:  docker-compose -f local.yml run --rm django python manage.py migrate |         run:  docker-compose -f local.yml run --rm django python manage.py migrate | ||||||
| 
 | 
 | ||||||
|       - name: Run the Stack |  | ||||||
|         run:  docker-compose -f local.yml up -d |  | ||||||
| 
 |  | ||||||
|       - name: Run Django Tests |       - name: Run Django Tests | ||||||
|         run:  docker-compose -f local.yml exec -T django pytest |         run:  docker-compose -f local.yml run django pytest | ||||||
| 
 | 
 | ||||||
|       - name: Tear down the Stack |       - name: Tear down the Stack | ||||||
|         run:  docker-compose -f local.yml down |         run:  docker-compose -f local.yml down | ||||||
| 
 |  | ||||||
|       {%- else %} |       {%- else %} | ||||||
| 
 | 
 | ||||||
|       - name: Set up Python 3.8 |       - name: Set up Python 3.8 | ||||||
|  | @ -69,8 +89,8 @@ jobs: | ||||||
|         id: pip-cache-location |         id: pip-cache-location | ||||||
|         run: | |         run: | | ||||||
|           echo "::set-output name=dir::$(pip cache dir)" |           echo "::set-output name=dir::$(pip cache dir)" | ||||||
|  |       {%- raw %} | ||||||
| 
 | 
 | ||||||
|       {% raw %} |  | ||||||
|       - name: Cache pip Project Dependencies |       - name: Cache pip Project Dependencies | ||||||
|         uses: actions/cache@v2 |         uses: actions/cache@v2 | ||||||
|         with: |         with: | ||||||
|  | @ -80,7 +100,7 @@ jobs: | ||||||
|           key: ${{ runner.os }}-pip-${{ hashFiles('**/local.txt') }} |           key: ${{ runner.os }}-pip-${{ hashFiles('**/local.txt') }} | ||||||
|           restore-keys: | |           restore-keys: | | ||||||
|             ${{ runner.os }}-pip- |             ${{ runner.os }}-pip- | ||||||
|       {% endraw %} |       {%- endraw %} | ||||||
| 
 | 
 | ||||||
|       - name: Install Dependencies |       - name: Install Dependencies | ||||||
|         run: | |         run: | | ||||||
|  | @ -89,5 +109,4 @@ jobs: | ||||||
| 
 | 
 | ||||||
|       - name: Test with pytest |       - name: Test with pytest | ||||||
|         run:  pytest |         run:  pytest | ||||||
| 
 |  | ||||||
|       {%- endif %} |       {%- endif %} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user