From: Stephen Finucane Date: Fri, 19 Nov 2021 12:09:06 +0000 (+0000) Subject: Switch from Travis CI to GitHub Actions X-Git-Tag: v3.1.0~51 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9933a170ed6f3036e64603105fbaee356393579a;p=thirdparty%2Fpatchwork.git Switch from Travis CI to GitHub Actions 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 --- diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..d2061a91 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -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 index 50b87a6c..00000000 --- a/.travis.yml +++ /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 diff --git a/README.rst b/README.rst index 973e870f..5de5e623 100644 --- a/README.rst +++ b/README.rst @@ -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 494e9fb5..0ed500a6 100644 --- 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} @@ -77,6 +77,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