]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
Switch from Travis CI to GitHub Actions
authorStephen Finucane <stephen@that.guru>
Fri, 19 Nov 2021 12:09:06 +0000 (12:09 +0000)
committerStephen Finucane <stephen@that.guru>
Tue, 10 May 2022 17:28:16 +0000 (18:28 +0100)
Travis has imposed quotas on builds that require us to contact them to
obtain OSS credits. The CI tool is irrelevant so long as builds do
happen, so switch to GitHub Actions for now. This is a little more
complicated that the switch for related projects like git-pw, given the
need for a database service. We may wish to investigate reusing some of
our own Docker files in the future but for now, this should do the
trick.

Signed-off-by: Stephen Finucane <stephen@that.guru>
(cherry picked from commit 9933a170ed6f3036e64603105fbaee356393579a)

.github/workflows/ci.yaml [new file with mode: 0644]
.travis.yml [deleted file]
README.rst
tox.ini

diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
new file mode 100644 (file)
index 0000000..d2061a9
--- /dev/null
@@ -0,0 +1,104 @@
+---
+name: CI
+on:
+  - push
+  - pull_request
+jobs:
+  lint:
+    name: Run linters
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout source code
+        uses: actions/checkout@v2
+      - name: Set up Python 3.9
+        uses: actions/setup-python@v2
+        with:
+          python-version: 3.9
+      - name: Install dependencies
+        run: python -m pip install tox
+      - name: Run tox
+        run: tox -e pep8
+  test:
+    name: Run unit tests
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        python: [3.6, 3.7, 3.8, 3.9]
+        db: [postgres, mysql]
+    services:
+      postgres:
+        image: postgres:latest
+        env:
+          POSTGRES_DB: patchwork
+          POSTGRES_PASSWORD: patchwork
+          POSTGRES_USER: patchwork
+        ports:
+          - 5432:5432
+        options: >-
+          --health-cmd pg_isready
+          --health-interval 10s
+          --health-timeout 5s
+          --health-retries 5
+      mysql:
+        image: mysql:latest
+        env:
+          MYSQL_DATABASE: patchwork
+          MYSQL_USER: patchwork
+          MYSQL_PASSWORD: patchwork
+          MYSQL_ROOT_PASSWORD: root
+        ports:
+          - 3306:3306
+        options: >-
+          --health-cmd="mysqladmin ping"
+          --health-interval 10s
+          --health-timeout 5s
+          --health-retries 5
+    steps:
+      - name: Checkout source code
+        uses: actions/checkout@v2
+      - name: Set up Python ${{ matrix.python }}
+        uses: actions/setup-python@v2
+        with:
+          python-version: ${{ matrix.python }}
+      - name: Install Python dependencies
+        run: python -m pip install tox tox-gh-actions codecov
+      - name: Log database configuration (mysql)
+        if: ${{ matrix.db == 'mysql' }}
+        run: mysql -h 127.0.0.1 -e "SELECT VERSION(), CURRENT_USER();" -uroot -proot patchwork
+      - name: Log database configuration (postgres)
+        if: ${{ matrix.db == 'postgres' }}
+        run: psql -h 127.0.0.1 -c "SELECT VERSION(), CURRENT_USER, current_database()" -U patchwork -d patchwork
+        env:
+          PGPASSWORD: patchwork
+      - name: Modify database user permissions (mysql)
+        if: ${{ matrix.db == 'mysql' }}
+        run: mysql -h 127.0.0.1 -e "GRANT ALL ON \`test\\_patchwork%\`.* to 'patchwork'@'%';" -uroot -proot
+      - name: Run unit tests (via tox)
+        run: tox
+        env:
+          PW_TEST_DB_TYPE: "${{ matrix.db }}"
+          PW_TEST_DB_USER: "patchwork"
+          PW_TEST_DB_PASS: "patchwork"
+          PW_TEST_DB_HOST: "127.0.0.1"
+  docs:
+    name: Build docs
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout source code
+        uses: actions/checkout@v2
+        with:
+          fetch-depth: 0
+      - name: Set up Python 3.9
+        uses: actions/setup-python@v2
+        with:
+          python-version: 3.9
+      - name: Install dependencies
+        run: python -m pip install tox
+      - name: Build docs (via tox)
+        run: tox -e docs
+      - name: Archive build results
+        uses: actions/upload-artifact@v2
+        with:
+          name: html-docs-build
+          path: docs/_build/html
+          retention-days: 7
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644 (file)
index 50b87a6..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-language: python
-
-os: linux
-dist: xenial
-
-python:
-  - 3.6
-  - 3.7
-  - 3.8
-
-addons:
-  postgresql: 9.6
-
-services:
-  - mysql
-  - postgresql
-
-env:
-  jobs:
-    - PW_TEST_DB_TYPE=postgres PW_TEST_DB_USER=postgres
-    - PW_TEST_DB_TYPE=mysql PW_TEST_DB_USER=root
-  global:
-    - PW_TEST_DB_PASS=""
-    - PW_TEST_DB_HOST="localhost"
-
-jobs:
-  include:
-    - addons:
-        mariadb: 10.3
-      env:
-        - PW_TEST_DB_TYPE=mysql
-        - PW_TEST_DB_USER=root
-    - addons:
-        postgresql: 10
-      env:
-        - PW_TEST_DB_TYPE=postgres
-        - PW_TEST_DB_USER=postgres
-      python: 3.7
-
-before_script:
-  - if [[ $PW_TEST_DB_TYPE == mysql ]]; then mysql -e "create database patchwork character set utf8;"; fi
-  - if [[ $PW_TEST_DB_TYPE == postgres ]]; then psql -c "create database patchwork with ENCODING = 'UTF8';" -U $PW_TEST_DB_USER; fi
-
-install:
-  - pip install tox-travis
-  - pip install codecov
-
-script:
-  - >
-    if [[ $PW_TEST_DB_TYPE == mysql ]];
-    then
-      mysql -e "SELECT VERSION(), CURRENT_USER();" -u $PW_TEST_DB_USER patchwork;
-    else
-      psql -c "SELECT VERSION(), CURRENT_USER, current_database()" -U $PW_TEST_DB_USER patchwork;
-    fi
-  - tox
-
-after_success:
-  - codecov
index 7af45ce7245469c8bb2d5f2de408705f87e2f896..2bf30ae54ad4c7500defbc29df5c529b6267899a 100644 (file)
@@ -10,8 +10,8 @@ Patchwork
    :target: https://codecov.io/gh/getpatchwork/patchwork
    :alt: Codecov
 
