Repository: latenighttales/alcali (language: python)

Issue:
Migrate tests to github actions




Discussion / hints:

Fix patch:
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 9a20d89c..00000000
--- a/.travis.yml
+++ /dev/null
@@ -1,42 +0,0 @@
-language: python
-python: 3.6
-
-services: docker
-
-env:
-  - DOCKER_COMPOSE_VERSION=1.23.2
-
-before_install:
-  # Stop the postgres instance travis sets up automatically
-  - sudo /etc/init.d/postgresql stop
-  - sudo /etc/init.d/mysql stop
-
-  # Update Docker compose
-  - sudo rm /usr/local/bin/docker-compose
-  - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
-  - chmod +x docker-compose
-  - sudo mv docker-compose /usr/local/bin
-  - docker -v
-  - docker-compose --version
-
-  # Setup env config
-  - export USER_ID=$(id -u ${USER})
-  - cp env.sample .env
-
-install:
-  - pip install black
-  - docker-compose -f docker-compose-ci.yml up --build -d
-
-script:
-  - bash docker/utils/ci_script.sh
-
-after_script:
-  - black --check .
-
-after_success:
-  - docker-compose exec -u alcali web safety check
-  - docker-compose exec -u alcali -e CODECOV_TOKEN web codecov -X s3
-
-after_failure:
-  - docker-compose logs
-
diff --git a/README.md b/README.md
index 5a5222be..c5fcb63f 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
 # Alcali
 
-[![Build Status](https://travis-ci.org/latenighttales/alcali.svg?branch=2019.2)](https://travis-ci.org/latenighttales/alcali)
+[![Build](https://github.com/latenighttales/alcali/actions/workflows/test_on_push.yml/badge.svg?branch=develop)](https://github.com/latenighttales/alcali/actions/workflows/test_on_push.yml)
 [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
 [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=latenighttales/alcali)](https://dependabot.com)
 [![codecov](https://codecov.io/gh/latenighttales/alcali/branch/2019.2.0/graph/badge.svg)](https://codecov.io/gh/latenighttales/alcali)
diff --git a/docker/utils/ci_script.sh b/docker/utils/ci_script.sh
index 096a470c..07304304 100755
--- a/docker/utils/ci_script.sh
+++ b/docker/utils/ci_script.sh
@@ -1,16 +1,19 @@
 #!/bin/bash
 
-docker-compose exec -u alcali web pip install --quiet --user -r requirements/test.txt
-while ! [[ $(docker-compose exec -u alcali web alcali check | grep -P "db:\tok") ]]; do
+docker-compose exec -T -u alcali web pip install --quiet --user -r requirements/test.txt
+while ! [[ $(docker-compose exec -T -u alcali web alcali check | grep -P "db:\tok") ]]; do
   echo "Waiting Database..."
-  docker-compose exec -u alcali web alcali check
+  docker-compose exec -T -u alcali web alcali check
   sleep 10
 done
-docker-compose exec -u alcali web alcali migrate
-docker-compose exec -u alcali web alcali shell -c "from django.contrib.auth.models import User; User.objects.filter(username='admin').count() or User.objects.create_superuser('admin', 'admin@example.com', 'password')"
+docker-compose exec -T -u alcali web alcali migrate
+docker-compose exec -T -u alcali web alcali shell -c "from django.contrib.auth.models import User; User.objects.filter(username='admin').count() or User.objects.create_superuser('admin', 'admin@example.com', 'password')"
 
 while ! [[ $(docker-compose logs | grep "The Salt Master has cached the public key for this node") ]]; do
   echo "Waiting Salt Master..."
   sleep 10
 done
-docker-compose exec -u alcali web pytest
+# python coverage is having trouble writing .coverage file
+docker-compose exec -T -u root web chown -R alcali:alcali /opt/alcali
+docker-compose exec -T -u alcali web pytest
+
diff --git a/requirements/prod.txt b/requirements/prod.txt
index 8131e69d..cb237fc7 100644
--- a/requirements/prod.txt
+++ b/requirements/prod.txt
@@ -1,5 +1,5 @@
 ansi2html==1.6.0
-Django==3.1.7
+Django==3.1.13
 django-cors-headers==3.7.0
 django-currentuser==0.5.2
 djangorestframework==3.12.2


Test patch:
diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml
new file mode 100644
index 00000000..d8bde000
--- /dev/null
+++ b/.github/workflows/test_on_push.yml
@@ -0,0 +1,29 @@
+name: Test on push
+on: push
+jobs:
+  test:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - name: Setup env config
+        run: cp env.sample .env
+      - name: Install black
+        run: pip install black
+      - name: Build the stack
+        run: docker-compose -f docker-compose-ci.yml up -d
+      - name: Test
+        run: bash docker/utils/ci_script.sh
+      - name: Check safety
+        if: ${{ success() }}
+        run: docker-compose exec -T -u alcali web safety check
+      - name: Check format
+        if: ${{ success() }}
+        run: black --check .
+      - name: Upload Codecov
+        if: ${{ success() }}
+        env:
+          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
+        run: docker-compose exec -T -u alcali -e "$env:CODECOV_TOKEN" web codecov -X s3
+      - name: Show logs
+        if: ${{ failure() }}
+        run: docker-compose logs
diff --git a/requirements/test.txt b/requirements/test.txt
index ad7547a1..c9febb03 100644
--- a/requirements/test.txt
+++ b/requirements/test.txt
@@ -1,6 +1,6 @@
-pytest==6.2.2
-pytest-cov==2.11.1
-pytest-django==3.9.0
+pytest==6.2.4
+pytest-cov==2.12.1
+pytest-django==4.4.0
 pytest-pythonpath==0.7.3
 codecov==2.1.9
 safety