From 5e0b72247ecab4ce0fcec599b77a83d73a480872 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Mon, 17 Aug 2020 22:09:34 -0700 Subject: [PATCH] Run CI on GitHub Actions, not Travis * Run CI on GitHub Actions, not Travis - refs #940 * Update documentation refs to Travis * Release action now runs parallel tests, then pushes to PyPI, then Docker Hub --- .dockerignore | 1 - .github/workflows/publish.yml | 72 +++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 29 ++++++++++++++ .travis.yml | 47 ----------------------- README.md | 2 +- docs/contributing.rst | 2 +- docs/index.rst | 4 +- setup.py | 2 +- 8 files changed, 106 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml diff --git a/.dockerignore b/.dockerignore index 938173e9..490f509e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,7 +3,6 @@ .eggs .gitignore .ipynb_checkpoints -.travis.yml build *.spec *.egg-info diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..4e554eda --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,72 @@ +name: Publish Python Package + +on: + release: + types: [created] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.6, 3.7, 3.8] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - uses: actions/cache@v2 + name: Configure pip caching + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install dependencies + run: | + pip install -e '.[test]' + - name: Run tests + run: | + pytest + deploy: + runs-on: ubuntu-latest + needs: [test] + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.8' + - uses: actions/cache@v2 + name: Configure pip caching + with: + path: ~/.cache/pip + key: ${{ runner.os }}-publish-pip-${{ hashFiles('**/setup.py') }} + restore-keys: | + ${{ runner.os }}-publish-pip- + - name: Install dependencies + run: | + pip install setuptools wheel twine + - name: Publish + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* + deploy_docker: + runs-on: ubuntu-latest + needs: [deploy] + steps: + - uses: actions/checkout@v2 + - name: Build and push to Docker Hub + env: + DOCKER_USER: ${{ secrets.DOCKER_USER }} + DOCKER_PASS: ${{ secrets.DOCKER_PASS }} + run: |- + docker login -u $DOCKER_USER -p $DOCKER_PASS + export REPO=datasetteproject/datasette + docker build -f Dockerfile -t $REPO::${GITHUB_REF#refs/tags/} . + docker tag $REPO::${GITHUB_REF#refs/tags/} $REPO:latest + docker push $REPO diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..74e56e13 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,29 @@ +name: Test + +on: [push] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.6, 3.7, 3.8] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - uses: actions/cache@v2 + name: Configure pip caching + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install dependencies + run: | + pip install -e '.[test]' + - name: Run tests + run: | + pytest diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 181bc3f3..00000000 --- a/.travis.yml +++ /dev/null @@ -1,47 +0,0 @@ -language: python -dist: xenial - -branches: - except: - - master - -# 3.6 is listed first so it gets used for the later build stages -python: - - "3.6" - - "3.7" - - "3.8" - -# Executed for 3.5 AND 3.5 as the first "test" stage: -script: - - pip install -U pip wheel - - pip install .[test] - - pytest - -cache: - directories: - - $HOME/.cache/pip - -# This defines further stages that execute after the tests -jobs: - include: - - stage: release tagged version - if: tag IS present - python: 3.6 - deploy: - - provider: pypi - user: simonw - distributions: "sdist bdist_wheel" - password: ${PYPI_PASSWORD} - on: - branch: master - tags: true - - stage: publish docker image - if: (tag IS present) AND NOT (tag =~ [ab]) - python: 3.6 - script: - # Build and release to Docker Hub - - docker login -u $DOCKER_USER -p $DOCKER_PASS - - export REPO=datasetteproject/datasette - - docker build -f Dockerfile -t $REPO:$TRAVIS_TAG . - - docker tag $REPO:$TRAVIS_TAG $REPO:latest - - docker push $REPO diff --git a/README.md b/README.md index ee3246a5..38ea7f79 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![PyPI](https://img.shields.io/pypi/v/datasette.svg)](https://pypi.org/project/datasette/) [![Changelog](https://img.shields.io/github/v/release/simonw/datasette?label=changelog)](https://docs.datasette.io/en/stable/changelog.html) [![Python 3.x](https://img.shields.io/pypi/pyversions/datasette.svg?logo=python&logoColor=white)](https://pypi.org/project/datasette/) -[![Travis CI](https://travis-ci.org/simonw/datasette.svg?branch=main)](https://travis-ci.org/simonw/datasette) +[![Tests](https://github.com/simonw/datasette/workflows/Test/badge.svg)](https://github.com/simonw/datasette/actions?query=workflow%3ATest) [![Documentation Status](https://readthedocs.org/projects/datasette/badge/?version=latest)](https://docs.datasette.io/en/latest/?badge=latest) [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/datasette/blob/main/LICENSE) [![docker: datasette](https://img.shields.io/badge/docker-datasette-blue)](https://hub.docker.com/r/datasetteproject/datasette) diff --git a/docs/contributing.rst b/docs/contributing.rst index 118146cf..95663dbc 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -126,7 +126,7 @@ Now browse to ``http://localhost:8000/`` to view the documentation. Any edits yo Release process --------------- -Datasette releases are performed using tags. When a new version tag is pushed to GitHub, a `Travis CI task `__ will perform the following: +Datasette releases are performed using tags. When a new release is published on GitHub, a `GitHub Action workflow `__ will perform the following: * Run the unit tests against all supported Python versions. If the tests pass... * Build a Docker image of the release and push a tag to https://hub.docker.com/r/datasetteproject/datasette diff --git a/docs/index.rst b/docs/index.rst index f9f2f0bb..946fa542 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -10,8 +10,8 @@ datasette| :target: https://docs.datasette.io/en/stable/changelog.html .. |Python 3.x| image:: https://img.shields.io/pypi/pyversions/datasette.svg?logo=python&logoColor=white :target: https://pypi.org/project/datasette/ -.. |Travis CI| image:: https://travis-ci.org/simonw/datasette.svg?branch=main - :target: https://travis-ci.org/simonw/datasette +.. |Tests| image:: https://github.com/simonw/datasette/workflows/Test/badge.svg + :target: https://github.com/simonw/datasette/actions?query=workflow%3ATest .. |License| image:: https://img.shields.io/badge/license-Apache%202.0-blue.svg :target: https://github.com/simonw/datasette/blob/main/LICENSE .. |docker: datasette| image:: https://img.shields.io/badge/docker-datasette-blue diff --git a/setup.py b/setup.py index bbd0aa8b..d9526149 100644 --- a/setup.py +++ b/setup.py @@ -38,7 +38,7 @@ setup( "Live demo": "https://latest.datasette.io/", "Source code": "https://github.com/simonw/datasette", "Issues": "https://github.com/simonw/datasette/issues", - "CI": "https://travis-ci.org/simonw/datasette", + "CI": "https://github.com/simonw/datasette/actions?query=workflow%3ATest", }, packages=find_packages(exclude=("tests",)), package_data={"datasette": ["templates/*.html"]},