-.. image:: https://travis-ci.org/getpatchwork/patchwork.svg?branch=master
-   :target: https://travis-ci.org/getpatchwork/patchwork
+.. image:: https://github.com/getpatchwork/patchwork/actions/workflows/ci.yaml/badge.svg
+   :target: https://github.com/getpatchwork/patchwork/actions/workflows/ci.yaml
    :alt: Build Status
 
 .. image:: https://readthedocs.org/projects/patchwork/badge/?version=latest
diff --git a/tox.ini b/tox.ini
index 46d72517dcc4d0e784680616d9479cd9b1242c41..4db9b20b7ee8cf425ccdf57574bec10e9c1a0adf 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -26,7 +26,7 @@ setenv =
 passenv =
     http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
     PW_TEST_DB_TYPE PW_TEST_DB_USER PW_TEST_DB_PASS PW_TEST_DB_HOST
-    PW_TEST_DB_PORT
+    PW_TEST_DB_PORT PW_TEST_DB_NAME DJANGO_TEST_PROCESSES
 commands =
     python {toxinidir}/manage.py test --noinput --parallel -- {posargs:patchwork}
 
@@ -78,6 +78,9 @@ commands =
          --branch {toxinidir}/manage.py test --noinput patchwork
     coverage report -m
 
-[travis]
+[gh-actions]
 python =
-    3.6: py36, pep8, coverage
+    3.6: py36
+    3.7: py37
+    3.8: py38
+    3.9: py39