From 1abfd539e398516130944891660eb8959c22e7b7 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 9 Nov 2020 18:46:19 +0000 Subject: [PATCH 1/8] Basic CI workflow using github actions --- .github/workflows/ci.yml | 33 +++++++++++++++++++++++++++++++++ .travis.yml | 36 ------------------------------------ 2 files changed, 33 insertions(+), 36 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..eb1aeec4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,33 @@ +name: CI + +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + script: + - name: Test results + run: tox -e py38 + - name: Black template + run: tox -e black-template + - name: Basic Docker + run: sh tests/test_docker.sh + - name: Extended Docker + run: sh tests/test_docker.sh use_celery=y use_drf=y js_task_runner=Gulp + - name: Bare metal + run: sh tests/test_bare.sh use_celery=y use_compressor=y + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install dependencies + run: | + python -m pip install -U pip + python -m pip install -U tox + - name: ${{ matrix.script.name }} + run: ${{ matrix.script.run }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index bfd008e7..00000000 --- a/.travis.yml +++ /dev/null @@ -1,36 +0,0 @@ -services: - - docker - -language: python - -python: 3.8 - -before_install: - - docker-compose -v - - docker -v - -matrix: - include: - - name: Test results - script: tox -e py38 - - name: Black template - script: tox -e black-template - - name: Basic Docker - script: sh tests/test_docker.sh - - name: Extended Docker - script: sh tests/test_docker.sh use_celery=y use_drf=y js_task_runner=Gulp - - name: Bare metal - script: sh tests/test_bare.sh use_celery=y use_compressor=y - services: - - postgresql - - redis-server - env: - - CELERY_BROKER_URL=redis://localhost:6379/0 - -install: - - pip install tox - -notifications: - email: - on_success: change - on_failure: always From 0a56c9c9b9157db28dbe2427dd7a85acebe8e260 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 9 Nov 2020 19:01:29 +0000 Subject: [PATCH 2/8] Split out workflow to add services for bare metal tests --- .github/workflows/ci.yml | 69 ++++++++++++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eb1aeec4..3785ec7c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,22 +3,14 @@ name: CI on: [push, pull_request] jobs: - test: + tox: runs-on: ubuntu-latest strategy: fail-fast: false matrix: - script: - - name: Test results - run: tox -e py38 - - name: Black template - run: tox -e black-template - - name: Basic Docker - run: sh tests/test_docker.sh - - name: Extended Docker - run: sh tests/test_docker.sh use_celery=y use_drf=y js_task_runner=Gulp - - name: Bare metal - run: sh tests/test_bare.sh use_celery=y use_compressor=y + tox-env: + - py38 + - black-template steps: - uses: actions/checkout@v2 @@ -29,5 +21,54 @@ jobs: run: | python -m pip install -U pip python -m pip install -U tox - - name: ${{ matrix.script.name }} - run: ${{ matrix.script.run }} + - name: Tox ${{ matrix.tox-env }} + run: tox -e ${{ matrix.tox-env }} + + docker: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + script: + - name: Basic + args: "" + - name: Extended + args: "use_celery=y use_drf=y js_task_runner=Gulp" + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Docker ${{ matrix.script.name }} + run: sh tests/test_docker.sh ${{ matrix.script.args }} + + bare: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + script: + - name: With Celery + args: "use_celery=y use_compressor=y" + + services: + redis: + image: redis + ports: + - 6379:6379 + postgres: + image: postgres + env: + POSTGRES_PASSWORD: postgres + + env: + CELERY_BROKER_URL: "redis://localhost:6379/0" + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Bare Metal ${{ matrix.script.name }} + run: sh tests/test_bare.sh ${{ matrix.script.args }} From 56268ec82c4b8969cefd2a87511fbfb15483ec4d Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 9 Nov 2020 19:06:49 +0000 Subject: [PATCH 3/8] Pin service images, expose DB ports and don't set PG password --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3785ec7c..32eaa054 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,13 +54,13 @@ jobs: services: redis: - image: redis + image: redis:5.0 ports: - 6379:6379 postgres: - image: postgres - env: - POSTGRES_PASSWORD: postgres + image: postgres:12 + ports: + - 5432:5432 env: CELERY_BROKER_URL: "redis://localhost:6379/0" From a625327226e77839b39865e484c8b2ce5a02f55e Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 9 Nov 2020 19:18:38 +0000 Subject: [PATCH 4/8] Set some environment variables --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 32eaa054..6bc0966b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,6 +35,10 @@ jobs: - name: Extended args: "use_celery=y use_drf=y js_task_runner=Gulp" + env: + DOCKER_BUILDKIT: 1 + COMPOSE_DOCKER_CLI_BUILD: 1 + steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 @@ -64,6 +68,7 @@ jobs: env: CELERY_BROKER_URL: "redis://localhost:6379/0" + DATABASE_URL: "postgres://postgres" steps: - uses: actions/checkout@v2 From c3d644083052025d05f27f8e786296349990dbc5 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 9 Nov 2020 19:23:48 +0000 Subject: [PATCH 5/8] Explicit DATABASE_URL --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6bc0966b..a943bfba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,10 +65,13 @@ jobs: image: postgres:12 ports: - 5432:5432 + env: + POSTGRES_PASSWORD: postgres env: CELERY_BROKER_URL: "redis://localhost:6379/0" - DATABASE_URL: "postgres://postgres" + # postgres://user:password@host:port/database + DATABASE_URL: "postgres://postgres:postgres@postgres:5432/postgres" steps: - uses: actions/checkout@v2 From 2233de8566830bbca8d02a5fe20a183831801823 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 9 Nov 2020 19:28:09 +0000 Subject: [PATCH 6/8] Connect to PG on localhost --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a943bfba..fb26dd8e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,7 +71,7 @@ jobs: env: CELERY_BROKER_URL: "redis://localhost:6379/0" # postgres://user:password@host:port/database - DATABASE_URL: "postgres://postgres:postgres@postgres:5432/postgres" + DATABASE_URL: "postgres://postgres:postgres@localhost:5432/postgres" steps: - uses: actions/checkout@v2 From 1e6104ce723809ff758a4b24967bb20dca75f762 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 9 Nov 2020 19:31:40 +0000 Subject: [PATCH 7/8] Update badge --- README.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index f964635f..dbc510a4 100644 --- a/README.rst +++ b/README.rst @@ -1,8 +1,8 @@ Cookiecutter Django -======================= +=================== -.. image:: https://travis-ci.org/pydanny/cookiecutter-django.svg?branch=master - :target: https://travis-ci.org/pydanny/cookiecutter-django?branch=master +.. image:: https://img.shields.io/github/workflow/status/pydanny/cookiecutter-django/CI/master + :target: https://github.com/pydanny/cookiecutter-django/actions?query=workflow%3ACI :alt: Build Status .. image:: https://readthedocs.org/projects/cookiecutter-django/badge/?version=latest From 46a0b60a29d34d3b8654382408541a0c52b890e6 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 9 Nov 2020 19:38:16 +0000 Subject: [PATCH 8/8] Ignore pushes to non-master branch to avoid double builds --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb26dd8e..fd966845 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,9 @@ name: CI -on: [push, pull_request] +on: + push: + branches: [ master ] + pull_request: jobs: tox: